From 0833e4b81fd0d966ad3fb27ddb166338bda72c86 Mon Sep 17 00:00:00 2001 From: goblin Date: Fri, 27 Jan 2017 00:04:09 +0100 Subject: [PATCH 1/8] test for issue #2816 --- .../damage/FlameheartWerewolfTest.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java new file mode 100644 index 00000000000..be044da4feb --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java @@ -0,0 +1,74 @@ +package org.mage.test.cards.abilities.oneshot.damage; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author goblin + */ +public class FlameheartWerewolfTest extends CardTestPlayerBase { + + /** + * https://github.com/magefree/mage/issues/2816 + */ + @Test + public void testBlockingKalitas() { + // this card is the second face of double-faced card + + // Flameheart Werewolf is a 3/2 with: + // Whenever Flameheart Werewolf blocks or becomes blocked by a creature, Flameheart Werewolf deals 2 damage to that creature. + + // Kalitas, Traitor of Ghet is a 3/4 with: + // Lifelink + // If a nontoken creature an opponent controls would die, instead exile that card and put a 2/2 black Zombie creature token onto the battlefield + + addCard(Zone.BATTLEFIELD, playerA, "Flameheart Werewolf"); + addCard(Zone.BATTLEFIELD, playerB, "Kalitas, Traitor of Ghet"); + + attack(2, playerB, "Kalitas, Traitor of Ghet"); + block(2, playerA, "Flameheart Werewolf", "Kalitas, Traitor of Ghet"); + + setStopAt(2, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 23); // lifelinked + + // both should die + assertPermanentCount(playerA, "Flameheart Werewolf", 0); + assertExileCount("Flameheart Werewolf", 1); // exiled by Kalitas + assertPermanentCount(playerB, "Kalitas, Traitor of Ghet", 0); + assertGraveyardCount(playerB, "Kalitas, Traitor of Ghet", 1); + } + + @Test + public void testBlockedByTwo22s() { + addCard(Zone.BATTLEFIELD, playerA, "Flameheart Werewolf"); + // Both 2/2 creatures should die before the combat starts + addCard(Zone.BATTLEFIELD, playerB, "Falkenrath Reaver"); + addCard(Zone.BATTLEFIELD, playerB, "Wind Drake"); + + attack(3, playerA, "Flameheart Werewolf"); + block(3, playerB, "Falkenrath Reaver", "Flameheart Werewolf"); + block(3, playerB, "Wind Drake", "Flameheart Werewolf"); + + setStopAt(3, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + // Flameheart Werewolf was blocked, no trample + assertLife(playerA, 20); + assertLife(playerB, 20); + + // both 2/2s should die before they had a chance to deal damage + // to Flameheart Werewolf + assertPermanentCount(playerA, "Flameheart Werewolf", 1); + assertGraveyardCount(playerA, "Flameheart Werewolf", 0); + assertPermanentCount(playerB, "Falkenrath Reaver", 0); + assertGraveyardCount(playerB, "Falkenrath Reaver", 1); + assertPermanentCount(playerB, "Wind Drake", 0); + assertGraveyardCount(playerB, "Wind Drake", 1); + } +} From ae8e121e90a72851f717fabd322d2ea76b8d3971 Mon Sep 17 00:00:00 2001 From: goblin Date: Fri, 27 Jan 2017 00:09:46 +0100 Subject: [PATCH 2/8] fix up whitespace XMage people seem to be using spaces... --- .../damage/FlameheartWerewolfTest.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java index be044da4feb..6875c85f3e7 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java @@ -12,18 +12,18 @@ import org.mage.test.serverside.base.CardTestPlayerBase; public class FlameheartWerewolfTest extends CardTestPlayerBase { /** - * https://github.com/magefree/mage/issues/2816 + * https://github.com/magefree/mage/issues/2816 */ @Test public void testBlockingKalitas() { - // this card is the second face of double-faced card + // this card is the second face of double-faced card - // Flameheart Werewolf is a 3/2 with: - // Whenever Flameheart Werewolf blocks or becomes blocked by a creature, Flameheart Werewolf deals 2 damage to that creature. + // Flameheart Werewolf is a 3/2 with: + // Whenever Flameheart Werewolf blocks or becomes blocked by a creature, Flameheart Werewolf deals 2 damage to that creature. - // Kalitas, Traitor of Ghet is a 3/4 with: - // Lifelink - // If a nontoken creature an opponent controls would die, instead exile that card and put a 2/2 black Zombie creature token onto the battlefield + // Kalitas, Traitor of Ghet is a 3/4 with: + // Lifelink + // If a nontoken creature an opponent controls would die, instead exile that card and put a 2/2 black Zombie creature token onto the battlefield addCard(Zone.BATTLEFIELD, playerA, "Flameheart Werewolf"); addCard(Zone.BATTLEFIELD, playerB, "Kalitas, Traitor of Ghet"); @@ -37,17 +37,17 @@ public class FlameheartWerewolfTest extends CardTestPlayerBase { assertLife(playerA, 20); assertLife(playerB, 23); // lifelinked - // both should die + // both should die assertPermanentCount(playerA, "Flameheart Werewolf", 0); assertExileCount("Flameheart Werewolf", 1); // exiled by Kalitas assertPermanentCount(playerB, "Kalitas, Traitor of Ghet", 0); assertGraveyardCount(playerB, "Kalitas, Traitor of Ghet", 1); } - @Test + @Test public void testBlockedByTwo22s() { addCard(Zone.BATTLEFIELD, playerA, "Flameheart Werewolf"); - // Both 2/2 creatures should die before the combat starts + // Both 2/2 creatures should die before the combat starts addCard(Zone.BATTLEFIELD, playerB, "Falkenrath Reaver"); addCard(Zone.BATTLEFIELD, playerB, "Wind Drake"); @@ -58,12 +58,12 @@ public class FlameheartWerewolfTest extends CardTestPlayerBase { setStopAt(3, PhaseStep.POSTCOMBAT_MAIN); execute(); - // Flameheart Werewolf was blocked, no trample + // Flameheart Werewolf was blocked, no trample assertLife(playerA, 20); assertLife(playerB, 20); - // both 2/2s should die before they had a chance to deal damage - // to Flameheart Werewolf + // both 2/2s should die before they had a chance to deal damage + // to Flameheart Werewolf assertPermanentCount(playerA, "Flameheart Werewolf", 1); assertGraveyardCount(playerA, "Flameheart Werewolf", 0); assertPermanentCount(playerB, "Falkenrath Reaver", 0); From 0f9ede42bd29a6f966a5901876040119c4cfab32 Mon Sep 17 00:00:00 2001 From: goblin Date: Fri, 27 Jan 2017 00:20:47 +0100 Subject: [PATCH 3/8] also test Kessig Forgemaster the other face of that card has a similar ability that needs fixing --- .../damage/FlameheartWerewolfTest.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java index 6875c85f3e7..21304603833 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java @@ -43,7 +43,7 @@ public class FlameheartWerewolfTest extends CardTestPlayerBase { assertPermanentCount(playerB, "Kalitas, Traitor of Ghet", 0); assertGraveyardCount(playerB, "Kalitas, Traitor of Ghet", 1); } - + @Test public void testBlockedByTwo22s() { addCard(Zone.BATTLEFIELD, playerA, "Flameheart Werewolf"); @@ -71,4 +71,32 @@ public class FlameheartWerewolfTest extends CardTestPlayerBase { assertPermanentCount(playerB, "Wind Drake", 0); assertGraveyardCount(playerB, "Wind Drake", 1); } + + @Test + public void testKessigForgemaster() { + addCard(Zone.BATTLEFIELD, playerA, "Kessig Forgemaster"); + // Both 1/1 creatures should die before the combat starts + addCard(Zone.BATTLEFIELD, playerB, "Wily Bandar"); + addCard(Zone.BATTLEFIELD, playerB, "Stern Constable"); + + attack(3, playerA, "Kessig Forgemaster"); + block(3, playerB, "Wily Bandar", "Flameheart Werewolf"); + block(3, playerB, "Stern Constable", "Flameheart Werewolf"); + + setStopAt(3, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + // Kessig Forgemaster was blocked, no trample + assertLife(playerA, 20); + assertLife(playerB, 20); + + // both 1/1s should die before they had a chance to deal damage + // to Kessig Forgemaster + assertPermanentCount(playerA, "Kessig Forgemaster", 1); + assertGraveyardCount(playerA, "Kessig Forgemaster", 0); + assertPermanentCount(playerB, "Wily Bandar", 0); + assertGraveyardCount(playerB, "Wily Bandar", 1); + assertPermanentCount(playerB, "Stern Constable", 0); + assertGraveyardCount(playerB, "Stern Constable", 1); + } } From 99cb632150c58e48e114e8f7db1b9723f26324b0 Mon Sep 17 00:00:00 2001 From: goblin Date: Fri, 27 Jan 2017 00:56:01 +0100 Subject: [PATCH 4/8] block Kessig in that test, not Werewolf --- .../abilities/oneshot/damage/FlameheartWerewolfTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java index 21304603833..d2ea16733a3 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java @@ -80,8 +80,8 @@ public class FlameheartWerewolfTest extends CardTestPlayerBase { addCard(Zone.BATTLEFIELD, playerB, "Stern Constable"); attack(3, playerA, "Kessig Forgemaster"); - block(3, playerB, "Wily Bandar", "Flameheart Werewolf"); - block(3, playerB, "Stern Constable", "Flameheart Werewolf"); + block(3, playerB, "Wily Bandar", "Kessig Forgemaster"); + block(3, playerB, "Stern Constable", "Kessig Forgemaster"); setStopAt(3, PhaseStep.POSTCOMBAT_MAIN); execute(); From 89e079fb9d138608433aa5279628eca45a304bf9 Mon Sep 17 00:00:00 2001 From: goblin Date: Fri, 27 Jan 2017 04:27:02 +0100 Subject: [PATCH 5/8] add license note not sure about BetaSteward, but might as well --- .../damage/FlameheartWerewolfTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java index d2ea16733a3..8a740005e40 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java @@ -1,3 +1,31 @@ +/* +* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are +* permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright notice, this list of +* conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright notice, this list +* of conditions and the following disclaimer in the documentation and/or other materials +* provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR +* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The views and conclusions contained in the software and documentation are those of the +* authors and should not be interpreted as representing official policies, either expressed +* or implied, of BetaSteward_at_googlemail.com. +*/ + package org.mage.test.cards.abilities.oneshot.damage; import mage.constants.PhaseStep; From 96aa2246523a0a5556cc4d8da13b0432812d6549 Mon Sep 17 00:00:00 2001 From: goblin Date: Fri, 27 Jan 2017 05:00:15 +0100 Subject: [PATCH 6/8] prevent Kessig from transforming each turn it was messing up the test --- .../oneshot/damage/FlameheartWerewolfTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java index 8a740005e40..68583e17b90 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java @@ -98,15 +98,26 @@ public class FlameheartWerewolfTest extends CardTestPlayerBase { assertGraveyardCount(playerB, "Falkenrath Reaver", 1); assertPermanentCount(playerB, "Wind Drake", 0); assertGraveyardCount(playerB, "Wind Drake", 1); + + System.out.println("22s end"); } @Test public void testKessigForgemaster() { + System.out.println("Forgemaster start"); addCard(Zone.BATTLEFIELD, playerA, "Kessig Forgemaster"); // Both 1/1 creatures should die before the combat starts addCard(Zone.BATTLEFIELD, playerB, "Wily Bandar"); addCard(Zone.BATTLEFIELD, playerB, "Stern Constable"); + // to prevent Kessig from transforming: + addCard(Zone.BATTLEFIELD, playerA, "Island"); + addCard(Zone.BATTLEFIELD, playerB, "Island"); + addCard(Zone.HAND, playerA, "Explosive Apparatus"); + addCard(Zone.HAND, playerB, "Explosive Apparatus"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Explosive Apparatus"); + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Explosive Apparatus"); + attack(3, playerA, "Kessig Forgemaster"); block(3, playerB, "Wily Bandar", "Kessig Forgemaster"); block(3, playerB, "Stern Constable", "Kessig Forgemaster"); From 907a12b6d2a74be1cb6be605a810fcfb4e4d7577 Mon Sep 17 00:00:00 2001 From: goblin Date: Fri, 27 Jan 2017 05:02:42 +0100 Subject: [PATCH 7/8] oops, remove debug logs and fix whitespace that wasn't meant to be committed --- .../oneshot/damage/FlameheartWerewolfTest.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java index 68583e17b90..10be65edff2 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/FlameheartWerewolfTest.java @@ -98,25 +98,22 @@ public class FlameheartWerewolfTest extends CardTestPlayerBase { assertGraveyardCount(playerB, "Falkenrath Reaver", 1); assertPermanentCount(playerB, "Wind Drake", 0); assertGraveyardCount(playerB, "Wind Drake", 1); - - System.out.println("22s end"); } @Test public void testKessigForgemaster() { - System.out.println("Forgemaster start"); addCard(Zone.BATTLEFIELD, playerA, "Kessig Forgemaster"); // Both 1/1 creatures should die before the combat starts addCard(Zone.BATTLEFIELD, playerB, "Wily Bandar"); addCard(Zone.BATTLEFIELD, playerB, "Stern Constable"); - // to prevent Kessig from transforming: - addCard(Zone.BATTLEFIELD, playerA, "Island"); - addCard(Zone.BATTLEFIELD, playerB, "Island"); - addCard(Zone.HAND, playerA, "Explosive Apparatus"); - addCard(Zone.HAND, playerB, "Explosive Apparatus"); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Explosive Apparatus"); - castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Explosive Apparatus"); + // to prevent Kessig from transforming: + addCard(Zone.BATTLEFIELD, playerA, "Island"); + addCard(Zone.BATTLEFIELD, playerB, "Island"); + addCard(Zone.HAND, playerA, "Explosive Apparatus"); + addCard(Zone.HAND, playerB, "Explosive Apparatus"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Explosive Apparatus"); + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Explosive Apparatus"); attack(3, playerA, "Kessig Forgemaster"); block(3, playerB, "Wily Bandar", "Kessig Forgemaster"); From 7b40803b4f1649d587664bf273c9cde3e46c6921 Mon Sep 17 00:00:00 2001 From: goblin Date: Fri, 27 Jan 2017 13:26:31 +0100 Subject: [PATCH 8/8] fix the issue Alter the constructor to create the object with setTargetPointer, like the other constructors. I hope nothing relies on it being false. Tests don't show anything breaking. --- .../common/BlocksOrBecomesBlockedTriggeredAbility.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/src/main/java/mage/abilities/common/BlocksOrBecomesBlockedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BlocksOrBecomesBlockedTriggeredAbility.java index 4bdb8c31bad..fe7135ddd6a 100644 --- a/Mage/src/main/java/mage/abilities/common/BlocksOrBecomesBlockedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/BlocksOrBecomesBlockedTriggeredAbility.java @@ -48,7 +48,7 @@ public class BlocksOrBecomesBlockedTriggeredAbility extends TriggeredAbilityImpl protected boolean setTargetPointer; public BlocksOrBecomesBlockedTriggeredAbility(Effect effect, boolean optional) { - this(effect, new FilterCreaturePermanent(), optional, null, false); + this(effect, new FilterCreaturePermanent(), optional, null, true); } public BlocksOrBecomesBlockedTriggeredAbility(Effect effect, FilterPermanent filter, boolean optional) {