From 7655d3d3b86a8e657e1b7aadd8f961626ee6e5d6 Mon Sep 17 00:00:00 2001 From: melvin Date: Fri, 23 Nov 2012 17:05:26 +0800 Subject: [PATCH] Only auto skip combat phases if stack is empty. Fixes issue 285. --- src/magic/model/choice/MagicPlayChoice.java | 7 +++- src/magic/test/TestCounterFlash.java | 43 +++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 src/magic/test/TestCounterFlash.java diff --git a/src/magic/model/choice/MagicPlayChoice.java b/src/magic/model/choice/MagicPlayChoice.java index 6837d797bd..5c655ef360 100644 --- a/src/magic/model/choice/MagicPlayChoice.java +++ b/src/magic/model/choice/MagicPlayChoice.java @@ -96,13 +96,16 @@ public class MagicPlayChoice extends MagicChoice { return PASS_CHOICE_RESULTS; } - //skip all combat phases if nobody is attacking + //skip all combat phases if + // nobody is attacking and + // stack is empty if ((game.isPhase(MagicPhaseType.DeclareAttackers) || game.isPhase(MagicPhaseType.DeclareBlockers) || game.isPhase(MagicPhaseType.CombatDamage) || game.isPhase(MagicPhaseType.EndOfCombat)) && player.getNrOfAttackers() == 0 && - player.getOpponent().getNrOfAttackers() == 0) { + player.getOpponent().getNrOfAttackers() == 0 && + game.getStack().isEmpty()) { return PASS_CHOICE_RESULTS; } diff --git a/src/magic/test/TestCounterFlash.java b/src/magic/test/TestCounterFlash.java new file mode 100644 index 0000000000..6715c9d127 --- /dev/null +++ b/src/magic/test/TestCounterFlash.java @@ -0,0 +1,43 @@ +package magic.test; + +import magic.model.MagicDuel; +import magic.model.MagicGame; +import magic.model.MagicPlayer; +import magic.model.MagicPlayerDefinition; +import magic.model.MagicPlayerProfile; +import magic.model.phase.MagicMainPhase; + +class TestCounterFlash extends TestGameBuilder { + public MagicGame getGame() { + final MagicDuel duel=new MagicDuel(); + duel.setDifficulty(6); + + final MagicPlayerProfile profile=new MagicPlayerProfile("bgruw"); + final MagicPlayerDefinition player1=new MagicPlayerDefinition("Player",false,profile,15); + final MagicPlayerDefinition player2=new MagicPlayerDefinition("Computer",true,profile,14); + duel.setPlayers(new MagicPlayerDefinition[]{player1,player2}); + duel.setStartPlayer(0); + + final MagicGame game=duel.nextGame(true); + game.setPhase(MagicMainPhase.getFirstInstance()); + final MagicPlayer player=game.getPlayer(0); + final MagicPlayer opponent=game.getPlayer(1); + + MagicPlayer P = player; + + P.setLife(1); + addToLibrary(P, "Plains", 10); + createPermanent(game,P,"Rupture Spire",false,8); + addToHand(P,"Counterspell",1); + + P = opponent; + + P.setLife(1); + addToLibrary(P, "Plains", 10); + createPermanent(game,P,"Rupture Spire",false,8); + addToHand(P,"Restoration Angel",1); + //addToHand(P,"Grizzly Bears",1); + + return game; + } +}