diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index 2157c14f635..36526dfbd9d 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -82,7 +82,8 @@ public class TestPlayer implements Player { private int maxCallsWithoutAction = 400; private int foundNoAction = 0; - private boolean AIPlayer; + private boolean AIPlayer; // full playable AI + private boolean AICanChooseInStrictMode = false; // AI can choose in custom aiXXX commands (e.g. on one priority or step) private final List actions = new ArrayList<>(); private final Map actionsToRemovesLater = new HashMap<>(); // remove actions later, on next step (e.g. for AI commands) private final List choices = new ArrayList<>(); // choices stack for choice @@ -113,6 +114,7 @@ public class TestPlayer implements Player { public TestPlayer(final TestPlayer testPlayer) { this.AIPlayer = testPlayer.AIPlayer; + this.AICanChooseInStrictMode = testPlayer.AICanChooseInStrictMode; this.foundNoAction = testPlayer.foundNoAction; this.actions.addAll(testPlayer.actions); this.choices.addAll(testPlayer.choices); @@ -687,16 +689,26 @@ public class TestPlayer implements Player { // play priority if (command.equals(AI_COMMAND_PLAY_PRIORITY)) { - computerPlayer.priority(game); - actions.remove(action); - return true; + AICanChooseInStrictMode = true; + try { + computerPlayer.priority(game); + actions.remove(action); + return true; + } finally { + AICanChooseInStrictMode = false; + } } // play step if (command.equals(AI_COMMAND_PLAY_STEP)) { - actionsToRemovesLater.put(action, game.getStep().getType()); - computerPlayer.priority(game); - return true; + AICanChooseInStrictMode = true; + try { + actionsToRemovesLater.put(action, game.getStep().getType()); + computerPlayer.priority(game); + return true; + } finally { + AICanChooseInStrictMode = false; + } } Assert.fail("Unknow ai command: " + command); @@ -1599,7 +1611,7 @@ public class TestPlayer implements Player { } private void chooseStrictModeFailed(String choiceType, Game game, String reason) { - if (strictChooseMode) { + if (strictChooseMode && !AICanChooseInStrictMode) { Assert.fail("Missing " + choiceType + " def for" + " turn " + game.getTurnNum() + ", step " + (game.getStep() != null ? game.getStep().getType().name() : "not started") diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java index 7e86f2fa501..31a343f540b 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java @@ -1420,6 +1420,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement /** * AI play one PRIORITY with multi game simulations (calcs and play ONE best action, can be called with stack) + * All choices must be made by AI (e.g. strict mode possible) */ public void aiPlayPriority(int turnNum, PhaseStep step, TestPlayer player) { assertAiPlayAndGameCompatible(player); @@ -1428,6 +1429,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement /** * AI play STEP to the end with multi game simulations (calcs and play best actions until step ends, can be called in the middle of the step) + * All choices must be made by AI (e.g. strict mode possible) */ public void aiPlayStep(int turnNum, PhaseStep step, TestPlayer player) { assertAiPlayAndGameCompatible(player);