- Fix issue with StopAtPhase restricting the AI being able to play outside their main phase

This commit is contained in:
jendave
2011-08-06 17:19:20 +00:00
parent 82dad26ca7
commit 451762bbae
6 changed files with 28 additions and 27 deletions

View File

@@ -173,8 +173,8 @@ public class AbilityFactory_DealDamage {
// TODO handle proper calculation of X values based on Cost // TODO handle proper calculation of X values based on Cost
// todo(sol): this should only happen during Humans EOT or if Stuffy is going to die // todo(sol): this should also happen if Stuffy is going to die
if(AF.getHostCard().getName().equals("Stuffy Doll")) { if(AF.getHostCard().getName().equals("Stuffy Doll") && AllZone.Phase.is(Constant.Phase.End_Of_Turn, AllZone.HumanPlayer)) {
return true; return true;
} }

View File

@@ -156,9 +156,6 @@ public class GameActionUtil {
// experimental, AI abuse aluren // experimental, AI abuse aluren
AllZone.Stack.unfreezeStack(); AllZone.Stack.unfreezeStack();
if (AllZone.Stack.size() == 0 && !AllZone.Display.stopAtPhase(player, Constant.Phase.Upkeep))
AllZone.Phase.setNeedToNextPhase(true);
} }
public static void executeDrawStepEffects() { public static void executeDrawStepEffects() {
@@ -175,8 +172,6 @@ public class GameActionUtil {
draw_Mana_Vault(player); draw_Mana_Vault(player);
draw_Sylvan_Library(player); draw_Sylvan_Library(player);
AllZone.Stack.unfreezeStack(); AllZone.Stack.unfreezeStack();
if (AllZone.Stack.size() == 0 && !AllZone.Display.stopAtPhase(player, Constant.Phase.Draw))
AllZone.Phase.setNeedToNextPhase(true);
} }
public static void executeTapSideEffects(Card c) { public static void executeTapSideEffects(Card c) {

View File

@@ -1050,7 +1050,7 @@ public class GuiDisplay3 extends JFrame implements CardContainer, Display, NewCo
else if (phase.equals(Constant.Phase.Combat_End)) else if (phase.equals(Constant.Phase.Combat_End))
return cbHumanEndCombat.isSelected(); return cbHumanEndCombat.isSelected();
} }
return false; return true;
} }
public boolean loadPrefs(){ public boolean loadPrefs(){

View File

@@ -1038,7 +1038,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo
else if (phase.equals(Constant.Phase.Combat_End)) else if (phase.equals(Constant.Phase.Combat_End))
return cbHumanEndCombat.isSelected(); return cbHumanEndCombat.isSelected();
} }
return false; return true;
} }
public boolean loadPrefs(){ public boolean loadPrefs(){

View File

@@ -122,7 +122,8 @@ public class InputControl extends MyObservable implements java.io.Serializable {
} }
else if(phase.equals(Constant.Phase.End_Of_Turn)){ else if(phase.equals(Constant.Phase.End_Of_Turn)){
if (priority.isComputer()){ if (priority.isComputer() && playerTurn.isComputer()){
// this section may not be needed
// AI passes priority in his end of turn phase to player automatically // AI passes priority in his end of turn phase to player automatically
AllZone.Phase.passPriority(); AllZone.Phase.passPriority();
return null; return null;
@@ -138,6 +139,13 @@ public class InputControl extends MyObservable implements java.io.Serializable {
// Special phases handled above, everything else is handled simply by priority // Special phases handled above, everything else is handled simply by priority
if (priority.isHuman()){ if (priority.isHuman()){
boolean skip = AllZone.Phase.doSkipPhase();
AllZone.Phase.setSkipPhase(false);
if(AllZone.Stack.size() == 0 && !AllZone.Display.stopAtPhase(playerTurn, phase) && skip) {
AllZone.Phase.passPriority();
return null;
}
else
return new Input_PassPriority(); return new Input_PassPriority();
} }

View File

@@ -85,6 +85,15 @@ public class Phase extends MyObservable
bPhaseEffects = b; bPhaseEffects = b;
} }
private boolean bSkipPhase = true;
public boolean doSkipPhase() {
return bSkipPhase;
}
public void setSkipPhase(boolean b) {
bSkipPhase = b;
}
private boolean bCombat = false; private boolean bCombat = false;
public boolean inCombat() { public boolean inCombat() {
return bCombat; return bCombat;
@@ -152,6 +161,7 @@ public class Phase extends MyObservable
// Handle effects that happen at the beginning of phases // Handle effects that happen at the beginning of phases
final String phase = AllZone.Phase.getPhase(); final String phase = AllZone.Phase.getPhase();
final Player turn = AllZone.Phase.getPlayerTurn(); final Player turn = AllZone.Phase.getPlayerTurn();
AllZone.Phase.setSkipPhase(true);
if(phase.equals(Constant.Phase.Untap)) { if(phase.equals(Constant.Phase.Untap)) {
PhaseUtil.handleUntap(); PhaseUtil.handleUntap();
@@ -188,13 +198,8 @@ public class Phase extends MyObservable
} }
else if(phase.equals(Constant.Phase.Combat_Begin)){ else if(phase.equals(Constant.Phase.Combat_Begin)){
if (AllZone.Display.stopAtPhase(turn, phase)){
PhaseUtil.verifyCombat(); PhaseUtil.verifyCombat();
} }
else {
this.setNeedToNextPhase(true);
}
}
else if (phase.equals(Constant.Phase.Combat_Declare_Attackers_InstantAbility)){ else if (phase.equals(Constant.Phase.Combat_Declare_Attackers_InstantAbility)){
if(inCombat()) { if(inCombat()) {
@@ -267,17 +272,11 @@ public class Phase extends MyObservable
runParams.put("Phase", phase); runParams.put("Phase", phase);
runParams.put("Player", getPlayerTurn()); runParams.put("Player", getPlayerTurn());
AllZone.TriggerHandler.runTrigger("Phase", runParams); AllZone.TriggerHandler.runTrigger("Phase", runParams);
if(AllZone.Stack.size() == 0 && !AllZone.Display.stopAtPhase(turn, phase))
AllZone.Phase.setNeedToNextPhase(true);
} }
} }
else if(phase.equals(Constant.Phase.End_Of_Turn)) { else if(phase.equals(Constant.Phase.End_Of_Turn)) {
AllZone.EndOfTurn.executeAt(); AllZone.EndOfTurn.executeAt();
// todo: when we have a bar for selecting which phases to stop at, we will check that instead of display.stop
if(AllZone.Stack.size() == 0 && !AllZone.Display.stopAtPhase(turn, phase))
AllZone.Phase.setNeedToNextPhase(true);
} }
else if(phase.equals(Constant.Phase.Cleanup)){ else if(phase.equals(Constant.Phase.Cleanup)){
@@ -293,7 +292,6 @@ public class Phase extends MyObservable
//This line fixes Combat Damage triggers not going off when they should //This line fixes Combat Damage triggers not going off when they should
AllZone.Stack.unfreezeStack(); AllZone.Stack.unfreezeStack();
resetPriority(); resetPriority();
} }