show bankrupt popup once

This commit is contained in:
Johannes Schmelz 2024-12-03 00:17:23 +01:00
parent 6db96f0a1d
commit 9e88353bd5

View File

@ -103,6 +103,8 @@ public class Toolbar extends Dialog implements GameEventListener {
*/
private volatile DiceRollEvent latestDiceRollEvent = null;
private boolean bankruptPopUp = false;
/**
* Constructs the toolbar for the Monopoly application.
* <p>
@ -256,9 +258,11 @@ public class Toolbar extends Dialog implements GameEventListener {
endTurnButton.setPreferredSize(new Vector3f(150, 50, 0));
endTurnButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON);
if (app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getAccountBalance() < 0) {
if (app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getAccountBalance() < 0 && !bankruptPopUp) {
new Bankrupt(app).open();
bankruptPopUp = true;
} else {
bankruptPopUp = false;
app.getGameLogic().send(new EndTurn());
receivedEvent(new ButtonStatusEvent(false));
}