mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 04:42:07 -08:00
Test framework: added real time card type check (#4936);
This commit is contained in:
parent
bec43e8d31
commit
4c899a25bd
5 changed files with 43 additions and 6 deletions
|
|
@ -667,6 +667,13 @@ public class TestPlayer implements Player {
|
|||
wasProccessed = true;
|
||||
}
|
||||
|
||||
// check type: card name, type, must have
|
||||
if (params[0].equals(CHECK_COMMAND_TYPE) && params.length == 4) {
|
||||
assertType(action, game, computerPlayer, params[1], CardType.fromString(params[2]), Boolean.parseBoolean(params[3]));
|
||||
actions.remove(action);
|
||||
wasProccessed = true;
|
||||
}
|
||||
|
||||
// check subtype: card name, subtype, must have
|
||||
if (params[0].equals(CHECK_COMMAND_SUBTYPE) && params.length == 4) {
|
||||
assertSubType(action, game, computerPlayer, params[1], SubType.fromString(params[2]), Boolean.parseBoolean(params[3]));
|
||||
|
|
@ -994,6 +1001,25 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
}
|
||||
|
||||
private void assertType(PlayerAction action, Game game, Player player, String permanentName, CardType type, boolean mustHave) {
|
||||
|
||||
Permanent perm = findPermanentWithAssert(action, game, player, permanentName);
|
||||
|
||||
boolean founded = false;
|
||||
for (CardType ct : perm.getCardType()) {
|
||||
if (ct.equals(type)) {
|
||||
founded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mustHave) {
|
||||
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have type " + type, true, founded);
|
||||
} else {
|
||||
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have not type " + type, false, founded);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertSubType(PlayerAction action, Game game, Player player, String permanentName, SubType subType, boolean mustHave) {
|
||||
|
||||
Permanent perm = findPermanentWithAssert(action, game, player, permanentName);
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
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_COLOR = "COLOR";
|
||||
public static final String CHECK_COMMAND_TYPE = "TYPE";
|
||||
public static final String CHECK_COMMAND_SUBTYPE = "SUBTYPE";
|
||||
public static final String CHECK_COMMAND_MANA_POOL = "MANA_POOL";
|
||||
public static final String CHECK_COMMAND_ALIAS_ZONE = "ALIAS_ZONE";
|
||||
|
|
@ -326,6 +327,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
check(checkName, turnNum, step, player, CHECK_COMMAND_COLOR, permanentName, colors, mustHave.toString());
|
||||
}
|
||||
|
||||
public void checkType(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, CardType type, Boolean mustHave) {
|
||||
//Assert.assertNotEquals("", permanentName);
|
||||
check(checkName, turnNum, step, player, CHECK_COMMAND_TYPE, permanentName, type.toString(), mustHave.toString());
|
||||
}
|
||||
|
||||
public void checkSubType(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, SubType subType, Boolean mustHave) {
|
||||
//Assert.assertNotEquals("", permanentName);
|
||||
check(checkName, turnNum, step, player, CHECK_COMMAND_SUBTYPE, permanentName, subType.toString(), mustHave.toString());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue