From 28e3c685701fb91eb950be39d50ea2142d09823a Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Mon, 31 Oct 2022 07:59:59 -0500 Subject: [PATCH] [BRO] Implemented Teferi, Temporal Pilgrim (#9692) --- .../mage/cards/t/TeferiTemporalPilgrim.java | 110 ++++++++++++++++++ Mage.Sets/src/mage/sets/TheBrothersWar.java | 1 + .../permanent/token/SpiritTeferiToken.java | 36 ++++++ 3 files changed, 147 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/TeferiTemporalPilgrim.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/SpiritTeferiToken.java diff --git a/Mage.Sets/src/mage/cards/t/TeferiTemporalPilgrim.java b/Mage.Sets/src/mage/cards/t/TeferiTemporalPilgrim.java new file mode 100644 index 0000000000..080f6ef03c --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TeferiTemporalPilgrim.java @@ -0,0 +1,110 @@ +package mage.cards.t; + +import java.util.HashSet; +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.LoyaltyAbility; +import mage.abilities.common.DrawCardControllerTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.constants.*; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.SpiritTeferiToken; +import mage.players.Player; +import mage.target.common.TargetControlledPermanent; +import mage.target.common.TargetOpponent; + +/** + * + * @author weirddan455 + */ +public final class TeferiTemporalPilgrim extends CardImpl { + + public TeferiTemporalPilgrim(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{3}{U}{U}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.TEFERI); + this.setStartingLoyalty(4); + + // Whenever you draw a card, put a loyalty counter on Teferi, Temporal Pilgrim. + this.addAbility(new DrawCardControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance()), false)); + + // 0: Draw a card. + this.addAbility(new LoyaltyAbility(new DrawCardSourceControllerEffect(1), 0)); + + // -2: Create a 2/2 blue Spirit creature token with vigilance and "Whenever you draw a card, put a +1/+1 counter on this creature." + this.addAbility(new LoyaltyAbility(new CreateTokenEffect(new SpiritTeferiToken()), -2)); + + // -12: Target opponent chooses a permanent they control and returns it to its owner's had. Then they shuffle each nonland permanent they control into its owner's library. + Ability ability = new LoyaltyAbility(new TeferiTemporalPilgrimEffect(), -12); + ability.addTarget(new TargetOpponent()); + this.addAbility(ability); + } + + private TeferiTemporalPilgrim(final TeferiTemporalPilgrim card) { + super(card); + } + + @Override + public TeferiTemporalPilgrim copy() { + return new TeferiTemporalPilgrim(this); + } +} + +class TeferiTemporalPilgrimEffect extends OneShotEffect { + + public TeferiTemporalPilgrimEffect() { + super(Outcome.Removal); + this.staticText = "Target opponent chooses a permanent they control and returns it to its owner's had. Then they shuffle each nonland permanent they control into its owner's library."; + } + + private TeferiTemporalPilgrimEffect(final TeferiTemporalPilgrimEffect effect) { + super(effect); + } + + @Override + public TeferiTemporalPilgrimEffect copy() { + return new TeferiTemporalPilgrimEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player opponent = game.getPlayer(source.getFirstTarget()); + if (opponent == null) { + return false; + } + TargetControlledPermanent target = new TargetControlledPermanent(); + target.setNotTarget(true); + opponent.chooseTarget(Outcome.ReturnToHand, target, source, game); + Permanent toHand = game.getPermanent(target.getFirstTarget()); + if (toHand != null) { + opponent.moveCards(toHand, Zone.HAND, source, game); + game.getState().processAction(game); + } + HashSet toLibrary = new HashSet<>(game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_NON_LAND, opponent.getId(), game)); + if (toLibrary.isEmpty()) { + return true; + } + HashSet ownerIds = new HashSet<>(); + for (Permanent permanent : toLibrary) { + ownerIds.add(permanent.getOwnerId()); + } + opponent.moveCards(toLibrary, Zone.LIBRARY, source, game); + for (UUID ownerId : ownerIds) { + Player owner = game.getPlayer(ownerId); + if (owner != null) { + owner.shuffleLibrary(source, game); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/TheBrothersWar.java b/Mage.Sets/src/mage/sets/TheBrothersWar.java index 8018fc6a0d..8c883589f4 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWar.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWar.java @@ -70,6 +70,7 @@ public final class TheBrothersWar extends ExpansionSet { cards.add(new SetCardInfo("Stern Lesson", 64, Rarity.COMMON, mage.cards.s.SternLesson.class)); cards.add(new SetCardInfo("Surge Engine", 81, Rarity.MYTHIC, mage.cards.s.SurgeEngine.class)); cards.add(new SetCardInfo("Swamp", 282, Rarity.LAND, mage.cards.basiclands.Swamp.class, FULL_ART_BFZ_VARIOUS)); + cards.add(new SetCardInfo("Teferi, Temporal Pilgrim", 66, Rarity.MYTHIC, mage.cards.t.TeferiTemporalPilgrim.class)); cards.add(new SetCardInfo("The Mightstone and Weakstone", "238a", Rarity.RARE, mage.cards.t.TheMightstoneAndWeakstone.class)); cards.add(new SetCardInfo("Third Path Savant", 67, Rarity.COMMON, mage.cards.t.ThirdPathSavant.class)); cards.add(new SetCardInfo("Titania, Gaea Incarnate", "256b", Rarity.MYTHIC, mage.cards.t.TitaniaGaeaIncarnate.class)); diff --git a/Mage/src/main/java/mage/game/permanent/token/SpiritTeferiToken.java b/Mage/src/main/java/mage/game/permanent/token/SpiritTeferiToken.java new file mode 100644 index 0000000000..1dd430959c --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/SpiritTeferiToken.java @@ -0,0 +1,36 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.abilities.common.DrawCardControllerTriggeredAbility; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.keyword.VigilanceAbility; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.counters.CounterType; + +/** + * + * @author weirddan455 + */ +public class SpiritTeferiToken extends TokenImpl { + + public SpiritTeferiToken() { + super("Spirit Token", "2/2 blue Spirit creature token with vigilance and \"Whenever you draw a card, put a +1/+1 counter on this creature.\""); + cardType.add(CardType.CREATURE); + subtype.add(SubType.SPIRIT); + color.setBlue(true); + power = new MageInt(2); + toughness = new MageInt(2); + addAbility(VigilanceAbility.getInstance()); + addAbility(new DrawCardControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false)); + } + + private SpiritTeferiToken(final SpiritTeferiToken token) { + super(token); + } + + @Override + public SpiritTeferiToken copy() { + return new SpiritTeferiToken(this); + } +}