From 0022dc8c376cb2880d8135649d36b9bad6689c86 Mon Sep 17 00:00:00 2001 From: Alex Vasile <48962821+Alex-Vasile@users.noreply.github.com> Date: Fri, 13 May 2022 14:40:54 -0600 Subject: [PATCH] Fixing several tests. Working towards enabling assertAllCommandsUsed() inside execute(). --- .../abilities/activated/EquipAbilityTest.java | 9 +- .../cards/abilities/keywords/ExertTest.java | 90 ++++++++++++------- .../abilities/keywords/HexproofTest.java | 2 +- .../oneshot/counterspell/ResetTest.java | 54 +++-------- .../cards/control/PutIntoPlayEffectsTest.java | 32 +++---- ...CastFromHandWithoutPayingManaCostTest.java | 35 ++++---- .../cards/cost/custom/SerraAvengerTest.java | 17 ++-- .../single/akh/BontuTheGlorifiedTest.java | 12 +-- .../single/c19/ChainerNightmareAdeptTest.java | 7 +- .../cards/single/dka/GravecrawlerTest.java | 25 +++--- .../single/dom/SimpleDominariaCards.java | 22 +++-- .../cards/single/lrw/MulldrifterTest.java | 1 - .../abilities/ProtectionFromTypeTest.java | 2 +- 13 files changed, 161 insertions(+), 147 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/EquipAbilityTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/EquipAbilityTest.java index 65d4413512..52ddb77ae1 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/EquipAbilityTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/EquipAbilityTest.java @@ -32,7 +32,7 @@ public class EquipAbilityTest extends CardTestPlayerBase { } /** - * Tests equipping creature with shroud + * Tests not being able to equip creature with shroud. */ @Test public void testEquipShroud() { @@ -40,8 +40,7 @@ public class EquipAbilityTest extends CardTestPlayerBase { addCard(Zone.BATTLEFIELD, playerA, "Simic Sky Swallower"); addCard(Zone.BATTLEFIELD, playerA, "Plains"); - activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip", "Simic Sky Swallower"); - + checkPlayableAbility("during", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip", false); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); @@ -51,7 +50,7 @@ public class EquipAbilityTest extends CardTestPlayerBase { } /** - * Tests equipping opponent's creature + * Tests not being able to equip opponent's creature. */ @Test public void testEquipOpponentsCreature() { @@ -59,7 +58,7 @@ public class EquipAbilityTest extends CardTestPlayerBase { addCard(Zone.BATTLEFIELD, playerB, "Llanowar Elves"); addCard(Zone.BATTLEFIELD, playerA, "Plains"); - activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip", "Llanowar Elves"); + checkPlayableAbility("during", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip", false); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ExertTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ExertTest.java index 2a225f67d7..21ebcdd46a 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ExertTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ExertTest.java @@ -203,8 +203,9 @@ public class ExertTest extends CardTestPlayerBase { } /* - "If you gain control of another player's creature until end of turn and exert it, it will untap during that player's untap step." - See issue #3183 + * "If you gain control of another player's creature until end of turn and exert it, + * it will untap during that player's untap step." + * See issue #3183 */ @Test public void stolenExertCreatureShouldUntapDuringOwnersUntapStep() { @@ -239,23 +240,32 @@ public class ExertTest extends CardTestPlayerBase { @Test public void combatCelebrantExertedCannotExertAgainDuringNextCombatPhase() { /* - Combat Celebrant 2R - Creature - Human Warrior 4/1 - If Combat Celebrant hasn't been exerted this turn, you may exert it as it attacks. When you do, untap all other creatures you control and after this phase, there is an additional combat phase. - */ + * Combat Celebrant 2R + * Creature - Human Warrior 4/1 + * If Combat Celebrant hasn't been exerted this turn, you may exert it as it attacks. + * When you do, untap all other creatures you control and after this phase, there is an additional combat phase. + */ String cCelebrant = "Combat Celebrant"; String memnite = "Memnite"; // {0} 1/1 addCard(Zone.BATTLEFIELD, playerA, cCelebrant); addCard(Zone.BATTLEFIELD, playerA, memnite); + setStrictChooseMode(true); + + // First combat phase attack(1, playerA, cCelebrant); attack(1, playerA, memnite); setChoice(playerA, true); // exert for extra turn - attack(1, playerA, cCelebrant); - attack(1, playerA, memnite); - setChoice(playerA, true); // try to exert again - attack(1, playerA, cCelebrant); // should not be able to enter this 3rd combat phase + + setStopAt(1, PhaseStep.COMBAT_DAMAGE); + execute(); + + assertLife(playerB, 15); // 4 + 1 + assertTapped(cCelebrant, true); + assertTapped(memnite, false); + + // Second combat phase attack(1, playerA, memnite); setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); @@ -267,22 +277,24 @@ public class ExertTest extends CardTestPlayerBase { } /* - * Reported bug: Combat Celebrant able to exert again despite being exerted already if Always Watching is in play. (Or presumably any Vigilance granting effect) - */ + * Reported bug: Combat Celebrant able to exert again despite being exerted already if Always Watching is in play. + * (Or presumably any Vigilance granting effect) + */ @Test public void combatCelebrantExertedCannotExertDuringNextCombatPhase_InteractionWithAlwaysWatching() { /* - Combat Celebrant 2R - Creature - Human Warrior 4/1 - If Combat Celebrant hasn't been exerted this turn, you may exert it as it attacks. When you do, untap all other creatures you control and after this phase, there is an additional combat phase. - */ + * Combat Celebrant 2R + * Creature - Human Warrior 4/1 + * If Combat Celebrant hasn't been exerted this turn, you may exert it as it attacks. + * When you do, untap all other creatures you control and after this phase, there is an additional combat phase. + */ String cCelebrant = "Combat Celebrant"; - + /* - Always Watching 1WW - Enchantment - Non-token creatures you control get +1/+1 and have vigilance. - */ + * Always Watching 1WW + * Enchantment + * Non-token creatures you control get +1/+1 and have vigilance. + */ String aWatching = "Always Watching"; String memnite = "Memnite"; // {0} 1/1 @@ -290,14 +302,23 @@ public class ExertTest extends CardTestPlayerBase { addCard(Zone.BATTLEFIELD, playerA, cCelebrant); addCard(Zone.BATTLEFIELD, playerA, memnite); + setStrictChooseMode(true); + + // First combat phase attack(1, playerA, cCelebrant); attack(1, playerA, memnite); setChoice(playerA, true); // exert for extra turn + + setStopAt(1, PhaseStep.COMBAT_DAMAGE); + execute(); + + assertLife(playerB, 13); // 5 + 2 (Celebrant once, Memnite once with +1/+1 on both) + assertTapped(cCelebrant, false); + assertTapped(memnite, false); + + // Extra combat phase attack(1, playerA, cCelebrant); attack(1, playerA, memnite); - setChoice(playerA, true); // try to exert again - attack(1, playerA, cCelebrant); // should not be able to enter this 3rd combat phase - attack(1, playerA, memnite); setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); execute(); @@ -313,17 +334,18 @@ public class ExertTest extends CardTestPlayerBase { @Test public void combatCelebrantExertedCannotExertAgainDuringNextCombatPhase_InteractionWithArlinnKord() { /* - Combat Celebrant 2R - Creature - Human Warrior 4/1 - If Combat Celebrant hasn't been exerted this turn, you may exert it as it attacks. When you do, untap all other creatures you control and after this phase, there is an additional combat phase. + * Combat Celebrant 2R + * Creature - Human Warrior 4/1 + * If Combat Celebrant hasn't been exerted this turn, you may exert it as it attacks. + * When you do, untap all other creatures you control and after this phase, there is an additional combat phase. */ String cCelebrant = "Combat Celebrant"; /* - Arlinn Kord {2}{R}{G} - Planeswalker — Arlinn 3 loyalty - +1: Until end of turn, up to one target creature gets +2/+2 and gains vigilance and haste. - 0: Create a 2/2 green Wolf creature token. Transform Arlinn Kord. + * Arlinn Kord {2}{R}{G} + * Planeswalker — Arlinn 3 loyalty + * +1: Until end of turn, up to one target creature gets +2/+2 and gains vigilance and haste. + * 0: Create a 2/2 green Wolf creature token. Transform Arlinn Kord. */ String aKord = "Arlinn Kord"; @@ -332,11 +354,13 @@ public class ExertTest extends CardTestPlayerBase { activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1:"); // grant +2/+2 vig and haste to celebrant addTarget(playerA, cCelebrant); + + // First combat phase attack(1, playerA, cCelebrant); setChoice(playerA, true); // exert for extra turn + + // Second combat phase attack(1, playerA, cCelebrant); - setChoice(playerA, true); // try to exert again - attack(1, playerA, cCelebrant); // should not be able to enter this 3rd combat phase setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); execute(); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HexproofTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HexproofTest.java index 00c6bf2477..b89b952e33 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HexproofTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HexproofTest.java @@ -154,7 +154,7 @@ public class HexproofTest extends CardTestPlayerBaseWithAIHelps { Assert.fail("must throw exception on execute"); } catch (Throwable e) { if (!e.getMessage().contains("setup good targets")) { - Assert.fail("must thow error about bad targets, but got:\n" + e.getMessage()); + Assert.fail("must throw error about bad targets, but got:\n" + e.getMessage()); } } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/counterspell/ResetTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/counterspell/ResetTest.java index 3fd137d600..d910586381 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/counterspell/ResetTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/counterspell/ResetTest.java @@ -12,7 +12,7 @@ import org.mage.test.serverside.base.CardTestPlayerBase; */ public class ResetTest extends CardTestPlayerBase { - /** + /* * I was playing a game against Show and Tell with the deck Solidarity (or * Reset High Tide) and xmage would not allow me to play Reset costing me * the match. @@ -22,69 +22,41 @@ public class ResetTest extends CardTestPlayerBase { * * It was working in the previous build so this issue surprised me. */ - @Test - public void testResetDoesWork() { - addCard(Zone.HAND, playerA, "Lightning Bolt"); - addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); + /** + * Should be allowed to cast Reset on opponent's turn after their upkeep. + */ + @Test + public void testResetShouldWork() { addCard(Zone.BATTLEFIELD, playerB, "Island", 2, true); addCard(Zone.BATTLEFIELD, playerB, "Island", 2); // Cast Reset only during an opponent's turn after their upkeep step. // Untap all lands you control. addCard(Zone.HAND, playerB, "Reset"); - // Counter target spell. - // Draw a card. - addCard(Zone.HAND, playerB, "Dismiss"); - - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Reset"); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Dismiss", "Lightning Bolt"); setStopAt(1, PhaseStep.END_TURN); execute(); - assertLife(playerA, 20); - assertLife(playerB, 20); - - assertGraveyardCount(playerA, "Lightning Bolt", 1); + assertTappedCount("Island", false,4); assertGraveyardCount(playerB, "Reset", 1); - assertGraveyardCount(playerB, "Dismiss", 1); - - assertHandCount(playerB, 1); - } + /** + * Should not be allowed to cast reset during your own turn. + */ @Test - public void testResetDoesNotWork() { - addCard(Zone.BATTLEFIELD, playerA, "Island", 2); + public void testResetShouldNotWork() { + addCard(Zone.BATTLEFIELD, playerA, "Island", 2, true); addCard(Zone.BATTLEFIELD, playerA, "Island", 2); // Cast Reset only during an opponent's turn after their upkeep step. // Untap all lands you control. addCard(Zone.HAND, playerA, "Reset"); - // Counter target spell. - // Draw a card. - addCard(Zone.HAND, playerA, "Dismiss"); // {2}{U}{U} - addCard(Zone.HAND, playerA, "Lumengrid Warden"); // {1}{U} 1/3 - addCard(Zone.HAND, playerB, "Lightning Bolt"); - addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1); - - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lumengrid Warden"); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", playerA); - - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Reset"); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Dismiss", "Lightning Bolt"); + checkPlayableAbility("during", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Reset", false); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); - - assertPermanentCount(playerA, "Lumengrid Warden", 1); - assertGraveyardCount(playerB, "Lightning Bolt", 1); - assertHandCount(playerA, "Reset", 1); - assertHandCount(playerA, "Dismiss", 1); - assertLife(playerB, 20); - assertLife(playerA, 17); - } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/control/PutIntoPlayEffectsTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/control/PutIntoPlayEffectsTest.java index 33d61545a3..4415af34e0 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/control/PutIntoPlayEffectsTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/control/PutIntoPlayEffectsTest.java @@ -19,7 +19,7 @@ public class PutIntoPlayEffectsTest extends CardTestPlayerBase { * e.g. the top card of the library of the current controller of Oracle of Mul Daya is revealed */ @Test - public void testLordOfTheVoid() { + public void testLordOfTheVoidDirectFromDeck() { skipInitShuffling(); // You may play an additional land on each of your turns. // Play with the top card of your library revealed. @@ -30,8 +30,9 @@ public class PutIntoPlayEffectsTest extends CardTestPlayerBase { // onto the battlefield under your control. addCard(Zone.BATTLEFIELD, playerB, "Lord of the Void"); - attack(2, playerB, "Lord of the Void"); - setChoice(playerB, "Oracle of Mul Daya"); + setStrictChooseMode(true); + attack(2, playerB, "Lord of the Void", playerA); + addTarget(playerB, "Oracle of Mul Daya"); setStopAt(2, PhaseStep.POSTCOMBAT_MAIN); execute(); @@ -45,12 +46,11 @@ public class PutIntoPlayEffectsTest extends CardTestPlayerBase { } - /* - test also if the Oracle was in play before by the owner of the oracle + /** + * Same as testLordOfTheVoid, but checks if it works when the Oracle was in previous under it's owner's control. */ @Test - public void testLordOfTheVoid2() { - + public void testLordOfTheVoidPreviouslyControlled() { addCard(Zone.BATTLEFIELD, playerA, "Oracle of Mul Daya"); // Whenever Lord of the Void deals combat damage to a player, exile the top seven cards // of that player's library, then put a creature card from among them @@ -61,9 +61,10 @@ public class PutIntoPlayEffectsTest extends CardTestPlayerBase { // Put target creature on top of its owner's library. addCard(Zone.HAND, playerB, "Griptide"); + setStrictChooseMode(true); castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Griptide", "Oracle of Mul Daya"); - attack(2, playerB, "Lord of the Void"); - setChoice(playerB, "Oracle of Mul Daya"); + attack(2, playerB, "Lord of the Void", playerA); + addTarget(playerB, "Oracle of Mul Daya"); setStopAt(2, PhaseStep.POSTCOMBAT_MAIN); execute(); @@ -77,12 +78,11 @@ public class PutIntoPlayEffectsTest extends CardTestPlayerBase { } /** - * A Silvercoat Lion from opponents deck will be put into play with Bribery. Than the opponent bounces this card - * back to hand and cast the spell itself. + * A Silvercoat Lion from opponents deck will be put into play with Bribery. + * Then the opponent bounces this card back to hand and cast the spell itself. */ @Test - public void bribery1() { - + public void testBribery() { addCard(Zone.BATTLEFIELD, playerA, "Island", 5); // Bribery - Sorcery {3}{U}{U} // Search target opponent's library for a creature card and put that card onto the battlefield @@ -96,9 +96,10 @@ public class PutIntoPlayEffectsTest extends CardTestPlayerBase { addCard(Zone.HAND, playerB, "Eye of Nowhere"); addCard(Zone.LIBRARY, playerB, "Silvercoat Lion", 1); skipInitShuffling(); - + + setStrictChooseMode(true); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Bribery", playerB); - setChoice(playerA, "Silvercoat Lion"); + addTarget(playerA, "Silvercoat Lion"); castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Eye of Nowhere", "Silvercoat Lion"); castSpell(2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Silvercoat Lion"); @@ -112,6 +113,5 @@ public class PutIntoPlayEffectsTest extends CardTestPlayerBase { assertGraveyardCount(playerB, "Eye of Nowhere", 1); assertHandCount(playerB, "Silvercoat Lion", 0); assertPermanentCount(playerB, "Silvercoat Lion", 1); - } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/cost/alternate/CastFromHandWithoutPayingManaCostTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/cost/alternate/CastFromHandWithoutPayingManaCostTest.java index 22956ce9fc..7d482b1f8e 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/cost/alternate/CastFromHandWithoutPayingManaCostTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/cost/alternate/CastFromHandWithoutPayingManaCostTest.java @@ -25,16 +25,21 @@ public class CastFromHandWithoutPayingManaCostTest extends CardTestPlayerBase { assertPermanentCount(playerA, "Gray Ogre", 1); } + /** + * Omniscience only lets you cast spells for free from your hand. + * Haakon lets you cast knights from your graveyard. + * + * If you control both, you must still pay costs to cast knights from your graveyard. + */ @Test public void testSpellHasCostIfCastFromGraveyard() { - // You may cast nonland cards from your hand without paying their mana costs. addCard(Zone.BATTLEFIELD, playerA, "Omniscience", 1); addCard(Zone.BATTLEFIELD, playerA, "Haakon, Stromgald Scourge", 1); addCard(Zone.GRAVEYARD, playerA, "Knight of the White Orchid", 1); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Knight of the White Orchid"); + checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Knight of the White Orchid", false); setStopAt(1, PhaseStep.END_TURN); execute(); @@ -235,10 +240,9 @@ public class CastFromHandWithoutPayingManaCostTest extends CardTestPlayerBase { /** + * Omniscience only lets you cast spells from your hand without paying their mana costs. * If another effect (e.g. Future Sight) allows you to cast nonland cards - * from zones other than your hand, Xmage incorrectly lets you cast those - * cards without paying their mana costs. Omniscience only lets you cast - * spells from your hand without paying their mana costs. + * from zones other than your hand, then you still have to pay the costs. */ @Test public void testCastingWithFutureSight() { @@ -252,8 +256,8 @@ public class CastFromHandWithoutPayingManaCostTest extends CardTestPlayerBase { addCard(Zone.LIBRARY, playerA, "Silvercoat Lion", 1); skipInitShuffling(); + setStrictChooseMode(true); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion"); - setChoice(playerA, true); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); @@ -309,14 +313,14 @@ public class CastFromHandWithoutPayingManaCostTest extends CardTestPlayerBase { } /** - * If a spell has an unpayable cost (e.g. Ancestral Vision, which has no - * mana cost), Omniscience should allow you to cast that spell without - * paying its mana cost. In the case of Ancestral Vision, for example, Xmage - * only gives you the option to suspend Ancestral Vision. 117.6a If an - * unpayable cost is increased by an effect or an additional cost is - * imposed, the cost is still unpayable. If an alternative cost is applied - * to an unpayable cost, including an effect that allows a player to cast a - * spell without paying its mana cost, the alternative cost may be paid. + * If a spell has an unpayable cost (e.g. Ancestral Vision, which has no mana cost), + * Omniscience should allow you to cast that spell without paying its mana cost. + * In the case of Ancestral Vision, for example, Xmage only gives you the option to suspend Ancestral Vision. + * + * 118.6a If an unpayable cost is increased by an effect or an additional cost is imposed, + * the cost is still unpayable. + * If an alternative cost is applied to an unpayable cost, including an effect that allows a player + * to cast a spell without paying its mana cost, the alternative cost may be paid. */ @Test public void testCastingUnpayableCost() { @@ -327,8 +331,9 @@ public class CastFromHandWithoutPayingManaCostTest extends CardTestPlayerBase { // Target player draws three cards. addCard(Zone.HAND, playerA, "Ancestral Vision", 1); + setStrictChooseMode(true); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ancestral Vision", playerA); - addTarget(playerA, playerB); + setChoice(playerA, "Yes"); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/cost/custom/SerraAvengerTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/cost/custom/SerraAvengerTest.java index 3ac1f027e4..8caa9fc036 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/cost/custom/SerraAvengerTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/cost/custom/SerraAvengerTest.java @@ -12,23 +12,26 @@ import org.mage.test.serverside.base.CardTestPlayerBase; public class SerraAvengerTest extends CardTestPlayerBase { /** - * Try to cast Serra Avenger on 1st, 2nd, 3rd and 4th turns. - * It should success only on 4th one. + * Serra Avenger can't be cast on your 1st, 2nd, and 3rd turns. + * It can only be cast on the 4th turn. */ @Test public void testCard() { addCard(Zone.BATTLEFIELD, playerA, "Plains", 2); - addCard(Zone.HAND, playerA, "Serra Avenger", 4); + addCard(Zone.HAND, playerA, "Serra Avenger", 1); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Serra Avenger"); - castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Serra Avenger"); - castSpell(5, PhaseStep.PRECOMBAT_MAIN, playerA, "Serra Avenger"); + // Can't cost on the 1st, 2nd, and 3rd turns + checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Serra Avenger", false); + checkPlayableAbility("before", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Serra Avenger", false); + checkPlayableAbility("before", 5, PhaseStep.PRECOMBAT_MAIN, playerA, "Serra Avenger", false); + + // Can only cast on the 4th turn. castSpell(7, PhaseStep.PRECOMBAT_MAIN, playerA, "Serra Avenger"); setStopAt(7, PhaseStep.BEGIN_COMBAT); execute(); - assertPermanentCount(playerA, "Serra Avenger", 1); // only the one that was cast on 4th turn + assertPermanentCount(playerA, "Serra Avenger", 1); } /** diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/akh/BontuTheGlorifiedTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/akh/BontuTheGlorifiedTest.java index bdca53426b..e6eb32dfff 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/akh/BontuTheGlorifiedTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/akh/BontuTheGlorifiedTest.java @@ -5,12 +5,13 @@ import mage.constants.Zone; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; +/** + * {@link BontuTheGlorifiedTest Bontu the Glorified} + * Menace, Indestructible + * Bontu the Glorified can’t attack or block unless a creature died under your control this turn. + * {1}{B}, Sacrifice another creature: Scry 1. Each opponent loses 1 life and you gain 1 life. + */ public class BontuTheGlorifiedTest extends CardTestPlayerBase { - - //Menace - //Indestructible - //Bontu the Glorified can't attack or block unless a creature died under your control this turn. - //{1}{B}, Sacrifice another creature: Scry 1. Each opponent loses 1 life and you gain 1 life. String bontu = "Bontu the Glorified"; String swamp = "Swamp"; String grizzly = "Grizzly Bears"; @@ -68,7 +69,6 @@ public class BontuTheGlorifiedTest extends CardTestPlayerBase { @Test public void testBontuSacAbilityTriggersAttack() { - addCard(Zone.BATTLEFIELD, playerA, bontu); addCard(Zone.BATTLEFIELD, playerA, swamp, 10); addCard(Zone.BATTLEFIELD, playerA, grizzly); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/c19/ChainerNightmareAdeptTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/c19/ChainerNightmareAdeptTest.java index 24ba3f45a2..c5c97c242f 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/c19/ChainerNightmareAdeptTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/c19/ChainerNightmareAdeptTest.java @@ -25,7 +25,10 @@ public class ChainerNightmareAdeptTest extends CardTestPlayerBase { activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Discard"); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, maaka); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, maaka); + + // Only one should be castable + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); + checkPlayableAbility("during", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast " + maaka, false); attack(1, playerA, maaka); @@ -66,7 +69,7 @@ public class ChainerNightmareAdeptTest extends CardTestPlayerBase { assertPermanentCount(playerA, khenra, 1); assertTapped(khenra, true); - assertAbility(playerA, maaka, HasteAbility.getInstance(), true); + assertAbility(playerA, khenra, HasteAbility.getInstance(), true); assertGraveyardCount(playerA, khenra, 0); assertLife(playerB, 20 - 2 - 2); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/dka/GravecrawlerTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/dka/GravecrawlerTest.java index 11be16db11..0879505d63 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/dka/GravecrawlerTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/dka/GravecrawlerTest.java @@ -11,18 +11,15 @@ import org.mage.test.serverside.base.CardTestPlayerBase; */ public class GravecrawlerTest extends CardTestPlayerBase { - /* Cryptoplasm - * Creature — Shapeshifter 2/2, 1UU - * At the beginning of your upkeep, you may have Cryptoplasm become a copy of another target creature. If you do, Cryptoplasm gains this ability. - * - * + /* + * Gravecrawler * Creature — Zombie 2/1, B * Gravecrawler can't block. * You may cast Gravecrawler from your graveyard as long as you control a Zombie. */ @Test - public void testCard() { + public void testShouldBeCastable() { addCard(Zone.GRAVEYARD, playerA, "Gravecrawler"); addCard(Zone.BATTLEFIELD, playerA, "Black Cat"); addCard(Zone.BATTLEFIELD, playerA, "Swamp"); @@ -31,28 +28,28 @@ public class GravecrawlerTest extends CardTestPlayerBase { setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); - assertLife(playerA, 20); - assertLife(playerB, 20); assertPermanentCount(playerA, "Gravecrawler", 1); assertGraveyardCount(playerA, 0); } @Test - public void testCard1() { + public void testShouldNotBeCastable() { addCard(Zone.GRAVEYARD, playerA, "Gravecrawler"); addCard(Zone.BATTLEFIELD, playerA, "Swamp"); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Gravecrawler"); + checkPlayableAbility("befre", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Gravecrawler", false); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); - assertLife(playerA, 20); - assertLife(playerB, 20); assertPermanentCount(playerA, "Gravecrawler", 0); - assertGraveyardCount(playerA, 1); + assertGraveyardCount(playerA, "Gravecrawler", 1); } /* + * Cryptoplasm + * Creature — Shapeshifter 2/2, 1UU + * At the beginning of your upkeep, you may have Cryptoplasm become a copy of another target creature. If you do, Cryptoplasm gains this ability. + * * Elite Vanguard * Creature — Human Soldier 2/1, W * @@ -63,7 +60,7 @@ public class GravecrawlerTest extends CardTestPlayerBase { @Test public void testCopiedCantBlockAbilityWorks() { addCard(Zone.BATTLEFIELD, playerA, "Island", 3); - addCard(Zone.HAND, playerA, "Cryptoplasm"); + addCard(Zone.HAND, playerA, "Cryptoplasm"); addCard(Zone.BATTLEFIELD, playerA, "Fervor"); addCard(Zone.BATTLEFIELD, playerA, "Elite Vanguard"); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/dom/SimpleDominariaCards.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/dom/SimpleDominariaCards.java index 27dc971319..30cdf6fa36 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/dom/SimpleDominariaCards.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/dom/SimpleDominariaCards.java @@ -2,6 +2,7 @@ package org.mage.test.cards.single.dom; import mage.constants.PhaseStep; import mage.constants.Zone; +import org.junit.Assert; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -41,11 +42,12 @@ public class SimpleDominariaCards extends CardTestPlayerBase { addCard(Zone.HAND, playerB, "Terror"); addCard(Zone.BATTLEFIELD, playerB, "Swamp", 3); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Terror", "Knight of Grace"); - setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); + // Knight of Grace has protection from Black so Terror should not be castable + checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerB, "Cast Terror", false); execute(); assertGraveyardCount(playerA, "Knight of Grace", 0); + assertHandCount(playerB, "Terror", 1); } @Test @@ -66,12 +68,22 @@ public class SimpleDominariaCards extends CardTestPlayerBase { @Test public void testKnightOfGraceBlackAbility(){ addCard(Zone.BATTLEFIELD, playerA, "Knight of Grace"); - addCard(Zone.BATTLEFIELD, playerB, "Royal Assassin"); + addCard(Zone.BATTLEFIELD, playerB, "Avatar of Woe"); - activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{T}: ", "Knight of Grace"); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{T}"); + addTarget(playerB, "Knight of Grace"); setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); - execute(); + try { + execute(); + Assert.fail("must throw exception on execute"); + } catch (Throwable e) { + if (!e.getMessage().contains("setup good targets")) { + Assert.fail("must throw error about bad targets, but got:\n" + e.getMessage()); + } + } + + assertTapped("Avatar of Woe", false); assertGraveyardCount(playerA, "Knight of Grace", 0); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/lrw/MulldrifterTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/lrw/MulldrifterTest.java index 8e65bab5bb..c12d2a0231 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/lrw/MulldrifterTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/lrw/MulldrifterTest.java @@ -73,7 +73,6 @@ public class MulldrifterTest extends CardTestPlayerBase { castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ghostly Flicker"); addTarget(playerA, "Mulldrifter^Merfolk Looter"); - setChoice(playerA, false); // do not pay evoke cost setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/cards/abilities/ProtectionFromTypeTest.java b/Mage.Tests/src/test/java/org/mage/test/serverside/cards/abilities/ProtectionFromTypeTest.java index fd99ac65e8..82f637ab58 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/cards/abilities/ProtectionFromTypeTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/cards/abilities/ProtectionFromTypeTest.java @@ -17,7 +17,7 @@ public class ProtectionFromTypeTest extends CardTestPlayerBase { addCard(Zone.BATTLEFIELD, playerB, "Tel-Jilad Fallen"); - activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}, Remove a charge counter from {this}, {T}: put a -1/-1 counter on target creature.", "Tel-Jilad Fallen"); + checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Remove", false); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute();