From 181a3306a6970d76659e5eed1ae953b28f36e06e Mon Sep 17 00:00:00 2001 From: theelk801 Date: Wed, 14 May 2025 21:28:10 -0400 Subject: [PATCH] [FIN] Implement Retrieve the Esper --- .../src/mage/cards/r/RetrieveTheEsper.java | 78 +++++++++++++++++++ Mage.Sets/src/mage/sets/FinalFantasy.java | 1 + .../game/permanent/token/RobotBlueToken.java | 29 +++++++ 3 files changed, 108 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/r/RetrieveTheEsper.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/RobotBlueToken.java diff --git a/Mage.Sets/src/mage/cards/r/RetrieveTheEsper.java b/Mage.Sets/src/mage/cards/r/RetrieveTheEsper.java new file mode 100644 index 00000000000..e90a12a9a0b --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RetrieveTheEsper.java @@ -0,0 +1,78 @@ +package mage.cards.r; + +import mage.abilities.Ability; +import mage.abilities.condition.common.CastFromGraveyardSourceCondition; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.FlashbackAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.token.RobotBlueToken; +import mage.game.permanent.token.Token; + +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class RetrieveTheEsper extends CardImpl { + + public RetrieveTheEsper(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}"); + + // Create a 3/3 blue Robot Warrior artifact creature token. Then if this spell was cast from a graveyard, put two +1/+1 counters on that token. + this.getSpellAbility().addEffect(new RetrieveTheEsperEffect()); + + // Flashback {5}{U} + this.addAbility(new FlashbackAbility(this, new ManaCostsImpl<>("{5}{U}"))); + } + + private RetrieveTheEsper(final RetrieveTheEsper card) { + super(card); + } + + @Override + public RetrieveTheEsper copy() { + return new RetrieveTheEsper(this); + } +} + +class RetrieveTheEsperEffect extends OneShotEffect { + + RetrieveTheEsperEffect() { + super(Outcome.Benefit); + staticText = "create a 3/3 blue Robot Warrior artifact creature token. " + + "Then if this spell was cast from a graveyard, put two +1/+1 counters on that token"; + } + + private RetrieveTheEsperEffect(final RetrieveTheEsperEffect effect) { + super(effect); + } + + @Override + public RetrieveTheEsperEffect copy() { + return new RetrieveTheEsperEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Token token = new RobotBlueToken(); + token.putOntoBattlefield(1, game, source); + if (!CastFromGraveyardSourceCondition.instance.apply(game, source)) { + return true; + } + for (UUID tokenId : token.getLastAddedTokenIds()) { + Optional.ofNullable(tokenId) + .map(game::getPermanent) + .ifPresent(permanent -> permanent.addCounters( + CounterType.P1P1.createInstance(2), source, game + )); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/FinalFantasy.java b/Mage.Sets/src/mage/sets/FinalFantasy.java index e19379f940b..caa70bf10ea 100644 --- a/Mage.Sets/src/mage/sets/FinalFantasy.java +++ b/Mage.Sets/src/mage/sets/FinalFantasy.java @@ -173,6 +173,7 @@ public final class FinalFantasy extends ExpansionSet { cards.add(new SetCardInfo("Ragnarok, Divine Deliverance", "446b", Rarity.UNCOMMON, mage.cards.r.RagnarokDivineDeliverance.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Ragnarok, Divine Deliverance", "526b", Rarity.UNCOMMON, mage.cards.r.RagnarokDivineDeliverance.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Ragnarok, Divine Deliverance", "99b", Rarity.UNCOMMON, mage.cards.r.RagnarokDivineDeliverance.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Retrieve the Esper", 68, Rarity.COMMON, mage.cards.r.RetrieveTheEsper.class)); cards.add(new SetCardInfo("Rinoa Heartilly", 237, Rarity.UNCOMMON, mage.cards.r.RinoaHeartilly.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Rinoa Heartilly", 502, Rarity.UNCOMMON, mage.cards.r.RinoaHeartilly.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Rosa, Resolute White Mage", 431, Rarity.RARE, mage.cards.r.RosaResoluteWhiteMage.class, NON_FULL_USE_VARIOUS)); diff --git a/Mage/src/main/java/mage/game/permanent/token/RobotBlueToken.java b/Mage/src/main/java/mage/game/permanent/token/RobotBlueToken.java new file mode 100644 index 00000000000..c3a2e7996e1 --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/RobotBlueToken.java @@ -0,0 +1,29 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.constants.CardType; +import mage.constants.SubType; + +/** + * @author TheElk801 + */ +public final class RobotBlueToken extends TokenImpl { + + public RobotBlueToken() { + super("Robot Token", "3/3 blue Robot Warrior artifact creature token"); + cardType.add(CardType.ARTIFACT); + cardType.add(CardType.CREATURE); + color.setBlue(true); + subtype.add(SubType.ROBOT); + power = new MageInt(3); + toughness = new MageInt(3); + } + + private RobotBlueToken(final RobotBlueToken token) { + super(token); + } + + public RobotBlueToken copy() { + return new RobotBlueToken(this); + } +}