From 53797ea2763108c3a6c54195c5de0b7eca7bb6df Mon Sep 17 00:00:00 2001 From: xenohedron Date: Mon, 10 Jul 2023 00:06:23 -0400 Subject: [PATCH] Fix #10254 (Alora, Merry Thief) --- .../src/mage/cards/a/AloraMerryThief.java | 49 +++++++++++++++---- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/Mage.Sets/src/mage/cards/a/AloraMerryThief.java b/Mage.Sets/src/mage/cards/a/AloraMerryThief.java index 344d1eba03c..d17cea95ccc 100644 --- a/Mage.Sets/src/mage/cards/a/AloraMerryThief.java +++ b/Mage.Sets/src/mage/cards/a/AloraMerryThief.java @@ -2,24 +2,25 @@ package mage.cards.a; import mage.MageInt; import mage.abilities.Ability; +import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.AttacksWithCreaturesTriggeredAbility; import mage.abilities.common.ChooseABackgroundAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; -import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ReturnToHandTargetEffect; import mage.abilities.effects.common.combat.CantBeBlockedTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.SubType; -import mage.constants.SuperType; +import mage.constants.*; +import mage.game.Game; +import mage.game.permanent.Permanent; import mage.target.common.TargetAttackingCreature; +import mage.target.targetpointer.FixedTarget; import java.util.UUID; /** - * @author TheElk801 + * @author xenohedron */ public final class AloraMerryThief extends CardImpl { @@ -36,10 +37,7 @@ public final class AloraMerryThief extends CardImpl { Ability ability = new AttacksWithCreaturesTriggeredAbility( new CantBeBlockedTargetEffect(Duration.EndOfTurn), 1 ); - ability.addEffect(new CreateDelayedTriggeredAbilityEffect( - new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnToHandTargetEffect() - .setText("return that creature to its owner's hand")), true - ).setText("Return that creature to its owner's hand at the beginning of the next end step")); + ability.addEffect(new AloraMerryThiefEffect()); ability.addTarget(new TargetAttackingCreature(0, 1)); this.addAbility(ability); @@ -56,3 +54,34 @@ public final class AloraMerryThief extends CardImpl { return new AloraMerryThief(this); } } + +class AloraMerryThiefEffect extends OneShotEffect { + + AloraMerryThiefEffect() { + super(Outcome.ReturnToHand); + this.staticText = "Return that creature to its owner's hand at the beginning of the next end step"; + } + + private AloraMerryThiefEffect(final AloraMerryThiefEffect effect) { + super(effect); + } + + @Override + public AloraMerryThiefEffect copy() { + return new AloraMerryThiefEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (creature == null) { + return false; + } + DelayedTriggeredAbility ability = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnToHandTargetEffect() + .setTargetPointer(new FixedTarget(creature, game)) + .setText("return that creature to its owner's hand")); + game.addDelayedTriggeredAbility(ability, source); + return true; + } + +}