Fix #10254 (Alora, Merry Thief)

This commit is contained in:
xenohedron 2023-07-10 00:06:23 -04:00
parent 820c5ffe17
commit 53797ea276

View file

@ -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;
}
}