@Override public AtTheBeginOfNextEndStepDelayedTriggeredAbility copy() { return new AtTheBeginOfNextEndStepDelayedTriggeredAbility(this); }
@Override public String getRule() { StringBuilder sb = new StringBuilder(); switch (targetController) { case YOU: sb.append("At the beginning of your next end step, "); break; case OPPONENT: sb.append("At the beginning of an opponent's next end step, "); break; case ANY: sb.append("At the beginning of the next end step, "); break; case CONTROLLER_ATTACHED_TO: sb.append("At the beginning of the next end step of enchanted creature's controller, "); break; } sb.append(getEffects().getText(modes.getMode())); return sb.toString(); } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), 0)); if (exileZone != null) { Effect effect = new ReturnFromExileEffect(exileZone.getId(), Zone.HAND); AtTheBeginOfNextEndStepDelayedTriggeredAbility ability = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect); ability.addEffect(new DrawCardSourceControllerEffect(1)); game.addDelayedTriggeredAbility(ability, source); return true; } } return false; } }
@Override public boolean apply(Game game, Ability source) { DestroyTargetEffect effect = new DestroyTargetEffect(); effect.setTargetPointer(new FixedTarget(source.getFirstTarget())); AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.ALL, effect, TargetController.ANY, new InvertCondition(TargetAttackedThisTurnCondition.instance)); delayedAbility.getDuration(); delayedAbility.getTargets().addAll(source.getTargets()); game.addDelayedTriggeredAbility(delayedAbility, source); return true; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(game.getActivePlayerId()); if (player != null) { Set<MageObjectReference> activeCreatures = new HashSet<>(); for (Permanent creature : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) { if (creature != null) { activeCreatures.add(new MageObjectReference(creature, game)); } } AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.ALL, new MaddeningImpDelayedDestroyEffect(activeCreatures), TargetController.ANY, new InvertCondition(TargetAttackedThisTurnCondition.instance)); delayedAbility.getDuration(); game.addDelayedTriggeredAbility(delayedAbility, source); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent aura = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (aura != null) { Permanent enchantedCreature = game.getPermanentOrLKIBattlefield(aura.getAttachedTo()); if (enchantedCreature != null) { Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (permanent != null) { if (permanent.destroy(source.getSourceId(), game, false)) { AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance())); delayedAbility.getEffects().get(0).setTargetPointer(new FixedTarget(enchantedCreature, game)); game.addDelayedTriggeredAbility(delayedAbility, source); } return true; } } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { boolean correctEndPhase = false; switch (targetController) { case ANY: correctEndPhase = true; break; case YOU: correctEndPhase = event.getPlayerId().equals(this.controllerId); break; case OPPONENT: if (game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) { correctEndPhase = true; } break; case CONTROLLER_ATTACHED_TO: Permanent attachment = game.getPermanent(sourceId); if (attachment != null && attachment.getAttachedTo() != null) { Permanent attachedTo = game.getPermanent(attachment.getAttachedTo()); if (attachedTo != null && attachedTo.isControlledBy(event.getPlayerId())) { correctEndPhase = true; } } } if (correctEndPhase) { return !(condition != null && !condition.apply(game, this)); } return false; }
@Override public boolean apply(Game game, Ability source) { DestroyTargetEffect effect = new DestroyTargetEffect(); effect.setTargetPointer(new FixedTarget(source.getFirstTarget())); AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.ALL, effect, TargetController.ANY, new InvertCondition(TargetAttackedThisTurnCondition.instance)); delayedAbility.getDuration(); delayedAbility.getTargets().addAll(source.getTargets()); game.addDelayedTriggeredAbility(delayedAbility, source); return true; } }
public ArcaneArtisanLeavesBattlefieldTriggeredAbility() { super(Zone.BATTLEFIELD, null, new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ArcaneArtisanExileEffect())), "", false ); }
public PureIntentionsTriggeredAbility() { super(Zone.ALL, new CreateDelayedTriggeredAbilityEffect( new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnSourceFromGraveyardToHandEffect())), false); }
@Override public boolean apply(Game game, Ability source) { return new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextEndStepDelayedTriggeredAbility( new SacrificeTargetEffect("sacrifice it", source.getControllerId()) )).apply(game, source); } }
public PrizedAmalgam(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}{B}"); this.subtype.add(SubType.ZOMBIE); this.power = new MageInt(3); this.toughness = new MageInt(3); // Whenever a creature enters the battlefield, if it entered from your graveyard or you cast it from your graveyard, return Prized Amalgam from your graveyard to the battlefield tapped at the beginning of the next end step. Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect(true); effect.setText("return {this} from your graveyard to the battlefield tapped at the beginning of the next end step"); this.addAbility(new PrizedAmalgamTriggerdAbility(new CreateDelayedTriggeredAbilityEffect( new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect)), filter), new CastFromGraveyardWatcher()); }
@Override public boolean apply(Game game, Permanent permanent, Ability source, UUID copyToObjectId) { permanent.addSuperType(SuperType.LEGENDARY); permanent.setName("Sakashima the Impostor"); // {2}{U}{U}: Return Sakashima the Impostor to its owner's hand at the beginning of the next end step permanent.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnToHandSourceEffect(true)), false), new ManaCostsImpl("{2}{U}{U}") ), game); return true; }
public void exileTokensCreatedAtNextEndStep(Game game, Ability source) { for (Permanent tokenPermanent : addedTokenPermanents) { ExileTargetEffect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD); exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game)); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source); } }
@Override public boolean apply(Game game, MageObject mageObject, Ability source, UUID copyToObjectId) { mageObject.addSuperType(SuperType.LEGENDARY); mageObject.setName("Sakashima the Impostor"); // {2}{U}{U}: Return Sakashima the Impostor to its owner's hand at the beginning of the next end step mageObject.getAbilities().add(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnToHandSourceEffect(true)), false), new ManaCostsImpl("{2}{U}{U}") )); return true; }
public GloriousEnd(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{R}"); // End the turn. getSpellAbility().addEffect(new EndTurnEffect()); // At the beginning of your next end step, you lose the game. getSpellAbility().addEffect(new CreateDelayedTriggeredAbilityEffect( new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new LoseGameSourceControllerEffect(), TargetController.YOU))); }
public FalseMemories(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{U}"); // Put the top seven cards of your library into your graveyard. this.getSpellAbility().addEffect(new PutTopCardOfLibraryIntoGraveControllerEffect(7)); // At the beginning of the next end step, exile seven cards from your graveyard. this.getSpellAbility().addEffect(new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ExileCardFromOwnGraveyardControllerEffect(7)))); }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Set<Card> cardsToExile = new HashSet<>(); cardsToExile.addAll(game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)); controller.moveCards(cardsToExile, Zone.EXILED, source, game); //Delayed ability game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility( new SyntheticDestinyDelayedEffect(cardsToExile.size())), source); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new OpponentGainControlEffect()), source); return true; } return false; }
public IdeasUnbound(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{U}{U}"); this.subtype.add(SubType.ARCANE); // Draw three cards. Discard three cards at the beginning of the next end step. this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(3)); this.getSpellAbility().addEffect(new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new DiscardControllerEffect(3)))); }