fixed interactions between effects which replace a token and effects which care about tokens after they've been made

This commit is contained in:
Evan Kranzler 2022-03-31 19:58:20 -04:00
parent 0540557455
commit 676c3a8bb4
2 changed files with 31 additions and 7 deletions

View file

@ -9,7 +9,6 @@ import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase; import org.mage.test.serverside.base.CardTestPlayerBase;
/** /**
*
* @author luziferius * @author luziferius
*/ */
public class DivineVisitationTest extends CardTestPlayerBase { public class DivineVisitationTest extends CardTestPlayerBase {
@ -74,8 +73,25 @@ public class DivineVisitationTest extends CardTestPlayerBase {
assertType("Angel Token", CardType.CREATURE, SubType.ANGEL); assertType("Angel Token", CardType.CREATURE, SubType.ANGEL);
assertColor(playerA, "Angel Token", ObjectColor.WHITE, true); assertColor(playerA, "Angel Token", ObjectColor.WHITE, true);
assertColor(playerA, "Angel Token", ObjectColor.RED, false); assertColor(playerA, "Angel Token", ObjectColor.RED, false);
assertPowerToughness(playerA, "Angel Token", 4,4); assertPowerToughness(playerA, "Angel Token", 4, 4);
assertNotSubtype("Angel Token", SubType.GOBLIN); assertNotSubtype("Angel Token", SubType.GOBLIN);
} }
@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);
}
} }

View file

@ -238,6 +238,14 @@ public abstract class TokenImpl extends MageObjectImpl implements Token {
} }
} }
putOntoBattlefieldHelper(event, game, source, tapped, attacking, attackedPlayer, created); 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 true;
} }
return false; return false;