From e2066f41abb2753e518c255edc7e0f5d2fcbe76e Mon Sep 17 00:00:00 2001 From: Susucre <34709007+Susucre@users.noreply.github.com> Date: Sat, 8 Jun 2024 20:49:20 +0200 Subject: [PATCH] fix copy effect not being discarded early enough (#12434) --- .../single/mh3/ShiftingWoodlandTest.java | 33 +++++++++++++++++-- .../abilities/effects/common/CopyEffect.java | 6 +++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/mh3/ShiftingWoodlandTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/mh3/ShiftingWoodlandTest.java index 85c02d1c9d5..90b80d04a13 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/mh3/ShiftingWoodlandTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/mh3/ShiftingWoodlandTest.java @@ -6,7 +6,6 @@ import mage.constants.PhaseStep; import mage.constants.SubType; import mage.constants.Zone; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -71,7 +70,6 @@ public class ShiftingWoodlandTest extends CardTestPlayerBase { assertColor(playerA, woodland, "Green", false); } - @Ignore // CopyEffect is not discarded properly. See #12433 @Test public void test_Copy_StopOnLTB() { setStrictChooseMode(true); @@ -122,4 +120,35 @@ public class ShiftingWoodlandTest extends CardTestPlayerBase { assertLife(playerB, 20 - 2); assertGraveyardCount(playerA, woodland, 1); } + + @Test + public void test_Copy_StopOnLTB_DeathTrigger() { + setStrictChooseMode(true); + + addCard(Zone.BATTLEFIELD, playerA, "Yavimaya Coast", 4); // to be sure not to activate Woodland + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); + addCard(Zone.BATTLEFIELD, playerA, woodland); + addCard(Zone.BATTLEFIELD, playerA, "Blood Artist"); + addCard(Zone.HAND, playerA, "Shoot the Sheriff"); + addCard(Zone.GRAVEYARD, playerA, "Anodet Lurker"); // When Anodet Lurker dies, you gain 3 life + addCard(Zone.GRAVEYARD, playerA, "Plains"); + addCard(Zone.GRAVEYARD, playerA, "Memnite"); + addCard(Zone.GRAVEYARD, playerA, "Divination"); + + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}. {this} deals 1 damage to you.", 4); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Delirium — {2}{G}{G}:", "Anodet Lurker"); + + attack(1, playerA, "Anodet Lurker", playerB); + + castSpell(1, PhaseStep.END_COMBAT, playerA, "Shoot the Sheriff", "Anodet Lurker", true); + setChoice(playerA, "When {this} dies"); + addTarget(playerA, playerB); + + setStopAt(2, PhaseStep.UPKEEP); + execute(); + + assertLife(playerA, 20 - 4 + 3 + 1); + assertLife(playerB, 20 - 3 - 1); + assertGraveyardCount(playerA, woodland, 1); + } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/CopyEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CopyEffect.java index d7b721d877c..77006ad4ecd 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CopyEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CopyEffect.java @@ -81,8 +81,12 @@ public class CopyEffect extends ContinuousEffectImpl { } Permanent permanent = affectedObjectList.get(0).getPermanent(game); if (permanent == null) { + if (!game.getShortLivingLKI(getSourceId(), Zone.BATTLEFIELD)) { + discard(); + return false; + } + // As long as the permanent is still in the short living LKI continue to copy to get triggered abilities to TriggeredAbilities for dies events. permanent = (Permanent) game.getLastKnownInformation(getSourceId(), Zone.BATTLEFIELD, source.getSourceObjectZoneChangeCounter()); - // As long as the permanent is still in the LKI continue to copy to get triggered abilities to TriggeredAbilities for dies events. if (permanent == null) { discard(); return false;