add missing priority after combat damage step for damage triggers to be put on the stack, fixes #978

master
melvinzhang 2017-10-03 17:18:59 +08:00
parent 5379ecd69a
commit f0d44cbb9b
3 changed files with 23 additions and 21 deletions

View File

@ -21,6 +21,7 @@ public class CombatDamageAction extends MagicAction {
private final MagicPlayer attackingPlayer;
private final MagicPlayer defendingPlayer;
private final boolean first;
private boolean dealtDamage = false;
public CombatDamageAction(final MagicPlayer attackingPlayer, final MagicPlayer defendingPlayer, final boolean first) {
this.attackingPlayer=attackingPlayer;
@ -113,10 +114,15 @@ public class CombatDamageAction extends MagicAction {
for (final MagicDamage damage: combatDamage) {
game.doAction(new DealDamageAction(damage));
}
dealtDamage = true;
game.setStateCheckRequired();
}
}
public boolean dealtDamage() {
return dealtDamage;
}
@Override
public void doAction(final MagicGame game) {
combatDamage(game,attackingPlayer,defendingPlayer);

View File

@ -2,19 +2,20 @@ package magic.model.phase;
import magic.model.MagicGame;
import magic.model.MagicPlayer;
import magic.model.MagicPermanent;
import magic.model.MagicAbility;
import magic.model.action.CombatDamageAction;
import magic.ui.MagicSound;
public class MagicCombatDamagePhase extends MagicPhase {
private static final MagicPhase INSTANCE = new MagicCombatDamagePhase();
public static final MagicPhase First = new MagicCombatDamagePhase(true);
public static final MagicPhase Second = new MagicCombatDamagePhase(false);
private final boolean isFirst;
private MagicCombatDamagePhase() {
private MagicCombatDamagePhase(final boolean first) {
super(MagicPhaseType.CombatDamage);
}
public static MagicPhase getInstance() {
return INSTANCE;
isFirst = first;
}
@Override
@ -28,13 +29,8 @@ public class MagicCombatDamagePhase extends MagicPhase {
final int attackerPoisonBefore = attackingPlayer.getPoison();
final String attackerName = attackingPlayer.getName();
//deal first strike damage
if (game.getStep() == MagicStep.Begin) {
game.doAction(new CombatDamageAction(attackingPlayer, defendingPlayer, true));
} else {
//deal regular damage
game.doAction(new CombatDamageAction(attackingPlayer, defendingPlayer, false));
}
final CombatDamageAction act = new CombatDamageAction(attackingPlayer, defendingPlayer, isFirst);
game.doAction(act);
//combat message for defender
final int defenderLifeAfter = defendingPlayer.getLife();
@ -69,15 +65,13 @@ public class MagicCombatDamagePhase extends MagicPhase {
}
//End combat damage steps
if (game.getStep() == MagicStep.Begin) {
if (isFirst == false || act.dealtDamage()) {
game.setStep(MagicStep.ActivePlayer);
} else {
game.setStep(MagicStep.NextPhase);
}
if (isFirst == false) {
game.playSound(MagicSound.COMBAT);
}
}
@Override
protected void executeEndOfPhase(final MagicGame game) {
executeBeginStep(game);
}
}

View File

@ -35,9 +35,11 @@ public class MagicDefaultGameplay implements MagicGameplay {
MagicDeclareBlockersPhase.getInstance() :
MagicEndOfCombatPhase.getInstance();
case DeclareBlockers:
return MagicCombatDamagePhase.getInstance();
return MagicCombatDamagePhase.First;
case CombatDamage:
return MagicEndOfCombatPhase.getInstance();
return game.getPhase() == MagicCombatDamagePhase.First ?
MagicCombatDamagePhase.Second :
MagicEndOfCombatPhase.getInstance();
case EndOfCombat:
return MagicMainPhase.getSecondInstance();
case SecondMain: