adjust CardsLeftGraveyardWatcher

related to #10550
This commit is contained in:
xenohedron 2024-01-26 20:12:07 -05:00
parent f35e00463d
commit 473d899bf6
2 changed files with 35 additions and 2 deletions

View file

@ -45,6 +45,35 @@ public class SyrixCarrierOfTheFlameTest extends CardTestPlayerBase {
}
@Test
public void testDamageTriggerOpponentSource() {
String cremate = "Cremate"; // {B} Exile target card from a graveyard. Draw a card.
addCard(Zone.BATTLEFIELD, playerA, syrix);
addCard(Zone.BATTLEFIELD, playerA, phoenix);
addCard(Zone.GRAVEYARD, playerA, historian);
addCard(Zone.BATTLEFIELD, playerB, "Swamp");
addCard(Zone.HAND, playerB, cremate);
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, cremate, historian);
checkExileCount("exiled", 2, PhaseStep.POSTCOMBAT_MAIN, playerA, historian, 1);
checkLife("before trigger", 2, PhaseStep.POSTCOMBAT_MAIN, playerA, 20);
checkLife("before trigger", 2, PhaseStep.POSTCOMBAT_MAIN, playerB, 20);
addTarget(playerA, phoenix); // target Phoenix
addTarget(playerA, playerB); // deals damage
setStrictChooseMode(true);
setStopAt(3, PhaseStep.UPKEEP);
execute();
assertLife(playerA, 20);
assertLife(playerB, 16);
assertPowerToughness(playerA, syrix, 3, 3);
assertPowerToughness(playerA, phoenix, 4, 2);
}
@Ignore("Usable zone issue, see #10550")
@Test
public void testCast() {

View file

@ -29,8 +29,12 @@ public class CardsLeftGraveyardWatcher extends Watcher {
|| ((ZoneChangeEvent) event).getFromZone() != Zone.GRAVEYARD) {
return;
}
UUID playerId = event.getPlayerId();
if (playerId == null || game.getCard(event.getTargetId()) == null) {
Card card = game.getCard(event.getTargetId());
if (card == null) {
return;
}
UUID playerId = card.getOwnerId();
if (playerId == null) {
return;
}
cardsLeftGraveyardThisTurn.computeIfAbsent(playerId, k -> new HashSet<>())