From 2bc056278dbecb2879a303e02b147f123a566313 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 17 Sep 2019 20:41:02 -0400 Subject: [PATCH] Implemented Escape to the Wilds --- .../src/mage/cards/e/EscapeToTheWilds.java | 119 ++++++++++++++++++ Mage.Sets/src/mage/sets/ThroneOfEldraine.java | 1 + 2 files changed, 120 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/e/EscapeToTheWilds.java diff --git a/Mage.Sets/src/mage/cards/e/EscapeToTheWilds.java b/Mage.Sets/src/mage/cards/e/EscapeToTheWilds.java new file mode 100644 index 0000000000..0c36bdd097 --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/EscapeToTheWilds.java @@ -0,0 +1,119 @@ +package mage.cards.e; + +import mage.abilities.Ability; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.PlayAdditionalLandsControllerEffect; +import mage.cards.*; +import mage.constants.*; +import mage.game.Game; +import mage.players.Player; +import mage.target.targetpointer.FixedTarget; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class EscapeToTheWilds extends CardImpl { + + public EscapeToTheWilds(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{R}{G}"); + + // Exile the top five cards of your library. You may play cards exiled this way until the end of your next turn. + // You may play an additional land this turn. + this.getSpellAbility().addEffect(new EscapeToTheWildsEffect()); + } + + private EscapeToTheWilds(final EscapeToTheWilds card) { + super(card); + } + + @Override + public EscapeToTheWilds copy() { + return new EscapeToTheWilds(this); + } +} + +class EscapeToTheWildsEffect extends OneShotEffect { + + EscapeToTheWildsEffect() { + super(Outcome.PlayForFree); + this.staticText = "Exile the top five cards of your library. " + + "You may play cards exiled this way until the end of your next turn.
" + + "You may play an additional land this turn."; + } + + private EscapeToTheWildsEffect(final EscapeToTheWildsEffect effect) { + super(effect); + } + + @Override + public EscapeToTheWildsEffect copy() { + return new EscapeToTheWildsEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5)); + Card sourceCard = game.getCard(source.getSourceId()); + controller.moveCards(cards, Zone.EXILED, source, game); + + cards.getCards(game).stream().forEach(card -> { + ContinuousEffect effect = new EscapeToTheWildsMayPlayEffect(); + effect.setTargetPointer(new FixedTarget(card.getId())); + game.addEffect(effect, source); + }); + game.addEffect(new PlayAdditionalLandsControllerEffect(1, Duration.EndOfTurn), source); + return true; + } +} + +class EscapeToTheWildsMayPlayEffect extends AsThoughEffectImpl { + + private int castOnTurn = 0; + + EscapeToTheWildsMayPlayEffect() { + super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.Custom, Outcome.Benefit); + this.staticText = "Until the end of your next turn, you may play that card."; + } + + private EscapeToTheWildsMayPlayEffect(final EscapeToTheWildsMayPlayEffect effect) { + super(effect); + castOnTurn = effect.castOnTurn; + } + + @Override + public EscapeToTheWildsMayPlayEffect copy() { + return new EscapeToTheWildsMayPlayEffect(this); + } + + @Override + public void init(Ability source, Game game) { + super.init(source, game); + castOnTurn = game.getTurnNum(); + } + + @Override + public boolean isInactive(Ability source, Game game) { + return castOnTurn != game.getTurnNum() + && game.getPhase().getStep().getType() == PhaseStep.END_TURN + && game.isActivePlayer(source.getControllerId()); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { + return source.isControlledBy(affectedControllerId) + && getTargetPointer().getTargets(game, source).contains(sourceId); + } +} diff --git a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java index 807401b18a..debc77c922 100644 --- a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java +++ b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java @@ -75,6 +75,7 @@ public final class ThroneOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Emry, Lurker of the Loch", 43, Rarity.RARE, mage.cards.e.EmryLurkerOfTheLoch.class)); cards.add(new SetCardInfo("Enchanted Carriage", 218, Rarity.UNCOMMON, mage.cards.e.EnchantedCarriage.class)); cards.add(new SetCardInfo("Epic Downfall", 85, Rarity.UNCOMMON, mage.cards.e.EpicDownfall.class)); + cards.add(new SetCardInfo("Escape to the Wilds", 189, Rarity.RARE, mage.cards.e.EscapeToTheWilds.class)); cards.add(new SetCardInfo("Eye Collector", 86, Rarity.COMMON, mage.cards.e.EyeCollector.class)); cards.add(new SetCardInfo("Faeburrow Elder", 190, Rarity.RARE, mage.cards.f.FaeburrowElder.class)); cards.add(new SetCardInfo("Faerie Formation", 316, Rarity.RARE, mage.cards.f.FaerieFormation.class));