mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
tests: added wrong commands order check
This commit is contained in:
parent
de34a98208
commit
9816ec7c26
4 changed files with 28 additions and 3 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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 + ")");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue