diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/cost/sacrifice/MomentousFallTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/cost/sacrifice/MomentousFallTest.java index 8fa9d92d75..b7be3260b5 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/cost/sacrifice/MomentousFallTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/cost/sacrifice/MomentousFallTest.java @@ -2,6 +2,7 @@ package org.mage.test.cards.cost.sacrifice; import mage.constants.PhaseStep; import mage.constants.Zone; +import mage.counters.CounterType; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -39,6 +40,7 @@ public class MomentousFallTest extends CardTestPlayerBase { execute(); assertPermanentCount(playerA, "Geralf's Messenger", 1); + assertCounterCount("Geralf's Messenger", CounterType.P1P1, 1); assertPowerToughness(playerA, "Geralf's Messenger", 5, 4); // +1/+1 counter + Anthem effect assertHandCount(playerA, 4); // +4 cards assertLife(playerA, 23); // +3 life diff --git a/Mage/src/mage/abilities/keyword/UndyingAbility.java b/Mage/src/mage/abilities/keyword/UndyingAbility.java index 0fa2100676..e5aad5a8e7 100644 --- a/Mage/src/mage/abilities/keyword/UndyingAbility.java +++ b/Mage/src/mage/abilities/keyword/UndyingAbility.java @@ -1,5 +1,6 @@ package mage.abilities.keyword; + import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.DiesTriggeredAbility; @@ -13,6 +14,7 @@ import mage.counters.CounterType; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; +import org.apache.log4j.Logger; /** * @author Loki @@ -38,6 +40,7 @@ public class UndyingAbility extends DiesTriggeredAbility { if (super.checkTrigger(event, game)) { Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); if (!permanent.getCounters().containsKey(CounterType.P1P1) || permanent.getCounters().getCount(CounterType.P1P1) == 0) { + Logger.getLogger(UndyingAbility.class).info("Undying trigger: " + getSourceId()); game.getState().setValue("undying" + getSourceId(),permanent.getId()); return true; } @@ -95,6 +98,7 @@ class UndyingReplacementEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null) { + game.getState().setValue("undying" + source.getSourceId(), null); permanent.addCounters(CounterType.P1P1.createInstance(), game); } used = true; @@ -110,9 +114,10 @@ class UndyingReplacementEffect extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { if (event.getTargetId().equals(source.getSourceId())) { // Check if undying condition is true - UUID target = (UUID) game.getState().getValue("undying" + source.getSourceId()); - if (target.equals(source.getSourceId())) { - game.getState().setValue("undying" + source.getSourceId(), null); + UUID targetId = (UUID) game.getState().getValue("undying" + source.getSourceId()); + Logger.getLogger(UndyingReplacementEffect.class).info("Undying replacement applies: " + targetId + " eventSourceId " + event.getTargetId()); + + if (targetId != null && targetId.equals(source.getSourceId())) { return true; } }