diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/ZulaportCutthroatTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/ZulaportCutthroatTest.java index c7a050b85e..dc91f4ae4f 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/ZulaportCutthroatTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/ZulaportCutthroatTest.java @@ -1,4 +1,3 @@ - package org.mage.test.cards.triggers.dies; import mage.constants.PhaseStep; @@ -7,7 +6,6 @@ import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; /** - * * @author LevelX2 */ public class ZulaportCutthroatTest extends CardTestPlayerBase { @@ -16,7 +14,6 @@ public class ZulaportCutthroatTest extends CardTestPlayerBase { * Zulaport's ability doesn't trigger when it dies. I'm not sure if that's * always the case, but I've encountered that bug at least several times * today. - * */ @Test public void testDiesAndControllerDamage() { @@ -40,4 +37,26 @@ public class ZulaportCutthroatTest extends CardTestPlayerBase { } + @Test + public void testTriggersWhenDevoured() { + // Whenever Zulaport Cutthroat or another creature you control dies, each opponent loses 1 life and you gain 1 life. + addCard(Zone.BATTLEFIELD, playerA, "Zulaport Cutthroat", 1); // 1/1 + addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 1); // 2/2 + addCard(Zone.BATTLEFIELD, playerA, "Forest", 3); + // Devour 1 + addCard(Zone.HAND, playerA, "Gluttonous Slime"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Gluttonous Slime"); + setChoice(playerA, "Yes"); // Devour + addTarget(playerA, "Zulaport Cutthroat^Grizzly Bears"); + setChoice(playerA, "Whenever {this}"); // Two triggers + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 22); + assertLife(playerB, 18); + } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DevourEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DevourEffect.java index d2d8a6a7d2..553bf2b6c1 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DevourEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DevourEffect.java @@ -88,19 +88,19 @@ public class DevourEffect extends ReplacementEffectImpl { controller.chooseTarget(Outcome.Detriment, target, source, game); if (!target.getTargets().isEmpty()) { List cardSubtypes = new ArrayList<>(); - int devouredCreatures = target.getTargets().size(); + int devouredCreatures = 0; + for (UUID targetId : target.getTargets()) { + Permanent targetCreature = game.getPermanent(targetId); + if (targetCreature != null && targetCreature.sacrifice(source.getSourceId(), game)) { + cardSubtypes.add(targetCreature.getSubtype(game)); + devouredCreatures++; + } + } if (!game.isSimulation()) { game.informPlayers(creature.getLogName() + " devours " + devouredCreatures + " creatures"); } - for (UUID targetId : target.getTargets()) { - Permanent targetCreature = game.getPermanent(targetId); - if (targetCreature != null) { - cardSubtypes.add(targetCreature.getSubtype(game)); - } - if (targetCreature == null || !targetCreature.sacrifice(source.getSourceId(), game)) { - return false; - } - } + game.getState().processAction(game); // need for multistep effects + int amountCounters; if (devourFactor == DevourFactor.DevourX) { amountCounters = devouredCreatures * devouredCreatures;