Fix Haunt ability to trigger on haunted tokens dying (#7689, #10308); add test (#10310)

This commit is contained in:
xenohedron 2023-05-07 13:31:23 -04:00 committed by GitHub
parent 35bb7d513b
commit 3e5b392287
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 5 deletions

View file

@ -47,6 +47,7 @@ public class HauntTest extends CardTestPlayerBase {
for (String rule : card.getRules(currentGame)) { for (String rule : card.getRules(currentGame)) {
if (rule.startsWith("Haunting") && rule.contains("Goblin Roughrider")) { if (rule.startsWith("Haunting") && rule.contains("Goblin Roughrider")) {
found = true; found = true;
break;
} }
} }
} }
@ -57,8 +58,9 @@ public class HauntTest extends CardTestPlayerBase {
for (Card card : currentGame.getBattlefield().getAllActivePermanents()) { for (Card card : currentGame.getBattlefield().getAllActivePermanents()) {
if (card.getName().equals("Goblin Roughrider")) { if (card.getName().equals("Goblin Roughrider")) {
for (String rule : card.getRules(currentGame)) { for (String rule : card.getRules(currentGame)) {
if (rule.startsWith("Haunted by") && rule.contains("Blind Hunter")) { if (rule.startsWith("Haunted by") && rule.contains("Blind Hunter")) {
found = true; found = true;
break;
} }
} }
} }
@ -85,14 +87,15 @@ public class HauntTest extends CardTestPlayerBase {
assertGraveyardCount(playerA, "Lightning Bolt", 2); assertGraveyardCount(playerA, "Lightning Bolt", 2);
assertExileCount("Blind Hunter", 1); assertExileCount("Blind Hunter", 1);
assertGraveyardCount(playerA, "Goblin Roughrider", 1); assertGraveyardCount(playerA, "Goblin Roughrider", 1);
assertLife(playerA, 22);
boolean found = false; boolean found = false;
for (Card card : currentGame.getPlayer(playerA.getId()).getGraveyard().getCards(currentGame)) { for (Card card : currentGame.getPlayer(playerA.getId()).getGraveyard().getCards(currentGame)) {
if (card.getName().equals("Goblin Roughrider")) { if (card.getName().equals("Goblin Roughrider")) {
for (String rule : card.getRules(currentGame)) { for (String rule : card.getRules(currentGame)) {
if (rule.startsWith("Haunted by") && rule.contains("Blind Hunter")) { if (rule.startsWith("Haunted by") && rule.contains("Blind Hunter")) {
found = true; found = true;
break;
} }
} }
} }
@ -100,5 +103,24 @@ public class HauntTest extends CardTestPlayerBase {
Assert.assertFalse("Found Haunted by rule text displayed for the card", found); Assert.assertFalse("Found Haunted by rule text displayed for the card", found);
} }
@Test
public void testHauntToken() {
addCard(Zone.BATTLEFIELD, playerA, "Blind Hunter");
addCard(Zone.HAND, playerA, "Satyr's Cunning");
addCard(Zone.HAND, playerA, "Lightning Bolt", 2);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Satyr's Cunning");
castSpell(1, PhaseStep.BEGIN_COMBAT, playerA, "Lightning Bolt", "Blind Hunter");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", "Satyr Token");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerA, "Lightning Bolt", 2);
assertExileCount("Blind Hunter", 1);
assertLife(playerA, 22);
}
} }

View file

@ -81,8 +81,7 @@ public class HauntAbility extends TriggeredAbilityImpl {
return false; return false;
} }
Card card = game.getCard(getSourceId()); Card card = game.getCard(getSourceId());
if (card == null if (card == null) {
|| game.getCard(event.getTargetId()) == null) {
return false; return false;
} }
String key = new StringBuilder("Haunting_") String key = new StringBuilder("Haunting_")