From c53d3b392a0565ba46d2b71c2f1661ea001b2ef9 Mon Sep 17 00:00:00 2001 From: Simown Date: Thu, 18 May 2017 21:17:16 +0100 Subject: [PATCH] Fixed Spirit Mirror and added tests. Fixes #3391 --- Mage.Sets/src/mage/cards/s/SpiritMirror.java | 4 +- .../test/cards/single/SpiritMirrorTest.java | 112 ++++++++++++++++++ 2 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/SpiritMirrorTest.java diff --git a/Mage.Sets/src/mage/cards/s/SpiritMirror.java b/Mage.Sets/src/mage/cards/s/SpiritMirror.java index 9b34e4e8b5..017f0565a8 100644 --- a/Mage.Sets/src/mage/cards/s/SpiritMirror.java +++ b/Mage.Sets/src/mage/cards/s/SpiritMirror.java @@ -44,6 +44,7 @@ import mage.constants.TargetController; import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.filter.predicate.mageobject.NamePredicate; +import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.permanent.TokenPredicate; import mage.game.permanent.token.ReflectionToken; import mage.target.TargetPermanent; @@ -56,8 +57,7 @@ public class SpiritMirror extends CardImpl { private static final FilterPermanent filter = new FilterPermanent("Reflection"); static { - filter.add(new NamePredicate("Reflection")); - filter.add(new TokenPredicate()); + filter.add(new SubtypePredicate("Reflection")); } public SpiritMirror(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/SpiritMirrorTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/SpiritMirrorTest.java new file mode 100644 index 0000000000..564786382c --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/SpiritMirrorTest.java @@ -0,0 +1,112 @@ +package org.mage.test.cards.single; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.game.permanent.Permanent; +import org.junit.Assert; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author Simown + */ + +/* + * Spirit Mirror - Enchantment {2}}{W}{W} + * At the beginning of your upkeep, if there are no Reflection tokens on the battlefield, create a 2/2 white Reflection creature token. + * {0}: Destroy target Reflection. +*/ +public class SpiritMirrorTest extends CardTestPlayerBase { + + @Test + public void createsTokenBeginningOfUpkeepTest() { + + addCard(Zone.BATTLEFIELD, playerA, "Spirit Mirror"); + setStopAt(3, PhaseStep.PRECOMBAT_MAIN); + + execute(); + + assertPermanentCount(playerA, "Reflection", 1); + Permanent reflection = getPermanent("Reflection"); + Assert.assertTrue(reflection.hasSubtype("Reflection", currentGame)); + } + + + @Test + public void destroyCreatedTokenTest() { + addCard(Zone.BATTLEFIELD, playerA, "Spirit Mirror"); + + // Destroy playerAs own reflection token + activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{0}: Destroy target Reflection", "Reflection"); + + setStopAt(3, PhaseStep.END_TURN); + execute(); + + assertPermanentCount(playerA, "Reflection", 0); + } + + @Test + public void onlyCreatesSingleTokenTest() { + + addCard(Zone.BATTLEFIELD, playerA, "Spirit Mirror"); + // Allow lots of turns without doing anything + playerA.setMaxCallsWithoutAction(1000); + playerB.setMaxCallsWithoutAction(1000); + + // Run for lots of turns + setStopAt(20, PhaseStep.PRECOMBAT_MAIN); + execute(); + + // Only one token created + assertPermanentCount(playerA, "Reflection", 1); + Permanent reflection = getPermanent("Reflection"); + Assert.assertTrue(reflection.hasSubtype("Reflection", currentGame)); + } + + + @Test + public void destroyChangelingTest() { + // Changeling - all creature types + addCard(Zone.BATTLEFIELD, playerA, "Chameleon Colossus"); + addCard(Zone.BATTLEFIELD, playerB, "Spirit Mirror"); + + activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "{0}: Destroy target Reflection", "Chameleon Colossus"); + + setStopAt(2, PhaseStep.BEGIN_COMBAT); + execute(); + + // Was a reflection so destroyed and put in the graveyard + assertPermanentCount(playerA, "Chameleon Colossus", 0); + assertGraveyardCount(playerA, "Chameleon Colossus", 1); + } + + @Test + public void interactionWithUnnaturalSelectionTest() { + + addCard(Zone.BATTLEFIELD, playerA, "Spirit Mirror"); + addCard(Zone.BATTLEFIELD, playerA, "Unnatural Selection"); + // Mana for Unnatural Selection activation + addCard(Zone.BATTLEFIELD, playerA, "Plains", 4); + + // Add some creatures that are not Reflections + String[] creatures = new String[]{"Memnite", "Chasm Skulker", "Fabled Hero", "Bronze Sable"}; + for (String creature : creatures) { + addCard(Zone.BATTLEFIELD, playerB, creature); + // Make them all reflections with Unnatural Selection + activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}: Choose a creature", creature); + setChoice(playerA, "Reflection"); + // Destroy them all with Spirit Mirror's ability + activateAbility(2, PhaseStep.POSTCOMBAT_MAIN, playerA, "{0}: Destroy target Reflection", creature); + } + + setStopAt(4, PhaseStep.UPKEEP); + execute(); + + // All creatures destroyed with Spirit Mirror's ability + for (String creature : creatures) { + assertPermanentCount(playerB, creature, 0); + assertGraveyardCount(playerB, creature, 1); + } + + } +}