From 7d07c220b0d17ba29ea7aea08608a7d8a749d50a Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 10 Jun 2021 18:42:47 -0400 Subject: [PATCH] fixed while on stack effects of copied spells not discarding when copy has left stack --- Mage.Sets/src/mage/cards/m/MeddlingMage.java | 1 - .../cards/continuous/SplitSecondTest.java | 51 +++++++++++++++++++ Mage/src/main/java/mage/game/GameImpl.java | 9 ++-- 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/continuous/SplitSecondTest.java diff --git a/Mage.Sets/src/mage/cards/m/MeddlingMage.java b/Mage.Sets/src/mage/cards/m/MeddlingMage.java index 049fd87c83..fbe56650a4 100644 --- a/Mage.Sets/src/mage/cards/m/MeddlingMage.java +++ b/Mage.Sets/src/mage/cards/m/MeddlingMage.java @@ -87,7 +87,6 @@ class MeddlingMageReplacementEffect extends ContinuousRuleModifyingEffectImpl { MageObject object = game.getObject(event.getSourceId()); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); return object != null - && !object.isCopy() && CardUtil.haveSameNames(object, cardName, game); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/SplitSecondTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/SplitSecondTest.java new file mode 100644 index 0000000000..203cc9a621 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/SplitSecondTest.java @@ -0,0 +1,51 @@ +package org.mage.test.cards.continuous; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author TheElk801 + */ +public class SplitSecondTest extends CardTestPlayerBase { + + @Test + public void testCounterSpell() { + addCard(Zone.BATTLEFIELD, playerA, "Volcanic Island", 4); + addCard(Zone.HAND, playerA, "Sudden Shock"); + addCard(Zone.HAND, playerA, "Counterspell"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sudden Shock", playerB); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Counterspell", "Sudden Shock"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertHandCount(playerA, "Counterspell", 1); + assertGraveyardCount(playerA, "Sudden Shock", 1); + assertLife(playerB, 20 - 2); + } + + @Test + public void testCopiedSpell() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5); + addCard(Zone.HAND, playerA, "Doublecast"); + addCard(Zone.HAND, playerA, "Sudden Shock"); + addCard(Zone.HAND, playerA, "Raging Goblin"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Doublecast"); + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sudden Shock", playerB); + + // No split second spells are on the stack, effect should not apply anymore + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Raging Goblin"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertLife(playerB, 20 - 2 - 2); + assertPermanentCount(playerA, "Raging Goblin", 1); + } +} diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index c12d8fba34..8e22f67d90 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -1965,11 +1965,14 @@ public abstract class GameImpl implements Game, Serializable { // (Isochron Scepter) 12/1/2004: If you don't want to cast the copy, you can choose not to; the copy ceases // to exist the next time state-based actions are checked. Zone zone = state.getZone(copiedCard.getMainCard().getId()); - if (zone == Zone.BATTLEFIELD || zone == Zone.STACK) { - continue; - } // TODO: remember LKI of copied cards here after LKI rework switch (zone) { + case BATTLEFIELD: + continue; + case STACK: + if (getStack().getStackObject(copiedCard.getId()) != null) { + continue; + } case GRAVEYARD: for (Player player : getPlayers().values()) { if (player.getGraveyard().contains(copiedCard.getId())) {