From 9c8258c54b9c53d3520d8baaa20b4400df7d548d Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 6 Apr 2016 19:09:55 +0200 Subject: [PATCH] Harness the Storm - Fixed wrong ability copy method leading to not correct functioning (fixes #1686). --- .../shadowsoverinnistrad/HarnessTheStorm.java | 4 +- .../cards/triggers/SpellCastTriggerTest.java | 72 ++++++++++++++++--- 2 files changed, 64 insertions(+), 12 deletions(-) diff --git a/Mage.Sets/src/mage/sets/shadowsoverinnistrad/HarnessTheStorm.java b/Mage.Sets/src/mage/sets/shadowsoverinnistrad/HarnessTheStorm.java index ff0265d173..21077af919 100644 --- a/Mage.Sets/src/mage/sets/shadowsoverinnistrad/HarnessTheStorm.java +++ b/Mage.Sets/src/mage/sets/shadowsoverinnistrad/HarnessTheStorm.java @@ -103,8 +103,8 @@ class HarnessTheStormTriggeredAbility extends SpellCastControllerTriggeredAbilit } @Override - public SpellCastControllerTriggeredAbility copy() { - return super.copy(); //To change body of generated methods, choose Tools | Templates. + public HarnessTheStormTriggeredAbility copy() { + return new HarnessTheStormTriggeredAbility(this); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SpellCastTriggerTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SpellCastTriggerTest.java index ce7aaa7db6..16fd900b35 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SpellCastTriggerTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SpellCastTriggerTest.java @@ -36,7 +36,6 @@ import org.mage.test.serverside.base.CardTestPlayerBase; * * @author LevelX2 */ - public class SpellCastTriggerTest extends CardTestPlayerBase { /** @@ -50,7 +49,7 @@ public class SpellCastTriggerTest extends CardTestPlayerBase { addCard(Zone.BATTLEFIELD, playerA, "Sunscorch Regent", 1); addCard(Zone.HAND, playerB, "Lightning Bolt"); - addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1); + addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1); castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", playerA); @@ -59,9 +58,9 @@ public class SpellCastTriggerTest extends CardTestPlayerBase { assertLife(playerA, 18); // 20 -3 +1 assertLife(playerB, 20); - + assertGraveyardCount(playerB, "Lightning Bolt", 1); - + assertPowerToughness(playerA, "Sunscorch Regent", 5, 4); } @@ -69,13 +68,13 @@ public class SpellCastTriggerTest extends CardTestPlayerBase { * Monastery Mentor triggers are causing a "rollback" error. */ @Test - public void testMonasteryMentor() { + public void testMonasteryMentor() { // Prowess (Whenever you cast a noncreature spell, this creature gets +1/+1 until end of turn.) // Whenever you cast a noncreature spell, put a 1/1 white Monk creature token with prowess onto the battlefield. addCard(Zone.BATTLEFIELD, playerA, "Monastery Mentor", 1); addCard(Zone.HAND, playerA, "Lightning Bolt", 2); - addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", playerB); @@ -83,14 +82,67 @@ public class SpellCastTriggerTest extends CardTestPlayerBase { setStopAt(1, PhaseStep.END_TURN); execute(); - assertLife(playerA, 20); + assertLife(playerA, 20); assertLife(playerB, 14); - + assertGraveyardCount(playerA, "Lightning Bolt", 2); assertPermanentCount(playerA, "Monk", 2); assertPowerToughness(playerA, "Monk", 2, 2); assertPowerToughness(playerA, "Monk", 1, 1); - + assertPowerToughness(playerA, "Monastery Mentor", 4, 4); - } + } + + @Test + public void testHarnessTheStormFirstTurn() { + // Whenever you cast an instant or sorcery spell from your hand, you may cast target card with the same name as that spell from your graveyard. + addCard(Zone.BATTLEFIELD, playerA, "Harness the Storm", 1); + + // Put two 1/1 red Devil creature tokens onto the battlefield. They have "When this creature dies, it deals 1 damage to target creature or player." + addCard(Zone.HAND, playerA, "Dance with Devils", 1); // {3}{R} + addCard(Zone.GRAVEYARD, playerA, "Dance with Devils", 1); // {3}{R} + + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 8); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Dance with Devils"); + setChoice(playerA, "Yes"); + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertGraveyardCount(playerA, "Dance with Devils", 2); + assertPermanentCount(playerA, "Devil", 4); + } + + /** + * I had cast Dance with Devils the turn before. On this turn I was casting + * Read the Bones. The enchantment should not have triggered and if it did + * it should have asked me to cast read the bones. + */ + @Test + public void testHarnessTheStormThirdTurn() { + // Whenever you cast an instant or sorcery spell from your hand, you may cast target card with the same name as that spell from your graveyard. + addCard(Zone.BATTLEFIELD, playerA, "Harness the Storm", 1); + + // Put two 1/1 red Devil creature tokens onto the battlefield. They have "When this creature dies, it deals 1 damage to target creature or player." + addCard(Zone.HAND, playerA, "Dance with Devils", 1); // {3}{R} + // Scry 2, then draw two cards. You lose 2 life. + addCard(Zone.HAND, playerA, "Read the Bones", 1); // {2}{B} + addCard(Zone.GRAVEYARD, playerA, "Read the Bones", 1); + + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4); + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Dance with Devils"); + + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Read the Bones"); + + setStopAt(3, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Dance with Devils", 1); + assertPermanentCount(playerA, "Devil", 2); + assertGraveyardCount(playerA, "Read the Bones", 2); + assertHandCount(playerA, 5); // one normally drawn + 4 from Read the Bones + + } }