From 7160a907c9740a50050eb96cef666a02d42b5216 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Mon, 17 Apr 2023 18:09:27 -0400 Subject: [PATCH] [MOM] Implement Invasion of New Phyrexia / Teferi Akosa of Zhalfir --- .../mage/cards/i/InvasionOfNewPhyrexia.java | 42 +++++++ .../mage/cards/t/TeferiAkosaOfZhalfir.java | 114 ++++++++++++++++++ .../src/mage/sets/MarchOfTheMachine.java | 2 + .../emblems/TeferiAkosaOfZhalfirEmblem.java | 37 ++++++ Utils/mtg-cards-data.txt | 2 +- 5 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/i/InvasionOfNewPhyrexia.java create mode 100644 Mage.Sets/src/mage/cards/t/TeferiAkosaOfZhalfir.java create mode 100644 Mage/src/main/java/mage/game/command/emblems/TeferiAkosaOfZhalfirEmblem.java diff --git a/Mage.Sets/src/mage/cards/i/InvasionOfNewPhyrexia.java b/Mage.Sets/src/mage/cards/i/InvasionOfNewPhyrexia.java new file mode 100644 index 0000000000..fb3ed001e2 --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/InvasionOfNewPhyrexia.java @@ -0,0 +1,42 @@ +package mage.cards.i; + +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SiegeAbility; +import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.game.permanent.token.KnightWhiteBlueToken; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class InvasionOfNewPhyrexia extends CardImpl { + + public InvasionOfNewPhyrexia(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.BATTLE}, "{X}{W}{U}"); + + this.subtype.add(SubType.SIEGE); + this.setStartingDefense(6); + this.secondSideCardClazz = mage.cards.t.TeferiAkosaOfZhalfir.class; + + // (As a Siege enters, choose an opponent to protect it. You and others can attack it. When it's defeated, exile it, then cast it transformed.) + this.addAbility(new SiegeAbility()); + + // When Invasion of New Phyrexia enters the battlefield, create X 2/2 white and blue Knight creature tokens with vigilance. + this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new KnightWhiteBlueToken(), ManacostVariableValue.ETB))); + } + + private InvasionOfNewPhyrexia(final InvasionOfNewPhyrexia card) { + super(card); + } + + @Override + public InvasionOfNewPhyrexia copy() { + return new InvasionOfNewPhyrexia(this); + } +} diff --git a/Mage.Sets/src/mage/cards/t/TeferiAkosaOfZhalfir.java b/Mage.Sets/src/mage/cards/t/TeferiAkosaOfZhalfir.java new file mode 100644 index 0000000000..173057a5e4 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TeferiAkosaOfZhalfir.java @@ -0,0 +1,114 @@ +package mage.cards.t; + +import mage.abilities.Ability; +import mage.abilities.LoyaltyAbility; +import mage.abilities.common.delayed.ReflexiveTriggeredAbility; +import mage.abilities.costs.common.DiscardTargetCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DoIfCostPaid; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.GetEmblemEffect; +import mage.abilities.effects.common.ShuffleIntoLibraryTargetEffect; +import mage.abilities.effects.common.discard.DiscardControllerEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.common.FilterNonlandPermanent; +import mage.filter.predicate.mageobject.ManaValuePredicate; +import mage.game.Game; +import mage.game.command.emblems.TeferiAkosaOfZhalfirEmblem; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetCardInHand; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TeferiAkosaOfZhalfir extends CardImpl { + + public TeferiAkosaOfZhalfir(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, ""); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.TEFERI); + this.setStartingLoyalty(4); + this.color.setWhite(true); + this.color.setBlue(true); + this.nightCard = true; + + // +1: Draw two cards. Then discard two cards unless you discard a creature card. + Ability ability = new LoyaltyAbility(new DrawCardSourceControllerEffect(2), 1); + ability.addEffect(new DoIfCostPaid( + null, new DiscardControllerEffect(2), + new DiscardTargetCost(new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE_A)) + .setText("discard a creature card instead of discarding two cards") + ).setText("Then discard two cards unless you discard an artifact card")); + + // -2: You get an emblem with "Knights you control get +1/+0 and have ward {1}." + this.addAbility(new LoyaltyAbility(new GetEmblemEffect(new TeferiAkosaOfZhalfirEmblem()), -2)); + + // -3: Tap any number of untapped creatures you control. When you do, shuffle target nonland permanent an opponent controls with mana value X or less into its owner's library, where X is the number of creatures tapped this way. + this.addAbility(new LoyaltyAbility(new TeferiAkosaOfZhalfirEffect(), -3)); + } + + private TeferiAkosaOfZhalfir(final TeferiAkosaOfZhalfir card) { + super(card); + } + + @Override + public TeferiAkosaOfZhalfir copy() { + return new TeferiAkosaOfZhalfir(this); + } +} + +class TeferiAkosaOfZhalfirEffect extends OneShotEffect { + + TeferiAkosaOfZhalfirEffect() { + super(Outcome.Benefit); + staticText = "tap any number of untapped creatures you control. When you do, " + + "shuffle target nonland permanent an opponent controls with mana value X or less " + + "into its owner's library, where X is the number of creatures tapped this way"; + } + + private TeferiAkosaOfZhalfirEffect(final TeferiAkosaOfZhalfirEffect effect) { + super(effect); + } + + @Override + public TeferiAkosaOfZhalfirEffect copy() { + return new TeferiAkosaOfZhalfirEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + TargetPermanent target = new TargetPermanent( + 0, Integer.MAX_VALUE, StaticFilters.FILTER_CONTROLLED_UNTAPPED_CREATURES, true + ); + player.choose(Outcome.Tap, target, source, game); + int count = 0; + for (UUID targetId : target.getTargets()) { + Permanent permanent = game.getPermanent(targetId); + if (permanent != null && permanent.tap(source, game)) { + count++; + } + } + FilterPermanent filter = new FilterNonlandPermanent("nonland permanent an opponent controls with mana value " + count + " or less"); + filter.add(TargetController.OPPONENT.getControllerPredicate()); + filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, count + 1)); + ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new ShuffleIntoLibraryTargetEffect() + .setText("shuffle target nonland permanent an opponent controls with mana value X or less " + + "into its owner's library, where X is the number of creatures tapped this way"), false); + ability.addTarget(new TargetPermanent(filter)); + game.fireReflexiveTriggeredAbility(ability, source); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index d8e4bffe6b..cded25b294 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -181,6 +181,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Invasion of Moag", 237, Rarity.UNCOMMON, mage.cards.i.InvasionOfMoag.class)); cards.add(new SetCardInfo("Invasion of Muraganda", 192, Rarity.UNCOMMON, mage.cards.i.InvasionOfMuraganda.class)); cards.add(new SetCardInfo("Invasion of New Capenna", 238, Rarity.UNCOMMON, mage.cards.i.InvasionOfNewCapenna.class)); + cards.add(new SetCardInfo("Invasion of New Phyrexia", 239, Rarity.MYTHIC, mage.cards.i.InvasionOfNewPhyrexia.class)); cards.add(new SetCardInfo("Invasion of Pyrulea", 240, Rarity.UNCOMMON, mage.cards.i.InvasionOfPyrulea.class)); cards.add(new SetCardInfo("Invasion of Ravnica", 1, Rarity.MYTHIC, mage.cards.i.InvasionOfRavnica.class)); cards.add(new SetCardInfo("Invasion of Regatha", 148, Rarity.UNCOMMON, mage.cards.i.InvasionOfRegatha.class)); @@ -320,6 +321,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Tandem Takedown", 208, Rarity.UNCOMMON, mage.cards.t.TandemTakedown.class)); cards.add(new SetCardInfo("Tangled Skyline", 209, Rarity.UNCOMMON, mage.cards.t.TangledSkyline.class)); cards.add(new SetCardInfo("Tarkir Duneshaper", 43, Rarity.COMMON, mage.cards.t.TarkirDuneshaper.class)); + cards.add(new SetCardInfo("Teferi Akosa of Zhalfir", 239, Rarity.MYTHIC, mage.cards.t.TeferiAkosaOfZhalfir.class)); cards.add(new SetCardInfo("Temporal Cleansing", 80, Rarity.COMMON, mage.cards.t.TemporalCleansing.class)); cards.add(new SetCardInfo("Tenured Oilcaster", 126, Rarity.COMMON, mage.cards.t.TenuredOilcaster.class)); cards.add(new SetCardInfo("Terror of Towashi", 331, Rarity.RARE, mage.cards.t.TerrorOfTowashi.class)); diff --git a/Mage/src/main/java/mage/game/command/emblems/TeferiAkosaOfZhalfirEmblem.java b/Mage/src/main/java/mage/game/command/emblems/TeferiAkosaOfZhalfirEmblem.java new file mode 100644 index 0000000000..9eb05517b5 --- /dev/null +++ b/Mage/src/main/java/mage/game/command/emblems/TeferiAkosaOfZhalfirEmblem.java @@ -0,0 +1,37 @@ +package mage.game.command.emblems; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.common.continuous.BoostControlledEffect; +import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; +import mage.abilities.keyword.WardAbility; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.game.command.Emblem; + +/** + * @author TheElk801 + */ +public final class TeferiAkosaOfZhalfirEmblem extends Emblem { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(SubType.KNIGHT, "Knights"); + private static final FilterPermanent filter2 = new FilterPermanent(SubType.KNIGHT, ""); + + // -2: You get an emblem with "Knights you control get +1/+0 and have ward {1}." + public TeferiAkosaOfZhalfirEmblem() { + this.setName("Emblem Teferi"); + this.setExpansionSetCodeForImage("MOM"); + Ability ability = new SimpleStaticAbility( + Zone.COMMAND, new BoostControlledEffect(1, 0, Duration.WhileOnBattlefield, filter) + ); + ability.addEffect(new GainAbilityControlledEffect( + new WardAbility(new GenericManaCost(1), false), + Duration.WhileOnBattlefield, filter2 + ).setText("and have ward {1}")); + this.getAbilities().add(ability); + } +} diff --git a/Utils/mtg-cards-data.txt b/Utils/mtg-cards-data.txt index 320c6305c4..04977ec4fe 100644 --- a/Utils/mtg-cards-data.txt +++ b/Utils/mtg-cards-data.txt @@ -48364,7 +48364,7 @@ Bloomwielder Dryads|March of the Machine|237|U||Creature - Dryad|3|3|Ward {2}$At Invasion of New Capenna|March of the Machine|238|U|{W}{B}|Battle - Siege|4|(As a Siege enters, choose an opponent to protect it. You and others can attack it. When it's defeated, exile it, then cast it transformed.)$When Invasion of New Capenna enters the battlefield, you may sacrifice an artifact or creature. When you do, exile target artifact or creature an opponent controls.| Holy Frazzle-Cannon|March of the Machine|238|U||Artifact - Equipment|||Whenever equipped creature attacks, put a +1/+1 counter on that creature and each other creature you control that shares a creature type with it.$Equip {1}| Invasion of New Phyrexia|March of the Machine|239|M|{X}{W}{U}|Battle - Siege|6|(As a Siege enters, choose an opponent to protect it. You and others can attack it. When it's defeated, exile it, then cast it transformed.)$When Invasion of New Phyrexia enters the battlefield, create X 2/2 white and blue Knight creature tokens with vigilance.| -Teferi Akosa of Zhalfir|March of the Machine|239|M||Legendary Planeswalker - Teferi|4|+1: Draw two cards. Then discard two cards unless you discard a creature card.$-2: You get an emblem with "Knights you control get +1/+0 and have ward {1}."$-3: Tap X creatures you control. When you do, shuffle target nonland permanent an opponent controls with mana value X or less into its owner's library.| +Teferi Akosa of Zhalfir|March of the Machine|239|M||Legendary Planeswalker - Teferi|4|+1: Draw two cards. Then discard two cards unless you discard a creature card.$-2: You get an emblem with "Knights you control get +1/+0 and have ward {1}."$-3: Tap any number of untapped creatures you control. When you do, shuffle target nonland permanent an opponent controls with mana value X or less into its owner's library, where X is the number of creatures tapped this way.| Invasion of Pyrulea|March of the Machine|240|U|{G}{U}|Battle - Siege|4|(As a Siege enters, choose an opponent to protect it. You and others can attack it. When it's defeated, exile it, then cast it transformed.)$When Invasion of Pyrulea enters the battlefield, scry 3, then reveal the top card of your library. If it's a land or double-faced card, draw a card.| Gargantuan Slabhorn|March of the Machine|240|U||Creature - Beast|4|4|Trample, ward {2}$Other transformed permanents you control have trample and ward {2}.| Invasion of Tolvada|March of the Machine|241|R|{3}{W}{B}|Battle - Siege|5|(As a Siege enters, choose an opponent to protect it. You and others can attack it. When it's defeated, exile it, then cast it transformed.)$When Invasion of Tolvada enters the battlefield, return target nonbattle permanent card from your graveyard to the battlefield.|