Triggered abilities - fixed that sacrice trigger doesn't work on itself (related to #13089, regression from #13088)

This commit is contained in:
Oleg Agafonov 2024-12-14 16:59:20 +04:00
parent b855434a24
commit ea0b0915a5
3 changed files with 53 additions and 3 deletions

View file

@ -413,9 +413,9 @@ public class SacrificeDiesTriggerTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Silvercoat Lion", 1); assertPermanentCount(playerA, "Silvercoat Lion", 1);
} }
// bug #9688
@Test @Test
public void testIndustrialAdvancement() { public void test_IndustrialAdvancement() {
// bug #9688
skipInitShuffling(); skipInitShuffling();
addCard(Zone.BATTLEFIELD, playerA, "Industrial Advancement"); addCard(Zone.BATTLEFIELD, playerA, "Industrial Advancement");
// At the beginning of your end step, you may sacrifice a creature. If you do, look at the top X cards of your // At the beginning of your end step, you may sacrifice a creature. If you do, look at the top X cards of your
@ -438,7 +438,55 @@ public class SacrificeDiesTriggerTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Lone Missionary", 1); assertPermanentCount(playerA, "Lone Missionary", 1);
assertGraveyardCount(playerA, "Guardian Automaton", 1); assertGraveyardCount(playerA, "Guardian Automaton", 1);
assertLife(playerA, 27); assertLife(playerA, 27);
} }
@Test
public void test_SavraQueenOfTheGolgari_SacrificeAnother() {
// Whenever you sacrifice a black creature, you may pay 2 life. If you do, each other player sacrifices a creature.
// Whenever you sacrifice a green creature, you may gain 2 life.
addCard(Zone.BATTLEFIELD, playerA, "Savra, Queen of the Golgari"); // {2}{B}{G}
//
// {2}, {T}, Sacrifice a creature: Draw a card.
addCard(Zone.BATTLEFIELD, playerA, "Phyrexian Vault", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
//
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears");
// sacrifice another creature
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}, {T}, Sacrifice");
setChoice(playerA, "Grizzly Bears"); // to sacrifice
setChoice(playerA, true); // use gain life
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertLife(playerA, 20 + 2); // from green trigger
}
@Test
public void test_SavraQueenOfTheGolgari_SacrificeItself() {
// make sure it works on itself, bug #13089
// Whenever you sacrifice a black creature, you may pay 2 life. If you do, each other player sacrifices a creature.
// Whenever you sacrifice a green creature, you may gain 2 life.
addCard(Zone.BATTLEFIELD, playerA, "Savra, Queen of the Golgari"); // {2}{B}{G}
//
// {2}, {T}, Sacrifice a creature: Draw a card.
addCard(Zone.BATTLEFIELD, playerA, "Phyrexian Vault", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
// sacrifice itself (must catch x2 triggers from savra)
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}, {T}, Sacrifice");
setChoice(playerA, "Savra, Queen of the Golgari");
setChoice(playerA, "Whenever you sacrifice a black creature"); // x2 triggers order from savra
setChoice(playerA, true); // use gain life from green trigger
setChoice(playerA, false); // ignore black trigger
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertLife(playerA, 20 + 2); // from green trigger
}
} }

View file

@ -1284,6 +1284,7 @@ public abstract class AbilityImpl implements Ability {
switch (e.getType()) { switch (e.getType()) {
case DESTROYED_PERMANENT: case DESTROYED_PERMANENT:
case EXPLOITED_CREATURE: case EXPLOITED_CREATURE:
case SACRIFICED_PERMANENT:
return true; return true;
case ZONE_CHANGE: case ZONE_CHANGE:
return ((ZoneChangeEvent) e).getFromZone() == Zone.BATTLEFIELD; return ((ZoneChangeEvent) e).getFromZone() == Zone.BATTLEFIELD;

View file

@ -395,6 +395,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
break; break;
case DESTROYED_PERMANENT: case DESTROYED_PERMANENT:
case EXPLOITED_CREATURE: case EXPLOITED_CREATURE:
case SACRIFICED_PERMANENT:
if (isLeavesTheBattlefieldTrigger() && game.checkShortLivingLKI(affectedSourceId, Zone.BATTLEFIELD)) { if (isLeavesTheBattlefieldTrigger() && game.checkShortLivingLKI(affectedSourceId, Zone.BATTLEFIELD)) {
affectedSourceObject = game.getPermanentOrLKIBattlefield(affectedSourceId); affectedSourceObject = game.getPermanentOrLKIBattlefield(affectedSourceId);
} }