mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
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:
@@ -724,6 +724,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
} else if (!game.getStack().hasSimultaneousStackEntries()) {
|
||||
game.getStack().resolveStack();
|
||||
game.getStack().chooseOrderOfSimultaneousStackEntryAll();
|
||||
updateObservers();
|
||||
}
|
||||
} else {
|
||||
// pass the priority to other player
|
||||
@@ -806,7 +807,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class InputProxy implements Observer {
|
||||
|
||||
public void setGame(GameState game0) {
|
||||
game = game0;
|
||||
game.getStack().addObserver(this);
|
||||
// game.getStack().addObserver(this);
|
||||
game.getPhaseHandler().addObserver(this);
|
||||
game.getInputQueue().addObserver(this);
|
||||
}
|
||||
@@ -63,14 +63,14 @@ public class InputProxy implements Observer {
|
||||
|
||||
if(INPUT_DEBUG) {
|
||||
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);
|
||||
Runnable showMessage = new Runnable() {
|
||||
@Override public void run() {
|
||||
if(INPUT_DEBUG)
|
||||
System.out.printf("%s > showMessage @ %s/%s during %s%n%n", FThreads.debugGetCurrThreadId(), nextInput.getClass().getSimpleName(), getInput().getClass().getSimpleName(), ph.debugPrintState());
|
||||
//if(INPUT_DEBUG)
|
||||
// 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());
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user