mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Devour abilities - fixed that it doesn't trigger simultaneous events after multiple permanents sacrifice (#6254, #6273)
This commit is contained in:
parent
da52fc430c
commit
85083a4433
2 changed files with 32 additions and 13 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue