From 91d577b0afad07b76bb8081d3be2e5d18894bc2c Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Fri, 27 Aug 2021 21:42:25 +0400 Subject: [PATCH] Test framework: fixed that ai play step command doesn't work correctly on declare attackers and blockers steps; --- .../cards/single/stx/DaemogothTitanTest.java | 47 +++++++++++++++++++ .../java/org/mage/test/player/TestPlayer.java | 8 ++-- 2 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/stx/DaemogothTitanTest.java diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/stx/DaemogothTitanTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/stx/DaemogothTitanTest.java new file mode 100644 index 0000000000..3c1c9209d0 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/stx/DaemogothTitanTest.java @@ -0,0 +1,47 @@ +package org.mage.test.cards.single.stx; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBaseWithAIHelps; + +/** + * @author JayDi85 + */ +public class DaemogothTitanTest extends CardTestPlayerBaseWithAIHelps { + + @Test + public void test_Attack_Manual() { + // Whenever Daemogoth Titan attacks or blocks, sacrifice a creature. + addCard(Zone.BATTLEFIELD, playerA, "Daemogoth Titan"); // 11/10 + addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 1); + + attack(1, playerA, "Daemogoth Titan"); + addTarget(playerA, "Grizzly Bears"); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertLife(playerB, 20 - 11); + assertGraveyardCount(playerA, "Grizzly Bears", 1); + } + + @Test + public void test_Attack_AI() { + // Whenever Daemogoth Titan attacks or blocks, sacrifice a creature. + addCard(Zone.BATTLEFIELD, playerA, "Daemogoth Titan"); // 11/10 + addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 1); + + aiPlayStep(1, PhaseStep.DECLARE_ATTACKERS, playerA); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertLife(playerB, 20 - 11); + assertGraveyardCount(playerA, "Grizzly Bears", 1); + } +} 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 a4e77c9a2a..cd6def1ac9 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 @@ -1683,8 +1683,8 @@ public class TestPlayer implements Player { mustAttackByAction = true; madeAttackByAction = true; this.computerPlayer.selectAttackers(game, attackingPlayerId); - it.remove(); - break; + // play step action will be removed on step end + continue; } if (action.getTurnNum() == game.getTurnNum() && action.getAction().startsWith("attack:")) { @@ -1774,8 +1774,8 @@ public class TestPlayer implements Player { if (action.getTurnNum() == game.getTurnNum() && action.getAction().equals(AI_PREFIX + AI_COMMAND_PLAY_STEP)) { mustBlockByAction = true; this.computerPlayer.selectBlockers(source, game, defendingPlayerId); - actions.remove(action); - break; + // play step action will be removed on step end + continue; } if (action.getTurnNum() == game.getTurnNum() && action.getAction().startsWith("block:")) {