Fixed missing watchers from DelayedTriggeredAbility:

* Planeswalkers Mischief - fixed rollback error on play;
* Psychic Theft - fixed rollback error on play;
This commit is contained in:
Oleg Agafonov 2020-07-25 19:00:59 +04:00
parent 32b7c592c8
commit 848c5b6052
6 changed files with 67 additions and 17 deletions

View file

@ -0,0 +1,43 @@
package org.mage.test.cards.watchers;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author JayDi85
*/
public class WatchersFromDelayedTriggeredAbilitiesTest extends CardTestPlayerBase {
@Test
public void test_PsychicTheft_WatcherFromDelayedAbility() {
// Target player reveals their hand. You choose an instant or sorcery card from it and exile that card.
// You may cast that card for as long as it remains exiled. At the beginning of the next end step,
// if you haven't cast the card, return it to its owner's hand.
addCard(Zone.HAND, playerA, "Psychic Theft", 1); // {1}{U}
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
//
addCard(Zone.HAND, playerB, "Lightning Bolt");
// reveal
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {U}", 2);
checkPlayableAbility("can't play bolt", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", false);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Psychic Theft", playerB);
setChoice(playerA, "Lightning Bolt");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
// can play until end step
checkPlayableAbility("can play bolt on 1", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", true);
checkPlayableAbility("can play bolt on 2", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", false);
setStrictChooseMode(true);
setStopAt(2, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertHandCount(playerB, "Lightning Bolt", 1);
}
}

View file

@ -1,14 +1,5 @@
package org.mage.test.serverside.base.impl;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import mage.MageObject;
import mage.Mana;
import mage.ObjectColor;
@ -44,6 +35,12 @@ import org.mage.test.player.TestPlayer;
import org.mage.test.serverside.base.CardTestAPI;
import org.mage.test.serverside.base.MageTestPlayerBase;
import java.io.FileNotFoundException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* API for test initialization and asserting the test results.
*
@ -202,7 +199,6 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
/**
*
* @throws GameException
* @throws FileNotFoundException
*/
@ -291,7 +287,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
}
Assert.assertFalse("Wrong stop command on " + this.stopOnTurn + " / " + this.stopAtStep + " (" + this.stopAtStep.getIndex() + ")"
+ " (found actions after stop on " + maxTurn + " / " + maxPhase + ")",
+ " (found actions after stop on " + maxTurn + " / " + maxPhase + ")",
(maxTurn > this.stopOnTurn) || (maxTurn == this.stopOnTurn && maxPhase > this.stopAtStep.getIndex()));
for (Player player : currentGame.getPlayers().values()) {
@ -533,6 +529,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* Removes all cards from player's library from the game. Usually this
* should be used once before initialization to form the library in certain
* order.
* <p>
* Warning, if you doesn't add cards to hand then player will lose the game on draw and test
* return unused actions (game ended too early)
*
* @param player {@link Player} to remove all library cards from.
*/