* Added some tests for restoring objects after rollback.

This commit is contained in:
LevelX2 2020-06-27 10:47:27 +02:00
parent aeec6a4e8d
commit 81d0442ba1

View file

@ -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.
// FlashbackTap 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);
}
}