From d94a2712baa8da5aa003c6d18a91a05faedc86ef Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 28 Nov 2015 12:52:13 +0100 Subject: [PATCH] * Fixed a bug that a dies ability did still trigger as the stack was not cleared meanwhile. --- .../triggers/dies/OmnathLocusOfRageTest.java | 29 +++++++++++++++++++ ...ThisOrAnotherCreatureTriggeredAbility.java | 6 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/OmnathLocusOfRageTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/OmnathLocusOfRageTest.java index f203603e532..4e95b114847 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/OmnathLocusOfRageTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/OmnathLocusOfRageTest.java @@ -66,4 +66,33 @@ public class OmnathLocusOfRageTest extends CardTestPlayerBase { } + @Test + public void testDiesTriggeredAbilityOnlyIfPresent() { + // Landfall - Whenever a land enters the battlefield under your control, put a 5/5 red and green Elemental creature token onto the battlefield. + // Whenever Omnath, Locus of Rage or another Elemental you control dies, Omnath deals 3 damage to target creature or player. + addCard(Zone.BATTLEFIELD, playerA, "Omnath, Locus of Rage", 1); + addCard(Zone.BATTLEFIELD, playerA, "Lightning Elemental", 1); // 4/1 Elemental - Haste + + // Blastfire Bolt deals 5 damage to target creature. Destroy all Equipment attached to that creature. + addCard(Zone.HAND, playerB, "Blastfire Bolt", 1); // {5}{R} + addCard(Zone.HAND, playerB, "Lightning Bolt", 1); // {R} + addCard(Zone.BATTLEFIELD, playerB, "Mountain", 7); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", "Lightning Elemental"); // Dying Lightning Elemental does no longer trigger ability of Omnath + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Blastfire Bolt", "Omnath, Locus of Rage", "Lightning Bolt"); + addTarget(playerA, playerB); + addTarget(playerA, playerB); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerB, "Lightning Bolt", 1); + assertGraveyardCount(playerB, "Blastfire Bolt", 1); + assertGraveyardCount(playerA, "Omnath, Locus of Rage", 1); + assertGraveyardCount(playerA, "Lightning Elemental", 1); + + assertLife(playerA, 20); + assertLife(playerB, 17); + + } } diff --git a/Mage/src/mage/abilities/common/DiesThisOrAnotherCreatureTriggeredAbility.java b/Mage/src/mage/abilities/common/DiesThisOrAnotherCreatureTriggeredAbility.java index e382ae91dd1..1ea17bda77d 100644 --- a/Mage/src/mage/abilities/common/DiesThisOrAnotherCreatureTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/DiesThisOrAnotherCreatureTriggeredAbility.java @@ -70,11 +70,13 @@ public class DiesThisOrAnotherCreatureTriggeredAbility extends TriggeredAbilityI @Override public boolean isInUseableZone(Game game, MageObject source, GameEvent event) { - Permanent sourcePermanent; + Permanent sourcePermanent = null; if (game.getState().getZone(getSourceId()) == Zone.BATTLEFIELD) { sourcePermanent = game.getPermanent(getSourceId()); } else { - sourcePermanent = (Permanent) game.getLastKnownInformation(getSourceId(), Zone.BATTLEFIELD); + if (game.getShortLivingLKI(sourceId, Zone.BATTLEFIELD)) { + sourcePermanent = (Permanent) game.getLastKnownInformation(getSourceId(), Zone.BATTLEFIELD); + } } if (sourcePermanent == null) { return false;