begin step of CombatDamagePhase is for first strike, end step is for regular damage, during resolve step inbetween players are not allowed to play spells or abilities except to decide targets of triggered effects

master
melvin 2011-06-13 20:59:43 +08:00
parent 11c2c8ace9
commit ee072e07b4
3 changed files with 36 additions and 25 deletions

View File

@ -42,6 +42,11 @@ public class MagicPlayChoice extends MagicChoice {
if (game.getStack().hasItemOnTopOfPlayer(player)) {
return PASS_OPTIONS;
}
//can't play spells or abilities during combat damage phase
if (game.isPhase(MagicPhaseType.CombatDamage)) {
return PASS_OPTIONS;
}
final List<Object> options=new ArrayList<Object>();
final MagicActivationMap activationMap=player.getActivationMap();
@ -89,11 +94,21 @@ public class MagicPlayChoice extends MagicChoice {
if (game.canAlwaysPass()) {
return PASS_CHOICE_RESULTS;
}
if ((game.isPhase(MagicPhaseType.DeclareAttackers) ||
game.isPhase(MagicPhaseType.DeclareBlockers) ||
game.isPhase(MagicPhaseType.CombatDamage) ||
game.isPhase(MagicPhaseType.EndOfCombat)) &&
player.getNrOfAttackers() == 0 &&
game.getOpponent(player).getNrOfAttackers() == 0) {
return PASS_CHOICE_RESULTS;
}
final Set<Object> validChoices;
validChoices=getValidChoices(game,player);
if (validChoices.isEmpty() && game.canSkipSingleChoice()) {
if ((game.isPhase(MagicPhaseType.CombatDamage)) ||
(validChoices.isEmpty() && game.canSkipSingleChoice())) {
if (!game.getStack().isEmpty()) {
try {
Thread.sleep(1000);
@ -104,16 +119,6 @@ public class MagicPlayChoice extends MagicChoice {
return PASS_CHOICE_RESULTS;
}
if ((game.isPhase(MagicPhaseType.DeclareAttackers) ||
game.isPhase(MagicPhaseType.DeclareBlockers) ||
game.isPhase(MagicPhaseType.CombatDamage) ||
game.isPhase(MagicPhaseType.EndOfCombat)) &&
player.getNrOfAttackers() == 0 &&
game.getOpponent(player).getNrOfAttackers() == 0) {
return PASS_CHOICE_RESULTS;
}
/*
if ((game.getStack().isEmpty() || game.getStack().hasItemOnTopOfPlayer(player)) &&
game.getTurnPlayer() == player &&

View File

@ -10,6 +10,7 @@ import magic.model.event.MagicPriorityEvent;
public class MagicCombatDamagePhase extends MagicPhase {
private static final MagicPhase INSTANCE=new MagicCombatDamagePhase();
private boolean regular = false;
private MagicCombatDamagePhase() {
super(MagicPhaseType.CombatDamage);
@ -27,14 +28,7 @@ public class MagicCombatDamagePhase extends MagicPhase {
final int poisonBefore=defendingPlayer.getPoison();
//deal first strike damage
game.doAction(new MagicCombatDamageAction(attackingPlayer,defendingPlayer, true));
//resolve stack
while (!game.getStack().isEmpty()) {
game.doAction(new MagicStackResolveAction());
SoundEffects.getInstance().playClip(game,SoundEffects.RESOLVE_SOUND);
}
//deal regular damage
game.doAction(new MagicCombatDamageAction(attackingPlayer,defendingPlayer, false));
game.doAction(new MagicCombatDamageAction(attackingPlayer,defendingPlayer, !regular));
final int lifeAfter=defendingPlayer.getLife();
final int poisonAfter=defendingPlayer.getPoison();
@ -51,7 +45,16 @@ public class MagicCombatDamagePhase extends MagicPhase {
game.logMessage(defendingPlayer,"{c}"+message.toString());
}
game.setStep(MagicStep.NextPhase);
SoundEffects.getInstance().playClip(game,SoundEffects.COMBAT_SOUND);
if (!regular) {
game.setStep(MagicStep.ActivePlayer);
} else {
SoundEffects.getInstance().playClip(game,SoundEffects.COMBAT_SOUND);
}
}
protected void executeEndOfPhase(final MagicGame game) {
regular = true;
executeBeginStep(game);
regular = false;
}
}

View File

@ -21,19 +21,22 @@ class TestDoubleStrikeDread extends TestGameBuilder {
MagicPlayer P = player;
P.setLife(4);
P.setLife(10);
addToLibrary(P, "Plains", 10);
createPermanent(game,P,"Rupture Spire",false,8);
createPermanent(game,P,"Dread",false,1);
createPermanent(game,P,"Dissipation Field",false,1);
//createPermanent(game,P,"Oracle of Nectars",false,1);
createPermanent(game,P,"Sword of Body and Mind",false,1);
createPermanent(game,P,"Sword of Light and Shadow",false,1);
createPermanent(game,P,"Hearthfire Hobgoblin", false, 1);
createPermanent(game,P,"Oracle of Nectars", false, 1);
addToGraveyard(P,"Oracle of Nectars", 1);
addToHand(P, "Pacifism", 2);
P = opponent;
P.setLife(4);
P.setLife(10);
addToLibrary(P, "Plains", 10);
createPermanent(game,P,"Rupture Spire",false,8);
createPermanent(game,P,"Hearthfire Hobgoblin", false, 1);