From 91d24b0e31359b95b2a3b669726b6f724a0948cf Mon Sep 17 00:00:00 2001 From: Derek Monturo Date: Fri, 12 May 2017 16:52:30 -0400 Subject: [PATCH] UTs for #3323 and #3252 confirming bugs --- .../akh/HapatraVizierOfPoisonsTest.java | 29 +++++ .../cards/single/akh/NewPerspectivesTest.java | 121 ++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/akh/NewPerspectivesTest.java diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/akh/HapatraVizierOfPoisonsTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/akh/HapatraVizierOfPoisonsTest.java index 7815c5bb4c..c665211aeb 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/akh/HapatraVizierOfPoisonsTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/akh/HapatraVizierOfPoisonsTest.java @@ -69,4 +69,33 @@ public class HapatraVizierOfPoisonsTest extends CardTestPlayerBase { assertPermanentCount(playerA, "Snake", 1); assertAbility(playerA, "Snake", DeathtouchAbility.getInstance(), true); } + + /* + * Reported bug for issue #3252 + * Devoted Druid untap ability not triggering Hapatra + */ + @Test + public void devotedDruidTriggersHapatra() { + + /* + Devoted Druid {1}{G} + Creature - Elf Druid 0/2 + {T}: Add Green to your mana pool. + Put a -1/-1 counter on Devoted Druid: Untap Devoted Druid. + */ + String dDruid = "Devoted Druid"; + + addCard(Zone.BATTLEFIELD, playerA, hapatra); + addCard(Zone.BATTLEFIELD, playerA, dDruid); + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Put"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertCounterCount(playerA, dDruid, CounterType.M1M1, 1); + assertPowerToughness(playerA, dDruid, -1, 1); // 0/2 with -1/-1 + assertPermanentCount(playerA, "Snake", 1); + assertAbility(playerA, "Snake", DeathtouchAbility.getInstance(), true); + } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/akh/NewPerspectivesTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/akh/NewPerspectivesTest.java new file mode 100644 index 0000000000..bb10bc8cb0 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/akh/NewPerspectivesTest.java @@ -0,0 +1,121 @@ +package org.mage.test.cards.single.akh; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * Created by escplan9 + */ +public class NewPerspectivesTest extends CardTestPlayerBase { + + /* + New Perspectives {5}{U} + Enchantment + When New Perspectives enters the battlefield, draw three cards. + As long as you have seven or more cards in hand, you may pay 0 rather than pay cycling costs. + */ + private String nPerspectives = "New Perspectives"; + + // just a basic test for free cycling! + @Test + public void newPerspectives_7Cards_FreeCycling() { + + String fJet = "Flame Jet"; // {1}{R} Sorcery deal 3 dmg to player. cycling (2) + + removeAllCardsFromHand(playerA); + addCard(Zone.BATTLEFIELD, playerA, "Island", 6); + addCard(Zone.HAND, playerA, nPerspectives); + addCard(Zone.HAND, playerA, "Mountain", 3); + addCard(Zone.HAND, playerA, fJet); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, nPerspectives); + activateAbility(1, PhaseStep.BEGIN_COMBAT, playerA, "Cycling"); + + setStopAt(1, PhaseStep.END_COMBAT); + execute(); + + assertPermanentCount(playerA, nPerspectives, 1); + assertGraveyardCount(playerA, fJet, 1); + assertHandCount(playerA, 7); // 4 + 3 (new perspectives ETB) (+ 1 - 1) (cycling) + } + + // fewer than 7 cards in hand, no free cycle! + @Test + public void newPerspectives_LessThan7Cards_CyclingNotFree() { + + String fJet = "Flame Jet"; // {1}{R} Sorcery deal 3 dmg to player. cycling (2) + + removeAllCardsFromHand(playerA); + addCard(Zone.BATTLEFIELD, playerA, "Island", 6); + addCard(Zone.HAND, playerA, nPerspectives); + addCard(Zone.HAND, playerA, fJet); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, nPerspectives); + activateAbility(1, PhaseStep.BEGIN_COMBAT, playerA, "Cycling"); + + setStopAt(1, PhaseStep.END_COMBAT); + execute(); + + assertPermanentCount(playerA, nPerspectives, 1); + assertGraveyardCount(playerA, fJet, 0); + assertHandCount(playerA, fJet, 1); + assertHandCount(playerA, 4); // 1 + 3 (new perspectives ETB) + } + + /* + * Reported bug for #3323: + * If you cast a second copy of New Perspective while the first one is still in play, the client will freeze. + */ + @Test + public void newPerspectives_PlayingSecondOneWithFewerThan7CardsOnCast() { + + String fJet = "Flame Jet"; // {1}{R} Sorcery deal 3 dmg to player. cycling (2) + + removeAllCardsFromHand(playerA); + addCard(Zone.BATTLEFIELD, playerA, "Island", 6); + addCard(Zone.HAND, playerA, nPerspectives, 2); + addCard(Zone.HAND, playerA, fJet); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, nPerspectives); + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, nPerspectives); + + activateAbility(3, PhaseStep.BEGIN_COMBAT, playerA, "Cycling"); + + setStopAt(3, PhaseStep.END_COMBAT); + execute(); + + assertPermanentCount(playerA, nPerspectives, 2); + assertHandCount(playerA, 8); // 1 (flame jet cycled) + 3 (new perspectives ETB) + 1 (draw step) + 3 (2nd perspectives etb) + assertGraveyardCount(playerA, fJet, 1); + } + + /* + * Reported bug for #3323: NOTE test failing due to bug in code (game freezes after casting 2nd new perspectives) + * If you cast a second copy of New Perspective while the first one is still in play, the client will freeze. + */ + @Test + public void newPerspectives_PlayingSecondOneWithMoreThan7CardsOnCast() { + + String fJet = "Flame Jet"; // {1}{R} Sorcery deal 3 dmg to player. cycling (2) + + removeAllCardsFromHand(playerA); + addCard(Zone.BATTLEFIELD, playerA, "Island", 6); + addCard(Zone.HAND, playerA, nPerspectives, 2); + addCard(Zone.HAND, playerA, "Mountain", 3); + addCard(Zone.HAND, playerA, fJet); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, nPerspectives); + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, nPerspectives); + + activateAbility(3, PhaseStep.BEGIN_COMBAT, playerA, "Cycling"); + + setStopAt(3, PhaseStep.END_COMBAT); + execute(); + + assertPermanentCount(playerA, nPerspectives, 2); + assertGraveyardCount(playerA, fJet, 1); + assertHandCount(playerA, 11); // 1 (flame jet cycled) + 3 Mountains in hand + 3 (new perspectives ETB) + 1 (draw step) + 3 (2nd perspectives etb) + } +}