From 81d0442ba135a0293d5466f39db17d0e0403a145 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 27 Jun 2020 10:47:27 +0200 Subject: [PATCH] * Added some tests for restoring objects after rollback. --- .../mage/test/rollback/StateValuesTest.java | 80 ++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/rollback/StateValuesTest.java b/Mage.Tests/src/test/java/org/mage/test/rollback/StateValuesTest.java index 0ec79277b6..c751d8799e 100644 --- a/Mage.Tests/src/test/java/org/mage/test/rollback/StateValuesTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/rollback/StateValuesTest.java @@ -1,6 +1,7 @@ - package org.mage.test.rollback; +import mage.abilities.keyword.FirstStrikeAbility; +import mage.abilities.keyword.FlyingAbility; import mage.constants.PhaseStep; import mage.constants.Zone; import org.junit.Test; @@ -65,4 +66,81 @@ public class StateValuesTest extends CardTestPlayerBase { assertPermanentCount(playerA, "Clue", 2); } + + @Test + public void rollbackTokenCreationTest() { + // Create two 1/1 white Bird creature tokens with flying. + // Flashback—Tap three untapped white creatures you control. (You may cast this card from your graveyard for its flashback cost. Then exile it.) + addCard(Zone.LIBRARY, playerA, "Battle Screech", 1); // Sorcery {2}{W}{W} + skipInitShuffling(); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 4); + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1); + + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Battle Screech"); + + activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Flashback"); + setChoice(playerA, "Bird"); + setChoice(playerA, "Bird"); + setChoice(playerA, "Silvercoat Lion"); + + setStrictChooseMode(true); + setStopAt(3, PhaseStep.POSTCOMBAT_MAIN); + + execute(); + assertAllCommandsUsed(); + + // Before rollback + assertTappedCount("Plains", true, 4); + assertTappedCount("Bird", true, 2); + assertTappedCount("Silvercoat Lion", true, 1); + assertPermanentCount(playerA, "Bird", 4); + assertHandCount(playerA, 0); + assertExileCount(playerA, "Battle Screech", 1); + + currentGame.rollbackTurns(2); + + // After rollback to turn 1 + assertTappedCount("Plains", true, 0); + assertTappedCount("Silvercoat Lion", true, 0); + assertPermanentCount(playerA, "Bird", 0); + assertLibraryCount(playerA, "Battle Screech", 1); + assertHandCount(playerA, 0); + } + + @Test + public void rollbackBuffUntilEndOfTurnTest() { + // Target creature gets +1/+1 and gains flying and first strike until end of turn. + addCard(Zone.LIBRARY, playerA, "Aerial Maneuver", 1); // Instant {1}{W} + skipInitShuffling(); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 2); + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1); + + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Aerial Maneuver", "Silvercoat Lion"); + + setStrictChooseMode(true); + setStopAt(3, PhaseStep.BEGIN_COMBAT); + + execute(); + assertAllCommandsUsed(); + + // Before rollback + assertTappedCount("Plains", true, 2); + assertPermanentCount(playerA, "Silvercoat Lion", 1); + assertPowerToughness(playerA, "Silvercoat Lion", 3, 3); + assertAbility(playerA, "Silvercoat Lion", FlyingAbility.getInstance(), true); + assertAbility(playerA, "Silvercoat Lion", FirstStrikeAbility.getInstance(), true); + assertHandCount(playerA, 0); + assertGraveyardCount(playerA, "Aerial Maneuver", 1); + + currentGame.rollbackTurns(0); + + // After rollback to begin turn 3 + assertTappedCount("Plains", true, 0); + assertPermanentCount(playerA, "Silvercoat Lion", 1); + assertPowerToughness(playerA, "Silvercoat Lion", 2, 2); + assertAbility(playerA, "Silvercoat Lion", FlyingAbility.getInstance(), false); + assertAbility(playerA, "Silvercoat Lion", FirstStrikeAbility.getInstance(), false); + assertLibraryCount(playerA, "Aerial Maneuver", 1); + assertHandCount(playerA, 0); + } }