From 9e88353bd56cdd5e8fba51c76ce3686f12d7c5ce Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Tue, 3 Dec 2024 00:17:23 +0100 Subject: [PATCH] show bankrupt popup once --- .../src/main/java/pp/monopoly/client/gui/Toolbar.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java index f9173dd..8beb8ba 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java @@ -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. *

@@ -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)); }