mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
Test framework: added library realtime check command;
This commit is contained in:
parent
da5d9b46e8
commit
bbed5a16b8
2 changed files with 24 additions and 0 deletions
|
@ -813,6 +813,13 @@ public class TestPlayer implements Player {
|
|||
wasProccessed = true;
|
||||
}
|
||||
|
||||
// check library count: card name, count
|
||||
if (params[0].equals(CHECK_COMMAND_LIBRARY_COUNT) && params.length == 3) {
|
||||
assertLibraryCount(action, game, computerPlayer, params[1], Integer.parseInt(params[2]));
|
||||
actions.remove(action);
|
||||
wasProccessed = true;
|
||||
}
|
||||
|
||||
// check hand count: count
|
||||
if (params[0].equals(CHECK_COMMAND_HAND_COUNT) && params.length == 2) {
|
||||
assertHandCount(action, game, computerPlayer, Integer.parseInt(params[1]));
|
||||
|
@ -1347,6 +1354,17 @@ public class TestPlayer implements Player {
|
|||
Assert.assertEquals(action.getActionName() + " - card " + permanentName + " must exists in graveyard zone with " + count + " instances", count, foundedCount);
|
||||
}
|
||||
|
||||
private void assertLibraryCount(PlayerAction action, Game game, Player player, String permanentName, int count) {
|
||||
int foundedCount = 0;
|
||||
for (Card card : player.getLibrary().getCards(game)) {
|
||||
if (hasObjectTargetNameOrAlias(card, permanentName)) {
|
||||
foundedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(action.getActionName() + " - card " + permanentName + " must exists in library with " + count + " instances", count, foundedCount);
|
||||
}
|
||||
|
||||
private void assertHandCount(PlayerAction action, Game game, Player player, int count) {
|
||||
Assert.assertEquals(action.getActionName() + " - hand must contain " + count, count, player.getHand().size());
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
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";
|
||||
public static final String CHECK_COMMAND_LIBRARY_COUNT = "LIBRARY_COUNT";
|
||||
public static final String CHECK_COMMAND_HAND_COUNT = "HAND_COUNT";
|
||||
public static final String CHECK_COMMAND_HAND_CARD_COUNT = "HAND_CARD_COUNT";
|
||||
public static final String CHECK_COMMAND_COMMAND_CARD_COUNT = "COMMAND_CARD_COUNT";
|
||||
|
@ -433,6 +434,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
check(checkName, turnNum, step, player, CHECK_COMMAND_GRAVEYARD_COUNT, permanentName, count.toString());
|
||||
}
|
||||
|
||||
public void checkLibraryCount(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, Integer count) {
|
||||
//Assert.assertNotEquals("", permanentName);
|
||||
check(checkName, turnNum, step, player, CHECK_COMMAND_LIBRARY_COUNT, permanentName, count.toString());
|
||||
}
|
||||
|
||||
public void checkHandCount(String checkName, int turnNum, PhaseStep step, TestPlayer player, Integer count) {
|
||||
check(checkName, turnNum, step, player, CHECK_COMMAND_HAND_COUNT, count.toString());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue