* Devour abilities - fixed that it doesn't trigger simultaneous events after multiple permanents sacrifice (#6254, #6273)

This commit is contained in:
Oleg Agafonov 2020-06-19 21:52:31 +04:00
parent da52fc430c
commit 85083a4433
2 changed files with 32 additions and 13 deletions

View file

@ -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);
}
}

View file

@ -88,19 +88,19 @@ public class DevourEffect extends ReplacementEffectImpl {
controller.chooseTarget(Outcome.Detriment, target, source, game);
if (!target.getTargets().isEmpty()) {
List<SubTypeList> 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;