InputProxy no longer updates when stack has changed - the only possible reason for it to update is passPriority

This fixes "AI spawning multiple threads" bug
This commit is contained in:
Maxmtg
2013-05-26 18:12:18 +00:00
parent 2031691ed3
commit aaa08dbc19
2 changed files with 6 additions and 5 deletions

View File

@@ -724,6 +724,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
} else if (!game.getStack().hasSimultaneousStackEntries()) { } else if (!game.getStack().hasSimultaneousStackEntries()) {
game.getStack().resolveStack(); game.getStack().resolveStack();
game.getStack().chooseOrderOfSimultaneousStackEntryAll(); game.getStack().chooseOrderOfSimultaneousStackEntryAll();
updateObservers();
} }
} else { } else {
// pass the priority to other player // pass the priority to other player
@@ -806,7 +807,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
} }
public String debugPrintState() { public String debugPrintState() {
return String.format("%s's %s, priority of %s [%sP]", getPlayerTurn(), getPhase(), getPriorityPlayer(), isPlayerPriorityAllowed() ? "+" : "-"); return String.format("%s's %s [%sP] %s", getPlayerTurn(), getPhase(), isPlayerPriorityAllowed() ? "+" : "-", getPriorityPlayer());
} }

View File

@@ -47,7 +47,7 @@ public class InputProxy implements Observer {
public void setGame(GameState game0) { public void setGame(GameState game0) {
game = game0; game = game0;
game.getStack().addObserver(this); // game.getStack().addObserver(this);
game.getPhaseHandler().addObserver(this); game.getPhaseHandler().addObserver(this);
game.getInputQueue().addObserver(this); game.getInputQueue().addObserver(this);
} }
@@ -63,14 +63,14 @@ public class InputProxy implements Observer {
if(INPUT_DEBUG) { if(INPUT_DEBUG) {
System.out.print(FThreads.debugGetStackTraceItem(6, true) + " ... "); System.out.print(FThreads.debugGetStackTraceItem(6, true) + " ... ");
System.out.printf("\tinput is %s during %s, \tstack = %s%n", nextInput == null ? "null" : nextInput.getClass().getSimpleName(), ph.debugPrintState(), game.getInputQueue().printInputStack()); System.out.printf("\t%s on %s, \tstack = %s%n", nextInput == null ? "null" : nextInput.getClass().getSimpleName(), ph.debugPrintState(), game.getInputQueue().printInputStack());
} }
this.input.set(nextInput); this.input.set(nextInput);
Runnable showMessage = new Runnable() { Runnable showMessage = new Runnable() {
@Override public void run() { @Override public void run() {
if(INPUT_DEBUG) //if(INPUT_DEBUG)
System.out.printf("%s > showMessage @ %s/%s during %s%n%n", FThreads.debugGetCurrThreadId(), nextInput.getClass().getSimpleName(), getInput().getClass().getSimpleName(), ph.debugPrintState()); // System.out.printf("%s > showMessage @ %s/%s during %s%n%n", FThreads.debugGetCurrThreadId(), nextInput.getClass().getSimpleName(), getInput().getClass().getSimpleName(), ph.debugPrintState());
getInput().showMessage(game.getInputQueue()); getInput().showMessage(game.getInputQueue());
} }
}; };