diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhantasmalImageTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhantasmalImageTest.java index 781df7d512..dd243c2b00 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhantasmalImageTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhantasmalImageTest.java @@ -36,7 +36,7 @@ public class PhantasmalImageTest extends CardTestPlayerBase { * Tests that copy effect will copy EntersBattlefieldTriggeredAbility and it will be applied. */ @Test - public void testCopiedEntersBattlefieldTriggeredAbility() { + public void testCopyEntersBattlefieldTriggeredAbility() { addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 2); addCard(Constants.Zone.HAND, playerA, "Phantasmal Image"); addCard(Constants.Zone.BATTLEFIELD, playerB, "Howling Banshee"); @@ -166,4 +166,50 @@ public class PhantasmalImageTest extends CardTestPlayerBase { assertLife(playerB, 18); } + + /** + * Tests that copy effect will copy AsEntersBattlefieldAbility and will choose another color. + * As there is no permanent of the second color, copy of Lurebound Scarecrow will be sacrificed. + */ + @Test + public void testCopyAsEntersBattlefieldAbility() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 5); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Llanowar Elves"); + addCard(Constants.Zone.HAND, playerA, "Phantasmal Image"); + addCard(Constants.Zone.HAND, playerA, "Lurebound Scarecrow"); + + setChoice(playerA, "Green"); + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lurebound Scarecrow"); + setChoice(playerA, "Red"); + castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Phantasmal Image"); + + setStopAt(1, Constants.PhaseStep.END_TURN); + execute(); + + assertPermanentCount(playerA, "Lurebound Scarecrow", 1); + } + + /** + * Tests that copy effect will copy AsEntersBattlefieldAbility and will choose another color. + * Both Lurebound Scarecrow cards should stay on battlefield. + */ + @Test + public void testCopyAsEntersBattlefieldAbility2() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 5); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Llanowar Elves"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Raging Goblin"); + addCard(Constants.Zone.HAND, playerA, "Phantasmal Image"); + addCard(Constants.Zone.HAND, playerA, "Lurebound Scarecrow"); + + setChoice(playerA, "Green"); + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lurebound Scarecrow"); + setChoice(playerA, "Red"); + castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Phantasmal Image"); + + setStopAt(1, Constants.PhaseStep.END_TURN); + execute(); + + assertPermanentCount(playerA, "Lurebound Scarecrow", 2); + } + } diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index d9d2eaf01e..19c3a4b967 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -38,6 +38,7 @@ import mage.counters.Counter; import mage.filter.FilterPermanent; import mage.filter.common.FilterAttackingCreature; import mage.filter.common.FilterCreatureForCombat; +import mage.filter.predicate.mageobject.NamePredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.player.ai.ComputerPlayer; @@ -51,7 +52,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; -import mage.filter.predicate.mageobject.NamePredicate; /** * @@ -170,8 +170,8 @@ public class TestPlayer extends ComputerPlayer { @Override public boolean choose(Constants.Outcome outcome, Choice choice, Game game) { if (!choices.isEmpty()) { - for (String choose1: choice.getChoices()) { - for (String choose2: choices) { + for (String choose2: choices) { + for (String choose1: choice.getChoices()) { if (choose1.equals(choose2)) { choice.setChoice(choose2); choices.remove(choose2);