mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Test framework: added realtime command to check tapped status (checkPermanentTapped)
This commit is contained in:
parent
69d8fd1898
commit
e2792881d5
2 changed files with 43 additions and 3 deletions
|
@ -772,6 +772,13 @@ public class TestPlayer implements Player {
|
|||
wasProccessed = true;
|
||||
}
|
||||
|
||||
// check permanent tapped count: target player, card name, tapped status, count
|
||||
if (params[0].equals(CHECK_COMMAND_PERMANENT_TAPPED) && params.length == 5) {
|
||||
assertPermanentTapped(action, game, game.getPlayer(UUID.fromString(params[1])), params[2], Boolean.parseBoolean(params[3]), Integer.parseInt(params[4]));
|
||||
actions.remove(action);
|
||||
wasProccessed = true;
|
||||
}
|
||||
|
||||
// check permanent counters: card name, counter type, count
|
||||
if (params[0].equals(CHECK_COMMAND_PERMANENT_COUNTERS) && params.length == 4) {
|
||||
assertPermanentCounters(action, game, computerPlayer, params[1], CounterType.findByName(params[2]), Integer.parseInt(params[3]));
|
||||
|
@ -1241,7 +1248,31 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must exists in " + count + " instances", count, foundedCount);
|
||||
if (foundedCount != count) {
|
||||
printStart("Permanents of " + player.getName());
|
||||
printPermanents(game, game.getBattlefield().getAllActivePermanents(player.getId()));
|
||||
printEnd();
|
||||
Assert.fail(action.getActionName() + " - permanent " + permanentName + " must exists in " + count + " instances");
|
||||
}
|
||||
}
|
||||
|
||||
private void assertPermanentTapped(PlayerAction action, Game game, Player player, String permanentName, boolean tapped, int count) {
|
||||
int foundedCount = 0;
|
||||
for (Permanent perm : game.getBattlefield().getAllPermanents()) {
|
||||
if (hasObjectTargetNameOrAlias(perm, permanentName)
|
||||
&& perm.getControllerId().equals(player.getId())
|
||||
&& perm.isTapped() == tapped) {
|
||||
foundedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundedCount != count) {
|
||||
printStart("Permanents of " + player.getName());
|
||||
printPermanents(game, game.getBattlefield().getAllActivePermanents(player.getId()));
|
||||
printEnd();
|
||||
Assert.fail(action.getActionName() + " - must have " + count + (tapped ? " tapped " : " untapped ")
|
||||
+ "permanents with name " + permanentName + ", but founded " + foundedCount);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertPermanentCounters(PlayerAction action, Game game, Player player, String permanentName, CounterType counterType, int count) {
|
||||
|
@ -2039,7 +2070,7 @@ public class TestPlayer implements Player {
|
|||
|
||||
// ignore player select
|
||||
if (!target.getMessage().equals("Select a starting player")) {
|
||||
this.chooseStrictModeFailed("choice", game, getInfo(game.getObject(sourceId)) + "; " + getInfo(target));
|
||||
this.chooseStrictModeFailed("choice", game, getInfo(game.getObject(sourceId)) + ";\n" + getInfo(target));
|
||||
}
|
||||
return computerPlayer.choose(outcome, target, sourceId, game, options);
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
public static final String CHECK_COMMAND_ABILITY = "ABILITY";
|
||||
public static final String CHECK_COMMAND_PLAYABLE_ABILITY = "PLAYABLE_ABILITY";
|
||||
public static final String CHECK_COMMAND_PERMANENT_COUNT = "PERMANENT_COUNT";
|
||||
public static final String CHECK_COMMAND_PERMANENT_TAPPED = "PERMANENT_TAPPED";
|
||||
public static final String CHECK_COMMAND_PERMANENT_COUNTERS = "PERMANENT_COUNTERS";
|
||||
public static final String CHECK_COMMAND_EXILE_COUNT = "EXILE_COUNT";
|
||||
public static final String CHECK_COMMAND_GRAVEYARD_COUNT = "GRAVEYARD_COUNT";
|
||||
|
@ -104,7 +105,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
public static final String CHECK_COMMAND_MANA_POOL = "MANA_POOL";
|
||||
public static final String CHECK_COMMAND_ALIAS_ZONE = "ALIAS_ZONE";
|
||||
public static final String CHECK_COMMAND_PLAYER_IN_GAME = "PLAYER_IN_GAME";
|
||||
public static final String CHECK_COMMAND_STACK_SIZE = "STACK_COUNT";
|
||||
public static final String CHECK_COMMAND_STACK_SIZE = "STACK_SIZE";
|
||||
public static final String CHECK_COMMAND_STACK_OBJECT = "STACK_OBJECT";
|
||||
|
||||
// TODO: add target player param to commands
|
||||
|
@ -374,6 +375,14 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
check(checkName, turnNum, step, player, CHECK_COMMAND_PERMANENT_COUNT, targetPlayer.getId().toString(), permanentName, count.toString());
|
||||
}
|
||||
|
||||
public void checkPermanentTapped(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, Boolean tapped, Integer count) {
|
||||
checkPermanentTapped(checkName, turnNum, step, player, player, permanentName, tapped, count);
|
||||
}
|
||||
|
||||
public void checkPermanentTapped(String checkName, int turnNum, PhaseStep step, TestPlayer player, TestPlayer targetPlayer, String permanentName, Boolean tapped, Integer count) {
|
||||
check(checkName, turnNum, step, player, CHECK_COMMAND_PERMANENT_TAPPED, targetPlayer.getId().toString(), permanentName, tapped.toString(), count.toString());
|
||||
}
|
||||
|
||||
public void checkPermanentCounters(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, CounterType counterType, Integer count) {
|
||||
check(checkName, turnNum, step, player, CHECK_COMMAND_PERMANENT_COUNTERS, permanentName, counterType.toString(), count.toString());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue