From 53c5abea14efcef309fc046a88e341dbc6bc196d Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Fri, 18 Dec 2020 16:46:05 +0400 Subject: [PATCH] Added additional test for #7251; Added last error info in too many errors game message; --- .../cards/single/m21/BrashTaunterTest.java | 30 ++++++++++++++++--- .../CardsDrawnThisTurnDynamicValue.java | 2 ++ Mage/src/main/java/mage/game/GameImpl.java | 5 ++-- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/m21/BrashTaunterTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/m21/BrashTaunterTest.java index 0ff1790b99..12f4da25f5 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/m21/BrashTaunterTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/m21/BrashTaunterTest.java @@ -8,25 +8,46 @@ import org.mage.test.serverside.base.CardTestPlayerBase; public class BrashTaunterTest extends CardTestPlayerBase { @Test - public void testTriggerDamageToOpponent(){ + public void test_TriggerDamageToOpponent_FromSpell() { // Whenever Brash Taunter is dealt damage, it deals that much damage to target opponent. addCard(Zone.BATTLEFIELD, playerA, "Brash Taunter"); - addCard(Zone.BATTLEFIELD, playerA, "Mountain"); + // // Shock deals 2 damage to any target addCard(Zone.HAND, playerA, "Shock"); + addCard(Zone.BATTLEFIELD, playerA, "Mountain"); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Shock", "Brash Taunter"); addTarget(playerA, playerB); + setStrictChooseMode(true); setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); execute(); assertAllCommandsUsed(); - assertLife(playerB, 18); + assertLife(playerB, 20 - 2); } @Test - public void testFightAbility(){ + public void test_TriggerDamageToOpponent_FromFight() { + // Whenever Brash Taunter is dealt damage, it deals that much damage to target opponent. + addCard(Zone.BATTLEFIELD, playerB, "Brash Taunter"); + // + addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 1); // 2/2 + + attack(1, playerA, "Balduvian Bears"); + block(1, playerB, "Brash Taunter", "Balduvian Bears"); + addTarget(playerB, playerA); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 20 - 2); + } + + @Test + public void test_FightAbility() { // Whenever Brash Taunter is dealt damage, it deals that much damage to target opponent. // {2}{R}, {T}: Brash Taunter fights another target creature. addCard(Zone.BATTLEFIELD, playerA, "Brash Taunter"); @@ -35,6 +56,7 @@ public class BrashTaunterTest extends CardTestPlayerBase { activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}{R}", "Serra Angel"); addTarget(playerA, playerB); + setStrictChooseMode(true); setStopAt(3, PhaseStep.POSTCOMBAT_MAIN); execute(); diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsDrawnThisTurnDynamicValue.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsDrawnThisTurnDynamicValue.java index 54d0a5ccf2..513f0b8f18 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsDrawnThisTurnDynamicValue.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsDrawnThisTurnDynamicValue.java @@ -7,6 +7,8 @@ import mage.game.Game; import mage.watchers.common.CardsDrawnThisTurnWatcher; /** + * Don't forget to add CardsDrawnThisTurnWatcher in card's definition + * * @author TheElk801 */ public enum CardsDrawnThisTurnDynamicValue implements DynamicValue { diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index 66fde913fa..96f6c9e1cb 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -1394,10 +1394,11 @@ public abstract class GameImpl implements Game, Serializable { this.fireErrorEvent("Game exception occurred: ", ex); restoreState(bookmark, "Game exception: " + ex.getMessage()); bookmark = 0; - Player activePlayer = this.getPlayer(getActivePlayerId()); if (errorContinueCounter > 15) { - throw new MageException("Iterated player priority after game exception too often, game ends!"); + throw new MageException("Iterated player priority after game exception too often, game ends! Last error:\n " + + ex.getMessage()); } + Player activePlayer = this.getPlayer(getActivePlayerId()); if (activePlayer != null && !activePlayer.isTestMode()) { errorContinueCounter++; continue;