mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
Test framework: added realtime check for damage (checkDamage, #4936)
This commit is contained in:
parent
53341c5519
commit
e6823e4423
2 changed files with 20 additions and 1 deletions
|
|
@ -619,6 +619,13 @@ public class TestPlayer implements Player {
|
||||||
wasProccessed = true;
|
wasProccessed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check damage: card name, damage
|
||||||
|
if (params[0].equals(CHECK_COMMAND_DAMAGE) && params.length == 3) {
|
||||||
|
assertDamage(action, game, computerPlayer, params[1], Integer.parseInt(params[2]));
|
||||||
|
actions.remove(action);
|
||||||
|
wasProccessed = true;
|
||||||
|
}
|
||||||
|
|
||||||
// check life: life
|
// check life: life
|
||||||
if (params[0].equals(CHECK_COMMAND_LIFE) && params.length == 2) {
|
if (params[0].equals(CHECK_COMMAND_LIFE) && params.length == 2) {
|
||||||
assertLife(action, game, computerPlayer, Integer.parseInt(params[1]));
|
assertLife(action, game, computerPlayer, Integer.parseInt(params[1]));
|
||||||
|
|
@ -930,6 +937,12 @@ public class TestPlayer implements Player {
|
||||||
Toughness, perm.getToughness().getValue());
|
Toughness, perm.getToughness().getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assertDamage(PlayerAction action, Game game, Player player, String permanentName, int damage) {
|
||||||
|
Permanent perm = findPermanentWithAssert(action, game, player, permanentName);
|
||||||
|
|
||||||
|
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " have wrong damage: " + perm.getDamage() + " <> " + damage, damage, perm.getDamage());
|
||||||
|
}
|
||||||
|
|
||||||
private void assertLife(PlayerAction action, Game game, Player player, int Life) {
|
private void assertLife(PlayerAction action, Game game, Player player, int Life) {
|
||||||
Assert.assertEquals(action.getActionName() + " - " + player.getName() + " have wrong life: " + player.getLife() + " <> " + Life,
|
Assert.assertEquals(action.getActionName() + " - " + player.getName() + " have wrong life: " + player.getLife() + " <> " + Life,
|
||||||
Life, player.getLife());
|
Life, player.getLife());
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
|
|
||||||
// TODO: add target player param to commands
|
// TODO: add target player param to commands
|
||||||
public static final String CHECK_COMMAND_PT = "PT";
|
public static final String CHECK_COMMAND_PT = "PT";
|
||||||
|
public static final String CHECK_COMMAND_DAMAGE = "DAMAGE";
|
||||||
public static final String CHECK_COMMAND_LIFE = "LIFE";
|
public static final String CHECK_COMMAND_LIFE = "LIFE";
|
||||||
public static final String CHECK_COMMAND_ABILITY = "ABILITY";
|
public static final String CHECK_COMMAND_ABILITY = "ABILITY";
|
||||||
public static final String CHECK_COMMAND_PERMANENT_COUNT = "PERMANENT_COUNT";
|
public static final String CHECK_COMMAND_PERMANENT_COUNT = "PERMANENT_COUNT";
|
||||||
|
|
@ -297,6 +298,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
check(checkName, turnNum, step, player, CHECK_COMMAND_PT, permanentName, power.toString(), toughness.toString());
|
check(checkName, turnNum, step, player, CHECK_COMMAND_PT, permanentName, power.toString(), toughness.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkDamage(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, Integer damage) {
|
||||||
|
//Assert.assertNotEquals("", permanentName);
|
||||||
|
check(checkName, turnNum, step, player, CHECK_COMMAND_DAMAGE, permanentName, damage.toString());
|
||||||
|
}
|
||||||
|
|
||||||
public void checkLife(String checkName, int turnNum, PhaseStep step, TestPlayer player, Integer life) {
|
public void checkLife(String checkName, int turnNum, PhaseStep step, TestPlayer player, Integer life) {
|
||||||
check(checkName, turnNum, step, player, CHECK_COMMAND_LIFE, life.toString());
|
check(checkName, turnNum, step, player, CHECK_COMMAND_LIFE, life.toString());
|
||||||
}
|
}
|
||||||
|
|
@ -1251,7 +1257,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
if (!player.getActions().isEmpty()) {
|
if (!player.getActions().isEmpty()) {
|
||||||
System.out.println("Remaining actions for " + player.getName() + " (" + player.getActions().size() + "):");
|
System.out.println("Remaining actions for " + player.getName() + " (" + player.getActions().size() + "):");
|
||||||
player.getActions().stream().forEach(a -> {
|
player.getActions().stream().forEach(a -> {
|
||||||
System.out.println("* turn " + a.getTurnNum() + " - " + a.getStep() + ": " + a.getActionName());
|
System.out.println("* turn " + a.getTurnNum() + " - " + a.getStep() + ": " + (a.getActionName().isEmpty() ? a.getAction() : a.getActionName()));
|
||||||
});
|
});
|
||||||
Assert.fail("Player " + player.getName() + " must have 0 actions but found " + player.getActions().size());
|
Assert.fail("Player " + player.getName() + " must have 0 actions but found " + player.getActions().size());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue