From 796c8fb22e834cc11bd00d7324dc31cc1b96d44c Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Wed, 23 Dec 2020 02:51:52 +0400 Subject: [PATCH] Tests: added Inferno Titan AI tests, related to #6330; --- .../cards/single/m11/InfernoTitanTest.java | 61 ++++++++++++++++++- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/m11/InfernoTitanTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/m11/InfernoTitanTest.java index 04f56469e42..74b0b4212a1 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/m11/InfernoTitanTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/m11/InfernoTitanTest.java @@ -4,12 +4,12 @@ import mage.constants.PhaseStep; import mage.constants.Zone; import mage.counters.CounterType; import org.junit.Test; -import org.mage.test.serverside.base.CardTestPlayerBase; +import org.mage.test.serverside.base.CardTestPlayerBaseWithAIHelps; /** * @author JayDi85 */ -public class InfernoTitanTest extends CardTestPlayerBase { +public class InfernoTitanTest extends CardTestPlayerBaseWithAIHelps { @Test public void test_MustAbleToTargetPlaneswalkers() { @@ -22,7 +22,7 @@ public class InfernoTitanTest extends CardTestPlayerBase { addCard(Zone.BATTLEFIELD, playerA, "Chandra, Acolyte of Flame", 1); // 4 addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears"); // 2/2 - // cast and devide damage (2x to creature and 1x to planeswalker) + // cast and divide damage (2x to creature and 1x to planeswalker) castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Inferno Titan"); addTargetAmount(playerA, "Grizzly Bears", 2); addTargetAmount(playerA, "Chandra, Acolyte of Flame", 1); @@ -36,4 +36,59 @@ public class InfernoTitanTest extends CardTestPlayerBase { assertGraveyardCount(playerA, "Grizzly Bears", 1); assertCounterCount(playerA, "Chandra, Acolyte of Flame", CounterType.LOYALTY, 4 - 1); } + + @Test + public void test_AI_MustPlayWithoutFreeze() { + // bug: game freeze on AI usage + // https://github.com/magefree/mage/issues/6330 + + // Whenever Inferno Titan enters the battlefield or attacks, it deals 3 damage divided as you choose among one, two, or three targets. + addCard(Zone.HAND, playerA, "Inferno Titan"); // {4}{R}{R} + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 6); + + addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears"); // 2/2 + addCard(Zone.BATTLEFIELD, playerB, "Grizzly Bears"); // 2/2 + + // AI must play inferno and kill opponent's creature and make 1 damage to player + // cast and divide damage (2x to creature and 1x to player) + aiPlayPriority(1, PhaseStep.PRECOMBAT_MAIN, playerA); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerA, "Inferno Titan", 1); // own in safe + assertPermanentCount(playerA, "Grizzly Bears", 1); // own in safe + assertGraveyardCount(playerB, "Grizzly Bears", 1); // 2x damage - kill + assertLife(playerB, 20 - 1); // 1x damage + } + + @Test + public void test_AI_MustAttackPlaneswalkerInsteadPlayer() { + // bug: game freeze on AI usage + // https://github.com/magefree/mage/issues/6330 + + // Whenever Inferno Titan enters the battlefield or attacks, it deals 3 damage divided as you choose among one, two, or three targets. + addCard(Zone.HAND, playerA, "Inferno Titan"); // {4}{R}{R} + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 6); + + addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears"); // 2/2 + addCard(Zone.BATTLEFIELD, playerB, "Grizzly Bears"); // 2/2 + addCard(Zone.BATTLEFIELD, playerB, "Chandra, Acolyte of Flame", 1); // 4 + + // AI must play inferno and kill opponent's creature and make 1 damage to planeswalker instead player + // cast and divide damage (2x to creature and 1x to planeswalker) + aiPlayPriority(1, PhaseStep.PRECOMBAT_MAIN, playerA); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerA, "Inferno Titan", 1); // own in safe + assertPermanentCount(playerA, "Grizzly Bears", 1); // own in safe + assertGraveyardCount(playerB, "Grizzly Bears", 1); // 2x damage - kill + assertCounterCount(playerB, "Chandra, Acolyte of Flame", CounterType.LOYALTY, 4 - 1); // 1x damage + } }