From fcbfadc1ec155f2ea7cb6c3096429b1bbfba43ba Mon Sep 17 00:00:00 2001 From: melvin Date: Sun, 5 May 2013 15:36:14 +0800 Subject: [PATCH] put all triggers on stack in immediate mode, clear stack after simulated combat fixes issue 235 --- src/magic/model/MagicGame.java | 5 ++--- src/magic/model/score/MagicGameCombatScore.java | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/magic/model/MagicGame.java b/src/magic/model/MagicGame.java index 4c47d83ee5..96965ffcd8 100644 --- a/src/magic/model/MagicGame.java +++ b/src/magic/model/MagicGame.java @@ -5,7 +5,6 @@ import magic.model.action.MagicAction; import magic.model.action.MagicActionList; import magic.model.action.MagicAddEventAction; import magic.model.action.MagicExecuteFirstEventAction; -import magic.model.action.MagicStackResolveAction; import magic.model.action.MagicLogMarkerAction; import magic.model.action.MagicMarkerAction; import magic.model.action.MagicPutItemOnStackAction; @@ -1175,12 +1174,12 @@ public class MagicGame { if (!event.isValid()) { return; } - + if (immediate) { if (event.hasChoice()) { // ignore } else { - executeEvent(event, MagicEvent.NO_CHOICE_RESULTS); + doAction(new MagicPutItemOnStackAction(new MagicTriggerOnStack(event))); } } else if (trigger.usesStack()) { doAction(new MagicPutItemOnStackAction(new MagicTriggerOnStack(event))); diff --git a/src/magic/model/score/MagicGameCombatScore.java b/src/magic/model/score/MagicGameCombatScore.java index ff9371171d..905d2ac354 100644 --- a/src/magic/model/score/MagicGameCombatScore.java +++ b/src/magic/model/score/MagicGameCombatScore.java @@ -4,6 +4,7 @@ import magic.model.MagicGame; import magic.model.MagicPlayer; import magic.model.action.MagicCombatDamageAction; import magic.model.action.MagicDeclareBlockersAction; +import magic.model.action.MagicStackResolveAction; import magic.model.choice.MagicDeclareBlockersResult; public class MagicGameCombatScore implements MagicCombatScore { @@ -24,6 +25,11 @@ public class MagicGameCombatScore implements MagicCombatScore { game.doAction(new MagicDeclareBlockersAction(defendingPlayer,result)); game.doAction(new MagicCombatDamageAction(attackingPlayer,defendingPlayer,true)); game.doAction(new MagicCombatDamageAction(attackingPlayer,defendingPlayer,false)); + // resolve triggers + while (game.getStack().size() > 0 && !game.isFinished()) { + game.doAction(new MagicStackResolveAction()); + game.checkState(); + } // Give extra points for extra blocked creatures. final int score=game.getScore()+result.size(); game.undoActions();