From 58364784fb0276aa65c2712012104e2a23e560eb Mon Sep 17 00:00:00 2001 From: PurpleCrowbar <26198472+PurpleCrowbar@users.noreply.github.com> Date: Mon, 5 Sep 2022 03:27:51 +0100 Subject: [PATCH] [DMU] Implement Zur, Eternal Schemer (#9406) --- .../src/mage/cards/z/ZurEternalSchemer.java | 128 ++++++++++++++++++ Mage.Sets/src/mage/sets/DominariaUnited.java | 2 + .../cards/single/uds/OpalescenceTest.java | 67 +++++++++ .../{usd => uds}/UrzasIncubatorTest.java | 2 +- 4 files changed, 198 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/z/ZurEternalSchemer.java create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/uds/OpalescenceTest.java rename Mage.Tests/src/test/java/org/mage/test/cards/single/{usd => uds}/UrzasIncubatorTest.java (98%) diff --git a/Mage.Sets/src/mage/cards/z/ZurEternalSchemer.java b/Mage.Sets/src/mage/cards/z/ZurEternalSchemer.java new file mode 100644 index 0000000000..7620606aae --- /dev/null +++ b/Mage.Sets/src/mage/cards/z/ZurEternalSchemer.java @@ -0,0 +1,128 @@ +package mage.cards.z; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.CompoundAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; +import mage.abilities.keyword.DeathtouchAbility; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.HexproofAbility; +import mage.abilities.keyword.LifelinkAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.common.FilterEnchantmentPermanent; +import mage.filter.predicate.Predicates; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author PurpleCrowbar + */ +public final class ZurEternalSchemer extends CardImpl { + + private static final FilterCreaturePermanent filter + = new FilterCreaturePermanent("Enchantment creatures"); + + private static final FilterEnchantmentPermanent filter2 + = new FilterEnchantmentPermanent("non-Aura enchantment you control"); + + static { + filter.add(CardType.ENCHANTMENT.getPredicate()); + filter2.add(Predicates.not(SubType.AURA.getPredicate())); + filter2.add(TargetController.YOU.getControllerPredicate()); + } + + public ZurEternalSchemer(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}{U}{B}"); + + addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.WIZARD); + this.power = new MageInt(1); + this.toughness = new MageInt(4); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Enchantment creatures you control have deathtouch, lifelink, and hexproof. + CompoundAbility compoundAbilities = new CompoundAbility(DeathtouchAbility.getInstance(), LifelinkAbility.getInstance(), HexproofAbility.getInstance()); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(compoundAbilities, Duration.WhileOnBattlefield, filter))); + + // {1}{W}: Target non-Aura enchantment you control becomes a creature in addition to its other types and has base power and toughness each equal to its mana value. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ZurEternalSchemerEffect(), new ManaCostsImpl<>("{1}{W}")); + ability.addTarget(new TargetPermanent(filter2)); + this.addAbility(ability); + } + + private ZurEternalSchemer(final ZurEternalSchemer card) { + super (card); + } + + @Override + public ZurEternalSchemer copy() { + return new ZurEternalSchemer(this); + } +} + +class ZurEternalSchemerEffect extends ContinuousEffectImpl { + + public ZurEternalSchemerEffect() { + super(Duration.EndOfGame, Outcome.BecomeCreature); + staticText = "Target non-Aura enchantment you control becomes a creature in addition to its other types " + + "and has base power and base toughness each equal to its mana value."; + } + + public ZurEternalSchemerEffect(final ZurEternalSchemerEffect effect) { + super(effect); + } + + @Override + public ZurEternalSchemerEffect copy() { + return new ZurEternalSchemerEffect(this); + } + + @Override + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + Permanent enchantment = game.getPermanent(this.getTargetPointer().getFirst(game, source)); + if (enchantment == null) { + return false; + } + switch (layer) { + case TypeChangingEffects_4: + if (sublayer == SubLayer.NA) { + if (!enchantment.isCreature(game)) { + enchantment.addCardType(game, CardType.CREATURE); + } + } + break; + + case PTChangingEffects_7: + if (sublayer == SubLayer.SetPT_7b) { + int cmc = enchantment.getManaValue(); + enchantment.getPower().setModifiedBaseValue(cmc); + enchantment.getToughness().setModifiedBaseValue(cmc); + } + } + return true; + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean hasLayer(Layer layer) { + return layer == Layer.PTChangingEffects_7 + || layer == Layer.TypeChangingEffects_4; + } +} diff --git a/Mage.Sets/src/mage/sets/DominariaUnited.java b/Mage.Sets/src/mage/sets/DominariaUnited.java index db156fb6a3..ca80262c3e 100644 --- a/Mage.Sets/src/mage/sets/DominariaUnited.java +++ b/Mage.Sets/src/mage/sets/DominariaUnited.java @@ -269,6 +269,8 @@ public final class DominariaUnited extends ExpansionSet { cards.add(new SetCardInfo("Yavimaya Steelcrusher", 152, Rarity.COMMON, mage.cards.y.YavimayaSteelcrusher.class)); cards.add(new SetCardInfo("Yotia Declares War", 153, Rarity.UNCOMMON, mage.cards.y.YotiaDeclaresWar.class)); cards.add(new SetCardInfo("Zar Ojanen, Scion of Efrava", 227, Rarity.UNCOMMON, mage.cards.z.ZarOjanenScionOfEfrava.class)); + cards.add(new SetCardInfo("Zur, Eternal Schemer", 228, Rarity.MYTHIC, mage.cards.z.ZurEternalSchemer.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Zur, Eternal Schemer", 327, Rarity.MYTHIC, mage.cards.z.ZurEternalSchemer.class, NON_FULL_USE_VARIOUS)); } // @Override diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/uds/OpalescenceTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/uds/OpalescenceTest.java new file mode 100644 index 0000000000..5f095ecb71 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/uds/OpalescenceTest.java @@ -0,0 +1,67 @@ +package org.mage.test.cards.single.uds; + +import mage.constants.CardType; +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author PurpleCrowbar + */ +public class OpalescenceTest extends CardTestPlayerBase { + + /** + * Test that Opalescence is applying its effect + */ + @Test + public void testOpalescenceApplies() { + // 1 CMC 1/2 enchantment creature + addCard(Zone.BATTLEFIELD, playerA, "Dockside Chef", 1); + // 1 CMC non-creature enchantment + addCard(Zone.BATTLEFIELD, playerA, "Alms", 1); + // Each other non-Aura enchantment is a creature in addition to its other types and has base power and base toughness each equal to its mana value. + addCard(Zone.BATTLEFIELD, playerA, "Opalescence", 1); + + // 2 CMC non-creature enchantment + addCard(Zone.BATTLEFIELD, playerB, "Amok", 1); + + setStopAt(1, PhaseStep.PRECOMBAT_MAIN); + execute(); + + assertPowerToughness(playerA, "Dockside Chef", 1, 1); + assertType("Alms", CardType.CREATURE, true); + assertPowerToughness(playerA, "Alms", 1, 1); + assertType("Amok", CardType.CREATURE, true); + assertPowerToughness(playerB, "Amok", 2, 2); + } + + /** + * Test that Opalescence's effect ends when it leaves the battlefield + */ + @Test + public void testOpalescenceEffectEnds() { + // 1 CMC 1/2 enchantment creature + addCard(Zone.BATTLEFIELD, playerA, "Dockside Chef", 1); + // 1 CMC non-creature enchantment + addCard(Zone.BATTLEFIELD, playerA, "Alms", 1); + // Each other non-Aura enchantment is a creature in addition to its other types and has base power and base toughness each equal to its mana value. + addCard(Zone.HAND, playerA, "Opalescence", 1); + addCard(Zone.HAND, playerA, "Vindicate", 1); + addCard(Zone.BATTLEFIELD, playerA, "Scrubland", 7); + + // 2 CMC non-creature enchantment + addCard(Zone.BATTLEFIELD, playerB, "Amok", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Opalescence"); + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Vindicate", "Opalescence"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertType("Dockside Chef", CardType.CREATURE, true); + assertPowerToughness(playerA, "Dockside Chef", 1, 2); + assertType("Alms", CardType.CREATURE, false); + assertType("Amok", CardType.CREATURE, false); + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/usd/UrzasIncubatorTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/uds/UrzasIncubatorTest.java similarity index 98% rename from Mage.Tests/src/test/java/org/mage/test/cards/single/usd/UrzasIncubatorTest.java rename to Mage.Tests/src/test/java/org/mage/test/cards/single/uds/UrzasIncubatorTest.java index 296d60fa04..6b54f845ff 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/usd/UrzasIncubatorTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/uds/UrzasIncubatorTest.java @@ -1,5 +1,5 @@ -package org.mage.test.cards.single.usd; +package org.mage.test.cards.single.uds; import mage.constants.PhaseStep; import mage.constants.Zone;