tests: added wrong commands order check

This commit is contained in:
Oleg Agafonov 2024-12-07 22:38:43 +04:00
parent de34a98208
commit 9816ec7c26
4 changed files with 28 additions and 3 deletions

View file

@ -86,7 +86,7 @@ public class PrimalPrayersTest extends CardTestPlayerBase {
setChoice(playerA, "Cast with alternative cost: Pay {E}"); // alternative cost chosen
checkPlayableAbility("no more energy to cast third Bears", 1, PhaseStep.BEGIN_COMBAT, playerA,
"Cast Grizzly Bears", false);
runCode("3: energy counter is 0", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> checkEnergyCount(info, player, 0));
runCode("3: energy counter is 0", 1, PhaseStep.BEGIN_COMBAT, playerA, (info, player, game) -> checkEnergyCount(info, player, 0));
setStopAt(1, PhaseStep.END_COMBAT);
execute();

View file

@ -102,10 +102,11 @@ public class BloodCultistTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Blood Cultist");
activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: {this} deals", "Devilthorn Fox");
activateAbility(5, PhaseStep.POSTCOMBAT_MAIN, playerA, "{T}: {this} deals", "Shambling Ghoul");
attack(5, playerA, "Silvercoat Lion");
block(5, playerB, "Shambling Ghoul", "Silvercoat Lion");
activateAbility(5, PhaseStep.POSTCOMBAT_MAIN, playerA, "{T}: {this} deals", "Shambling Ghoul");
setStrictChooseMode(true);
setStopAt(5, PhaseStep.END_TURN);
execute();

View file

@ -57,6 +57,8 @@ public class PlayerAction {
@Override
public String toString() {
return "T" + this.turnNum + "." + this.step.getStepShortText() + ": " + this.action;
return "T" + this.turnNum + "." + this.step.getStepShortText()
+ ": " + this.action
+ (this.actionName.isEmpty() ? "" : " (" + this.actionName + ")");
}
}

View file

@ -262,6 +262,28 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
+ " (found actions after stop on " + maxTurn + " / " + maxPhase + ")",
(maxTurn > this.stopOnTurn) || (maxTurn == this.stopOnTurn && maxPhase > this.stopAtStep.getIndex()));
// check commands order
for (Player player : currentGame.getPlayers().values()) {
if (true) break; // TODO: delete/comment and fix all failed tests
if (player instanceof TestPlayer) {
TestPlayer testPlayer = (TestPlayer) player;
int lastActionIndex = 0;
PlayerAction lastAction = null;
for (PlayerAction currentAction : testPlayer.getActions()) {
int currentActionIndex = 1000 * currentAction.getTurnNum() + currentAction.getStep().getIndex();
if (currentActionIndex < lastActionIndex) {
// how-to fix: find typo in step/turn number
Assert.fail("Found wrong commands order for " + testPlayer.getName() + ":" + "\n"
+ lastAction + "\n"
+ currentAction);
} else {
lastActionIndex = currentActionIndex;
lastAction = currentAction;
}
}
}
}
if (!currentGame.isPaused()) {
// workaround to fill range info (cause real range fills after game start, but some cheated cards needs range on ETB)
for (Player player : currentGame.getPlayers().values()) {