From 676c3a8bb42d9043ba95debffe2fa32839a805e2 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 31 Mar 2022 19:58:20 -0400 Subject: [PATCH] fixed interactions between effects which replace a token and effects which care about tokens after they've been made --- .../cards/triggers/DivineVisitationTest.java | 30 ++++++++++++++----- .../mage/game/permanent/token/TokenImpl.java | 8 +++++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/DivineVisitationTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/DivineVisitationTest.java index 17cbbb0050..08cd6daa97 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/DivineVisitationTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/DivineVisitationTest.java @@ -9,7 +9,6 @@ import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; /** - * * @author luziferius */ public class DivineVisitationTest extends CardTestPlayerBase { @@ -35,11 +34,11 @@ public class DivineVisitationTest extends CardTestPlayerBase { setChoice(playerA, "Whenever an opponent draws a card", 2); // choose order of triggers setChoice(playerB, false, 3); // Decline to pay 2 setStopAt(1, PhaseStep.BEGIN_COMBAT); - + setStrictChooseMode(true); execute(); assertAllCommandsUsed(); - + assertHandCount(playerB, 3); assertPermanentCount(playerA, "Treasure Token", 3); assertType("Treasure Token", CardType.ARTIFACT, SubType.TREASURE); @@ -62,7 +61,7 @@ public class DivineVisitationTest extends CardTestPlayerBase { addCard(Zone.HAND, playerA, "Dragon Fodder"); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Dragon Fodder"); setStopAt(1, PhaseStep.BEGIN_COMBAT); - + setStrictChooseMode(true); execute(); assertAllCommandsUsed(); @@ -74,8 +73,25 @@ public class DivineVisitationTest extends CardTestPlayerBase { assertType("Angel Token", CardType.CREATURE, SubType.ANGEL); assertColor(playerA, "Angel Token", ObjectColor.WHITE, true); assertColor(playerA, "Angel Token", ObjectColor.RED, false); - assertPowerToughness(playerA, "Angel Token", 4,4); + assertPowerToughness(playerA, "Angel Token", 4, 4); assertNotSubtype("Angel Token", SubType.GOBLIN); - + } -} \ No newline at end of file + + @Test + public void testSacrificeEOT() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); + addCard(Zone.BATTLEFIELD, playerA, "Divine Visitation"); + addCard(Zone.HAND, playerA, "Thatcher Revolt"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Thatcher Revolt"); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerA, "Human Token", 0); + assertPermanentCount(playerA, "Angel Token", 0); + } +} diff --git a/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java b/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java index f7c2c15b15..6e72abd438 100644 --- a/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java +++ b/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java @@ -238,6 +238,14 @@ public abstract class TokenImpl extends MageObjectImpl implements Token { } } putOntoBattlefieldHelper(event, game, source, tapped, attacking, attackedPlayer, created); + event.getTokens() + .keySet() + .stream() + .map(Token::getLastAddedTokenIds) + .flatMap(Collection::stream) + .distinct() + .filter(uuid -> !this.lastAddedTokenIds.contains(uuid)) + .forEach(this.lastAddedTokenIds::add); return true; } return false;