Added additional test for #7251;

Added last error info in too many errors game message;
This commit is contained in:
Oleg Agafonov 2020-12-18 16:46:05 +04:00
parent c13d07b73d
commit 53c5abea14
3 changed files with 31 additions and 6 deletions

View file

@ -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();

View file

@ -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 {

View file

@ -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;