diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/UndyingTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/UndyingTest.java index e162873305..5c694095e6 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/UndyingTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/UndyingTest.java @@ -27,6 +27,26 @@ public class UndyingTest extends CardTestPlayerBase { assertPowerToughness(playerA, "Geralf's Messenger", 4, 3); } + /** + * Tests boost weren't be applied second time when creature back to battlefield + */ + @Test + public void testWithMassBoost() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Strangleroot Geist"); + + addCard(Constants.Zone.BATTLEFIELD, playerB, "Swamp", 3); + addCard(Constants.Zone.HAND, playerB, "Cower in Fear"); + + castSpell(2, Constants.PhaseStep.PRECOMBAT_MAIN, playerB, "Cower in Fear"); + + setStopAt(2, Constants.PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Strangleroot Geist", 1); + // dies then returned with +1/+1 counter (and boost doesn't work anymore) + assertPowerToughness(playerA, "Strangleroot Geist", 3, 2); + } + /** * Tests "Target creature gains undying until end of turn" */ diff --git a/Mage/src/mage/abilities/effects/ContinuousEffect.java b/Mage/src/mage/abilities/effects/ContinuousEffect.java index 5d22ca0625..e9cfd8c4f1 100644 --- a/Mage/src/mage/abilities/effects/ContinuousEffect.java +++ b/Mage/src/mage/abilities/effects/ContinuousEffect.java @@ -35,6 +35,8 @@ import mage.abilities.Ability; import mage.game.Game; import java.util.Date; +import java.util.List; +import java.util.UUID; /** * @@ -55,4 +57,5 @@ public interface ContinuousEffect> extends Effect< public Layer getLayer(); public SubLayer getSublayer(); public void overrideRuleText(String text); + public List getAffectedObjects(); } diff --git a/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java b/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java index a58ee5103a..d50f9d0592 100644 --- a/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java +++ b/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java @@ -185,4 +185,8 @@ public abstract class ContinuousEffectImpl> ex return false; } + @Override + public List getAffectedObjects() { + return this.objects; + } } diff --git a/Mage/src/mage/game/permanent/PermanentCard.java b/Mage/src/mage/game/permanent/PermanentCard.java index dc552f78fb..2f75a9d2af 100644 --- a/Mage/src/mage/game/permanent/PermanentCard.java +++ b/Mage/src/mage/game/permanent/PermanentCard.java @@ -29,6 +29,7 @@ package mage.game.permanent; import mage.Constants.Zone; +import mage.abilities.effects.ContinuousEffect; import mage.cards.Card; import mage.cards.LevelerCard; import mage.game.Game; @@ -172,6 +173,13 @@ public class PermanentCard extends PermanentImpl { if (controller != null && controller.removeFromBattlefield(this, game)) { ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, controllerId, fromZone, toZone); if (!game.replaceEvent(event)) { + if (event.getFromZone().equals(Zone.BATTLEFIELD)) { + for (ContinuousEffect effect : game.getContinuousEffects().getLayeredEffects(game)) { + if (effect.getAffectedObjects().contains(getId())) { + effect.getAffectedObjects().remove(getId()); + } + } + } Player owner = game.getPlayer(ownerId); game.rememberLKI(objectId, Zone.BATTLEFIELD, this); if (owner != null) {