put all triggers on stack in immediate mode, clear stack after simulated combat

fixes issue 235
master
melvin 2013-05-05 15:36:14 +08:00
parent 805165949b
commit fcbfadc1ec
2 changed files with 8 additions and 3 deletions

View File

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

View File

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