|
| 1 | +package org.mage.test.cards.copy; |
| 2 | + |
| 3 | +import mage.abilities.keyword.VigilanceAbility; |
| 4 | +import mage.constants.CardType; |
| 5 | +import mage.constants.PhaseStep; |
| 6 | +import mage.constants.Zone; |
| 7 | +import mage.counters.CounterType; |
| 8 | +import mage.game.Game; |
| 9 | +import mage.game.permanent.Permanent; |
| 10 | +import org.junit.Assert; |
| 11 | +import org.junit.Ignore; |
| 12 | +import org.junit.Test; |
| 13 | +import org.mage.test.serverside.base.CardTestPlayerBase; |
| 14 | + |
| 15 | +/** |
| 16 | + * @author JayDi85 |
| 17 | + */ |
| 18 | +public class SparkDoubleTest extends CardTestPlayerBase { |
| 19 | + |
| 20 | + private Permanent findDoubleSparkPermanent(Game game) { |
| 21 | + for (Permanent perm : game.getBattlefield().getAllActivePermanents()) { |
| 22 | + if (perm.isCopy()) { |
| 23 | + return perm; |
| 24 | + } |
| 25 | + } |
| 26 | + Assert.fail("spark must exist"); |
| 27 | + return null; |
| 28 | + } |
| 29 | + |
| 30 | + @Test |
| 31 | + public void test_CopyCreatureAndGetOneCounter() { |
| 32 | + addCard(Zone.BATTLEFIELD, playerA, "Abbey Griffin", 1); // 2/2, fly, vig |
| 33 | + // |
| 34 | + addCard(Zone.HAND, playerA, "Spark Double"); // {3}{U} |
| 35 | + addCard(Zone.BATTLEFIELD, playerA, "Island", 4); |
| 36 | + |
| 37 | + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Spark Double"); |
| 38 | + setChoice(playerA, "Yes"); |
| 39 | + setChoice(playerA, "Abbey Griffin"); |
| 40 | + |
| 41 | + setStrictChooseMode(true); |
| 42 | + setStopAt(1, PhaseStep.BEGIN_COMBAT); |
| 43 | + execute(); |
| 44 | + assertAllCommandsUsed(); |
| 45 | + |
| 46 | + assertPermanentCount(playerA, "Abbey Griffin", 2); |
| 47 | + |
| 48 | + Permanent spark = findDoubleSparkPermanent(currentGame); |
| 49 | + Assert.assertEquals("must add 1 counter", 1, spark.getCounters(currentGame).getCount(CounterType.P1P1)); |
| 50 | + // |
| 51 | + Assert.assertEquals("must copy p/t", 3, spark.getPower().getValue()); |
| 52 | + Assert.assertEquals("must copy p/t", 3, spark.getToughness().getValue()); |
| 53 | + Assert.assertTrue("must copy ability", spark.getAbilities().contains(VigilanceAbility.getInstance())); |
| 54 | + } |
| 55 | + |
| 56 | + @Test |
| 57 | + public void test_CopyPlaneswalkerWithoutLegendaryWithOneCounter() { |
| 58 | + addCard(Zone.BATTLEFIELD, playerA, "Ajani, the Greathearted", 1); |
| 59 | + // |
| 60 | + addCard(Zone.HAND, playerA, "Spark Double"); // {3}{U} |
| 61 | + addCard(Zone.BATTLEFIELD, playerA, "Island", 4); |
| 62 | + |
| 63 | + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Spark Double"); |
| 64 | + setChoice(playerA, "Yes"); |
| 65 | + setChoice(playerA, "Ajani, the Greathearted"); |
| 66 | + |
| 67 | + setStrictChooseMode(true); |
| 68 | + setStopAt(1, PhaseStep.BEGIN_COMBAT); |
| 69 | + execute(); |
| 70 | + assertAllCommandsUsed(); |
| 71 | + |
| 72 | + assertPermanentCount(playerA, "Ajani, the Greathearted", 2); |
| 73 | + |
| 74 | + Permanent spark = findDoubleSparkPermanent(currentGame); |
| 75 | + Assert.assertEquals("must add 1 loyalty", 5 + 1, spark.getCounters(currentGame).getCount(CounterType.LOYALTY)); |
| 76 | + } |
| 77 | + |
| 78 | + @Test |
| 79 | + public void test_CopyCreatureAndGetDoubleCounter() { |
| 80 | + addCard(Zone.BATTLEFIELD, playerA, "Abbey Griffin", 1); // 2/2, fly, vig |
| 81 | + addCard(Zone.BATTLEFIELD, playerA, "Doubling Season", 1); |
| 82 | + // |
| 83 | + addCard(Zone.HAND, playerA, "Spark Double"); // {3}{U} |
| 84 | + addCard(Zone.BATTLEFIELD, playerA, "Island", 4); |
| 85 | + |
| 86 | + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Spark Double"); |
| 87 | + setChoice(playerA, "Yes"); |
| 88 | + setChoice(playerA, "Abbey Griffin"); |
| 89 | + |
| 90 | + setStrictChooseMode(true); |
| 91 | + setStopAt(1, PhaseStep.BEGIN_COMBAT); |
| 92 | + execute(); |
| 93 | + assertAllCommandsUsed(); |
| 94 | + |
| 95 | + assertPermanentCount(playerA, "Abbey Griffin", 2); |
| 96 | + |
| 97 | + Permanent spark = findDoubleSparkPermanent(currentGame); |
| 98 | + Assert.assertEquals("must add 2 counter", 2, spark.getCounters(currentGame).getCount(CounterType.P1P1)); |
| 99 | + } |
| 100 | + |
| 101 | + @Test |
| 102 | + public void test_CopyPlaneswalkerWithCreatureActivated() { |
| 103 | + addCard(Zone.BATTLEFIELD, playerA, "Gideon, Ally of Zendikar", 1); |
| 104 | + // |
| 105 | + addCard(Zone.HAND, playerA, "Spark Double"); // {3}{U} |
| 106 | + addCard(Zone.BATTLEFIELD, playerA, "Island", 4); |
| 107 | + |
| 108 | + // activate creature ability |
| 109 | + checkType("planeswalker not creature", 1, PhaseStep.UPKEEP, playerA, "Gideon, Ally of Zendikar", CardType.CREATURE, false); |
| 110 | + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1:"); |
| 111 | + checkType("planeswalker is creature", 1, PhaseStep.BEGIN_COMBAT, playerA, "Gideon, Ally of Zendikar", CardType.CREATURE, true); |
| 112 | + |
| 113 | + // copy |
| 114 | + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Spark Double"); |
| 115 | + setChoice(playerA, "Yes"); |
| 116 | + setChoice(playerA, "Gideon, Ally of Zendikar"); |
| 117 | + |
| 118 | + setStrictChooseMode(true); |
| 119 | + setStopAt(1, PhaseStep.END_TURN); |
| 120 | + execute(); |
| 121 | + assertAllCommandsUsed(); |
| 122 | + |
| 123 | + assertPermanentCount(playerA, "Gideon, Ally of Zendikar", 2); |
| 124 | + |
| 125 | + Permanent spark = findDoubleSparkPermanent(currentGame); |
| 126 | + Assert.assertEquals("must add 1 loyalty", 4 + 1, spark.getCounters(currentGame).getCount(CounterType.LOYALTY)); |
| 127 | + Assert.assertEquals("must not add creature counter", 0, spark.getCounters(currentGame).getCount(CounterType.P1P1)); |
| 128 | + } |
| 129 | + |
| 130 | + @Test |
| 131 | + @Ignore // TODO: enabled after Blood Moon type changing effect will be fixed |
| 132 | + public void test_CopyPlaneswalkerWithCreatureTypeChangedEffect() { |
| 133 | + addCard(Zone.BATTLEFIELD, playerA, "Gideon Blackblade", 1); |
| 134 | + // |
| 135 | + addCard(Zone.HAND, playerA, "Spark Double"); // {3}{U} |
| 136 | + addCard(Zone.BATTLEFIELD, playerA, "Island", 4); |
| 137 | + |
| 138 | + // Gideon Blackblade is creature on your turn (by type changing effect) |
| 139 | + checkType("planeswalker is creature", 1, PhaseStep.UPKEEP, playerA, "Gideon Blackblade", CardType.CREATURE, true); |
| 140 | + |
| 141 | + // copy |
| 142 | + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Spark Double"); |
| 143 | + setChoice(playerA, "Yes"); |
| 144 | + setChoice(playerA, "Gideon Blackblade"); |
| 145 | + |
| 146 | + setStrictChooseMode(true); |
| 147 | + setStopAt(1, PhaseStep.END_COMBAT); |
| 148 | + execute(); |
| 149 | + assertAllCommandsUsed(); |
| 150 | + |
| 151 | + assertPermanentCount(playerA, "Gideon Blackblade", 2); |
| 152 | + |
| 153 | + Permanent spark = findDoubleSparkPermanent(currentGame); |
| 154 | + Assert.assertEquals("must add 1 loyalty", 4 + 1, spark.getCounters(currentGame).getCount(CounterType.LOYALTY)); |
| 155 | + Assert.assertEquals("must add 1 creature counter", 1, spark.getCounters(currentGame).getCount(CounterType.P1P1)); |
| 156 | + } |
| 157 | +} |
0 commit comments