use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class ElkinBottleCastFromExileEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
controller.moveCardsToExile(card, source, game, true, source.getSourceId(), CardUtil.createObjectRealtedWindowTitle(source, game, null));
ContinuousEffect effect = new ElkinBottleCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId(), game));
game.addEffect(effect, source);
}
return true;
}
return false;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class EmberwildeDjinnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId());
MageObject sourceObject = source.getSourceObject(game);
if (player == null || sourceObject == null) {
return false;
}
Cost cost = new OrCost(new ManaCostsImpl("{R}{R}"), new PayLifeCost(2), "{R}{R} or 2 life");
if (player.chooseUse(Outcome.GainControl, "Gain control of " + sourceObject.getLogName() + "?", source, game)) {
if (cost.pay(source, game, source, player.getId(), false)) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, false, player.getId());
effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
game.addEffect(effect, source);
player.resetStoredBookmark(game);
}
}
return true;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class FightOrFlightEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(game.getCombat().getAttackingPlayerId());
if (player != null && targetPlayer != null) {
int count = game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURES, targetPlayer.getId(), game);
TargetCreaturePermanent creatures = new TargetCreaturePermanent(0, count, new FilterCreaturePermanent("creatures to put in the first pile"), true);
List<Permanent> pile1 = new ArrayList<>();
creatures.setRequired(false);
if (player.choose(Outcome.Neutral, creatures, source.getSourceId(), game)) {
List<UUID> targets = creatures.getTargets();
for (UUID targetId : targets) {
Permanent p = game.getPermanent(targetId);
if (p != null) {
pile1.add(p);
}
}
}
List<Permanent> pile2 = new ArrayList<>();
for (Permanent p : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, targetPlayer.getId(), game)) {
if (!pile1.contains(p)) {
pile2.add(p);
}
}
boolean choice = targetPlayer.choosePile(outcome, "Choose which pile can attack this turn.", pile1, pile2, game);
List<Permanent> chosenPile = choice ? pile2 : pile1;
List<Permanent> otherPile = choice ? pile1 : pile2;
for (Permanent permanent : chosenPile) {
if (permanent != null) {
RestrictionEffect effect = new CantAttackTargetEffect(Duration.EndOfTurn);
effect.setText("");
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
}
game.informPlayers("Creatures that can attack this turn: " + otherPile.stream().map(Permanent::getLogName).collect(Collectors.joining(", ")));
return true;
}
return false;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class GlyphOfDelusionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (source.getTargets().get(1) != null) {
Permanent targetPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (targetPermanent != null) {
targetPermanent.addCounters(CounterType.GLYPH.createInstance(targetPermanent.getPower().getValue()), source.getControllerId(), source, game);
SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousRuleModifyingEffect(new DontUntapInControllersUntapStepSourceEffect(), new SourceHasCounterCondition(CounterType.GLYPH)).setText("This creature doesn't untap during your untap step if it has a glyph counter on it"));
GainAbilityTargetEffect effect = new GainAbilityTargetEffect(ability, Duration.Custom);
effect.setTargetPointer(new FixedTarget(targetPermanent.getId(), game));
game.addEffect(effect, source);
BeginningOfUpkeepTriggeredAbility ability2 = new BeginningOfUpkeepTriggeredAbility(new RemoveCounterSourceEffect(CounterType.GLYPH.createInstance()), TargetController.YOU, false);
GainAbilityTargetEffect effect2 = new GainAbilityTargetEffect(ability2, Duration.Custom);
effect2.setTargetPointer(new FixedTarget(targetPermanent.getId(), game));
game.addEffect(effect2, source);
}
}
return false;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class GlimmerpointStagEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
int zcc = permanent.getZoneChangeCounter(game);
controller.moveCards(permanent, Zone.EXILED, source, game);
// create delayed triggered ability
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
effect.setTargetPointer(new FixedTarget(permanent.getId(), zcc + 1));
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
return true;
}
return false;
}
Aggregations