From 04176350dbe66098ccf4a3e301ae785f8aeedcd7 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 23 Jul 2020 11:52:09 +0200 Subject: [PATCH] * Pyromancer's Gauntlet - Fixed that the effect was applied to all damage of planeswalker not only to planeswalker of the Gauntlets's controller (fixes #6877). --- .../src/mage/cards/p/PyromancersGauntlet.java | 16 ++- .../mage/cards/t/TorbranThaneOfRedFell.java | 5 +- .../test/java/PyromancersGauntletTest.java | 117 ++++++++++++++++++ .../single/eld/TorbranThaneOfRedFellTest.java | 114 +++++++++++++++++ 4 files changed, 240 insertions(+), 12 deletions(-) create mode 100644 Mage.Tests/src/test/java/PyromancersGauntletTest.java create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/eld/TorbranThaneOfRedFellTest.java diff --git a/Mage.Sets/src/mage/cards/p/PyromancersGauntlet.java b/Mage.Sets/src/mage/cards/p/PyromancersGauntlet.java index 6c6c1c9b4c..4e56c86f57 100644 --- a/Mage.Sets/src/mage/cards/p/PyromancersGauntlet.java +++ b/Mage.Sets/src/mage/cards/p/PyromancersGauntlet.java @@ -1,4 +1,3 @@ - package mage.cards.p; import java.util.UUID; @@ -25,7 +24,7 @@ import mage.util.CardUtil; public final class PyromancersGauntlet extends CardImpl { public PyromancersGauntlet(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{5}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{5}"); // If a red instant or sorcery spell you control or a red planeswalker you control would deal damage to a permanent or player, it deals that much damage plus 2 to that permanent or player instead. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PyromancersGauntletReplacementEffect())); @@ -58,22 +57,21 @@ class PyromancersGauntletReplacementEffect extends ReplacementEffectImpl { || event.getType() == GameEvent.EventType.DAMAGE_CREATURE || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER; } - + @Override public boolean applies(GameEvent event, Ability source, Game game) { MageObject object = game.getObject(event.getSourceId()); if (object instanceof Spell) { if (((Spell) object).isControlledBy(source.getControllerId()) && (object.isInstant() - || object.isSorcery())){ + || object.isSorcery())) { return true; } } - Permanent permanent = game.getBattlefield().getPermanent(event.getSourceId()); - if(permanent != null && permanent.isPlaneswalker()){ - return true; - } - return false; + Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId()); + return permanent != null + && permanent.isPlaneswalker() + && source.isControlledBy(permanent.getControllerId()); } @Override diff --git a/Mage.Sets/src/mage/cards/t/TorbranThaneOfRedFell.java b/Mage.Sets/src/mage/cards/t/TorbranThaneOfRedFell.java index 3abdd57d62..7f0b09a09d 100644 --- a/Mage.Sets/src/mage/cards/t/TorbranThaneOfRedFell.java +++ b/Mage.Sets/src/mage/cards/t/TorbranThaneOfRedFell.java @@ -1,5 +1,6 @@ package mage.cards.t; +import java.util.UUID; import mage.MageInt; import mage.MageObject; import mage.abilities.Ability; @@ -14,8 +15,6 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.util.CardUtil; -import java.util.UUID; - /** * @author TheElk801 */ @@ -30,7 +29,7 @@ public final class TorbranThaneOfRedFell extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(4); - // If a red source you control would deal damage to an opponent or a + // If a red source you control would deal damage to an opponent or a // permanent an opponent controls, it deals that much damage plus 2 instead. this.addAbility(new SimpleStaticAbility(new TorbranThaneOfRedFellEffect())); } diff --git a/Mage.Tests/src/test/java/PyromancersGauntletTest.java b/Mage.Tests/src/test/java/PyromancersGauntletTest.java new file mode 100644 index 0000000000..6e0c6569b8 --- /dev/null +++ b/Mage.Tests/src/test/java/PyromancersGauntletTest.java @@ -0,0 +1,117 @@ + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.game.GameException; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class PyromancersGauntletTest extends CardTestPlayerBase { + + @Test + public void basicTest() { + setStrictChooseMode(true); + + addCard(Zone.HAND, playerA, "Lightning Bolt", 2); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); + + // If a red instant or sorcery spell you control or a red planeswalker you control + // would deal damage to a permanent or player, it deals that much damage plus 2 to that permanent or player instead. + addCard(Zone.BATTLEFIELD, playerA, "Pyromancer's Gauntlet"); // Artifact {5} + + addCard(Zone.BATTLEFIELD, playerB, "Pillarfield Ox"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Pillarfield Ox"); + + setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 20); + assertLife(playerB, 15); // Bolt 3 + 2 + + assertGraveyardCount(playerA, "Lightning Bolt", 2); + assertGraveyardCount(playerB, "Pillarfield Ox", 1); + } + + @Test + public void opponentsPyromancersGauntletAppliedToOwnPlaneswalkerTest() { + setStrictChooseMode(true); + + // +1: Elementals you control get +2/+0 until end of turn. + // −1: Add {R}{R}. + // −2: Chandra, Novice Pyromancer deals 2 damage to any target. + addCard(Zone.BATTLEFIELD, playerA, "Chandra, Novice Pyromancer"); // Planeswalker (5) {3}{R} + + // If a red instant or sorcery spell you control or a red planeswalker you control + // would deal damage to a permanent or player, it deals that much damage plus 2 to that permanent or player instead. + addCard(Zone.BATTLEFIELD, playerB, "Pyromancer's Gauntlet"); // Creature 2/4 {1}{R}{R}{R} + addCard(Zone.BATTLEFIELD, playerB, "Chandra, Novice Pyromancer"); // Planeswalker (5) {3}{R} + + addCard(Zone.BATTLEFIELD, playerB, "Barbarian Horde"); // Creature 3/3 {3}{R} + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "-2:", playerB); + + attack(2, playerB, "Barbarian Horde"); + activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "-2:", playerA); + + activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "-2:", "Barbarian Horde"); + + setStopAt(3, PhaseStep.BEGIN_COMBAT); + + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 13); // Attack from Horde 3 + Dmage 2+2 from planeswalker + assertLife(playerB, 18); // Damage from planeswalker 2 + + assertPermanentCount(playerB, "Barbarian Horde", 1); + + assertCounterCount(playerA, "Chandra, Novice Pyromancer", CounterType.LOYALTY, 1); + assertCounterCount(playerB, "Chandra, Novice Pyromancer", CounterType.LOYALTY, 3); + } + + @Test + public void with3PlayersTest() throws GameException { + playerC = createPlayer(currentGame, playerC, "PlayerC"); + + setStrictChooseMode(true); + + // +1: Elementals you control get +2/+0 until end of turn. + // −1: Add {R}{R}. + // −2: Chandra, Novice Pyromancer deals 2 damage to any target. + addCard(Zone.BATTLEFIELD, playerA, "Chandra, Novice Pyromancer"); // Planeswalker (5) {3}{R} + + // If a red instant or sorcery spell you control or a red planeswalker you control + // would deal damage to a permanent or player, it deals that much damage plus 2 to that permanent or player instead. + addCard(Zone.BATTLEFIELD, playerC, "Pyromancer's Gauntlet"); // Creature 2/4 {1}{R}{R}{R} + addCard(Zone.BATTLEFIELD, playerB, "Chandra, Novice Pyromancer"); // Planeswalker (5) {3}{R} + + addCard(Zone.BATTLEFIELD, playerB, "Barbarian Horde"); // Creature 3/3 {3}{R} + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "-2:", playerB); + + attack(3, playerB, "Barbarian Horde"); + activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerB, "-2:", playerA); + + activateAbility(4, PhaseStep.PRECOMBAT_MAIN, playerA, "-2:", "Barbarian Horde"); + + setStopAt(4, PhaseStep.BEGIN_COMBAT); + + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 15); // Attack from Horde 3 + Dmage 2 from planeswalker + assertLife(playerB, 18); // Damage from planeswalker 2 + assertLife(playerC, 20); + assertPermanentCount(playerB, "Barbarian Horde", 1); + + assertCounterCount(playerA, "Chandra, Novice Pyromancer", CounterType.LOYALTY, 1); + assertCounterCount(playerB, "Chandra, Novice Pyromancer", CounterType.LOYALTY, 3); + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/eld/TorbranThaneOfRedFellTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/eld/TorbranThaneOfRedFellTest.java new file mode 100644 index 0000000000..161b30c8bb --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/eld/TorbranThaneOfRedFellTest.java @@ -0,0 +1,114 @@ +package org.mage.test.cards.single.eld; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.game.GameException; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class TorbranThaneOfRedFellTest extends CardTestPlayerBase { + + @Test + public void basicTest() { + setStrictChooseMode(true); + + addCard(Zone.HAND, playerA, "Lightning Bolt", 2); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); + // If a red source you control would deal damage to an opponent or a permanent an opponent controls, + // it deals that much damage plus 2 instead. + addCard(Zone.BATTLEFIELD, playerA, "Torbran, Thane of Red Fell"); // Creature 2/4 {1}{R}{R}{R} + + addCard(Zone.BATTLEFIELD, playerB, "Pillarfield Ox"); + + attack(1, playerA, "Torbran, Thane of Red Fell"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Pillarfield Ox"); + + setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 20); + assertLife(playerB, 11); // damage from: attack 2 + 2 Bolt 3 + 2 + + assertGraveyardCount(playerA, "Lightning Bolt", 2); + assertGraveyardCount(playerB, "Pillarfield Ox", 1); + } + + @Test + public void opponentsTornbanAppliedToOwnPlaneswalkerTest() { + setStrictChooseMode(true); + + // +1: Elementals you control get +2/+0 until end of turn. + // −1: Add {R}{R}. + // −2: Chandra, Novice Pyromancer deals 2 damage to any target. + addCard(Zone.BATTLEFIELD, playerA, "Chandra, Novice Pyromancer"); // Planeswalker (5) {3}{R} + + // If a red source you control would deal damage to an opponent or a permanent an opponent controls, + // it deals that much damage plus 2 instead. + addCard(Zone.BATTLEFIELD, playerB, "Torbran, Thane of Red Fell"); // Creature 2/4 {1}{R}{R}{R} + + addCard(Zone.BATTLEFIELD, playerB, "Barbarian Horde"); // Creature 3/3 {3}{R} + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "-2:", playerB); + + attack(2, playerB, "Barbarian Horde"); + + activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "-2:", "Barbarian Horde"); + + setStopAt(3, PhaseStep.BEGIN_COMBAT); + + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 15); // Attack from Horde 3+2 + assertLife(playerB, 18); // Damage from planeswalker 2 + + assertPermanentCount(playerB, "Barbarian Horde", 1); + + assertCounterCount("Chandra, Novice Pyromancer", CounterType.LOYALTY, 1); + } + + @Test + public void with3PlayersTest() throws GameException { + playerC = createPlayer(currentGame, playerC, "PlayerC"); + setStrictChooseMode(true); + + // +1: Elementals you control get +2/+0 until end of turn. + // −1: Add {R}{R}. + // −2: Chandra, Novice Pyromancer deals 2 damage to any target. + addCard(Zone.BATTLEFIELD, playerA, "Chandra, Novice Pyromancer"); // Planeswalker (5) {3}{R} + + // If a red source you control would deal damage to an opponent or a permanent an opponent controls, + // it deals that much damage plus 2 instead. + addCard(Zone.BATTLEFIELD, playerC, "Torbran, Thane of Red Fell"); // Creature 2/4 {1}{R}{R}{R} + + addCard(Zone.BATTLEFIELD, playerB, "Barbarian Horde"); // Creature 3/3 {3}{R} + addCard(Zone.BATTLEFIELD, playerB, "Chandra, Novice Pyromancer"); // Planeswalker (5) {3}{R} + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "-2:", playerB); + + attack(3, playerB, "Barbarian Horde", playerA); + activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerB, "-2:", playerA); + + activateAbility(4, PhaseStep.PRECOMBAT_MAIN, playerA, "-2:", "Barbarian Horde"); + + setStopAt(4, PhaseStep.BEGIN_COMBAT); + + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 15); // Attack from Horde 3+2 + assertLife(playerB, 18); // Damage from planeswalker 2 + + assertPermanentCount(playerB, "Barbarian Horde", 1); + + assertCounterCount(playerA, "Chandra, Novice Pyromancer", CounterType.LOYALTY, 1); + assertCounterCount(playerB, "Chandra, Novice Pyromancer", CounterType.LOYALTY, 3); + } +}