From bea736aa54f1721d33e944a108f2a591282f143a Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 7 Apr 2021 19:24:41 -0400 Subject: [PATCH] [STX] Implemented Retriever Phoenix --- .../src/mage/cards/r/RetrieverPhoenix.java | 98 +++++++++++++++++++ .../mage/sets/StrixhavenSchoolOfMages.java | 1 + .../abilities/effects/common/LearnEffect.java | 19 +++- .../main/java/mage/game/events/GameEvent.java | 1 + 4 files changed, 115 insertions(+), 4 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/r/RetrieverPhoenix.java diff --git a/Mage.Sets/src/mage/cards/r/RetrieverPhoenix.java b/Mage.Sets/src/mage/cards/r/RetrieverPhoenix.java new file mode 100644 index 0000000000..5d60ef4a53 --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RetrieverPhoenix.java @@ -0,0 +1,98 @@ +package mage.cards.r; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.common.CastFromEverywhereSourceCondition; +import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.LearnEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.HasteAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.players.Player; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class RetrieverPhoenix extends CardImpl { + + public RetrieverPhoenix(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}"); + + this.subtype.add(SubType.PHOENIX); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Haste + this.addAbility(HasteAbility.getInstance()); + + // When Retriever Phoenix enters the battlefield, if you cast it, learn. + this.addAbility(new ConditionalInterveningIfTriggeredAbility( + new EntersBattlefieldTriggeredAbility(new LearnEffect()), CastFromEverywhereSourceCondition.instance, + "When {thi} enters the battlefield, if you cast it, " + LearnEffect.getDefaultText() + )); + + // As long as Retriever Phoenix is in your graveyard, if you would learn, you may instead return Retriever Phoenix to the battlefield. + this.addAbility(new SimpleStaticAbility(Zone.GRAVEYARD, new RetrieverPhoenixEffect())); + } + + private RetrieverPhoenix(final RetrieverPhoenix card) { + super(card); + } + + @Override + public RetrieverPhoenix copy() { + return new RetrieverPhoenix(this); + } +} + +class RetrieverPhoenixEffect extends ReplacementEffectImpl { + + RetrieverPhoenixEffect() { + super(Duration.WhileInGraveyard, Outcome.PutCreatureInPlay); + staticText = "as long as {this} is in your graveyard, if you would learn, " + + "you may instead return {this} to the battlefield"; + } + + private RetrieverPhoenixEffect(final RetrieverPhoenixEffect effect) { + super(effect); + } + + @Override + public RetrieverPhoenixEffect copy() { + return new RetrieverPhoenixEffect(this); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + MageObject sourceObject = source.getSourceObjectIfItStillExists(game); + Player player = game.getPlayer(source.getControllerId()); + return sourceObject instanceof Card + && player != null + && player.chooseUse(outcome, "Return " + sourceObject.getName() + " to the battlefield instead of learning?", source, game) + && player.moveCards((Card) sourceObject, Zone.BATTLEFIELD, source, game); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.LEARN; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + return source.isControlledBy(event.getPlayerId()); + } +} diff --git a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java index c7135e5774..aaedd824d7 100644 --- a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java +++ b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java @@ -198,6 +198,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet { cards.add(new SetCardInfo("Reject", 50, Rarity.COMMON, mage.cards.r.Reject.class)); cards.add(new SetCardInfo("Relic Sloth", 223, Rarity.COMMON, mage.cards.r.RelicSloth.class)); cards.add(new SetCardInfo("Resculpt", 51, Rarity.COMMON, mage.cards.r.Resculpt.class)); + cards.add(new SetCardInfo("Retriever Phoenix", 113, Rarity.RARE, mage.cards.r.RetrieverPhoenix.class)); cards.add(new SetCardInfo("Returned Pastcaller", 224, Rarity.UNCOMMON, mage.cards.r.ReturnedPastcaller.class)); cards.add(new SetCardInfo("Rip Apart", 225, Rarity.UNCOMMON, mage.cards.r.RipApart.class)); cards.add(new SetCardInfo("Rise of Extus", 226, Rarity.COMMON, mage.cards.r.RiseOfExtus.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/LearnEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LearnEffect.java index e4b90b1d6e..385f25e2bb 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/LearnEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/LearnEffect.java @@ -7,7 +7,7 @@ import mage.constants.Outcome; import mage.constants.SubType; import mage.filter.FilterCard; import mage.game.Game; -import mage.players.Player; +import mage.game.events.GameEvent; /** * @author TheElk801 @@ -20,10 +20,12 @@ public class LearnEffect extends OneShotEffect { filter.add(SubType.LESSON.getPredicate()); } + private static final String defaultText = "learn. (You may reveal a Lesson card you own from outside the game " + + "and put it into your hand, or discard a card to draw a card.)"; + public LearnEffect() { super(Outcome.Neutral); - staticText = "learn. (You may reveal a Lesson card you own from outside the game " + - "and put it into your hand, or discard a card to draw a card.)"; + staticText = defaultText; } private LearnEffect(final LearnEffect effect) { @@ -32,7 +34,12 @@ public class LearnEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); + if (game.replaceEvent(GameEvent.getEvent( + GameEvent.EventType.LEARN, source.getSourceId(), + source, source.getControllerId() + ))) { + return false; + } return new WishEffect(filter, true).apply(game, source) || new DoIfCostPaid( new DrawCardSourceControllerEffect(1), new DiscardCardCost() @@ -43,4 +50,8 @@ public class LearnEffect extends OneShotEffect { public LearnEffect copy() { return new LearnEffect(this); } + + public static String getDefaultText() { + return defaultText; + } } diff --git a/Mage/src/main/java/mage/game/events/GameEvent.java b/Mage/src/main/java/mage/game/events/GameEvent.java index 175bcd14a6..d5e603ebbd 100644 --- a/Mage/src/main/java/mage/game/events/GameEvent.java +++ b/Mage/src/main/java/mage/game/events/GameEvent.java @@ -301,6 +301,7 @@ public class GameEvent implements Serializable { DIDNT_PAY_CUMULATIVE_UPKEEP, LIFE_PAID, CASCADE_LAND, + LEARN, //permanent events ENTERS_THE_BATTLEFIELD_SELF, /* 616.1a If any of the replacement and/or prevention effects are self-replacement effects (see rule 614.15), one of them must be chosen. If not, proceed to rule 616.1b. */