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 ce8d707..e2a4467 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 @@ -14,6 +14,7 @@ import com.simsilica.lemur.style.ElementId; import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; +import pp.monopoly.client.gui.popups.Bankrupt; import pp.monopoly.game.server.Player; import pp.monopoly.game.server.PlayerHandler; import pp.monopoly.message.client.EndTurn; @@ -185,8 +186,12 @@ public class Toolbar extends Dialog implements GameEventListener { endTurnButton.setPreferredSize(new Vector3f(150, 50, 0)); endTurnButton.addClickCommands(s -> ifTopDialog(() -> { app.getGameLogic().playSound(Sound.BUTTON); - app.getGameLogic().send(new EndTurn()); - receivedEvent(new ButtonStatusEvent(false)); + if (app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getAccountBalance() < 0) { + new Bankrupt(app).open(); + } else { + app.getGameLogic().send(new EndTurn()); + receivedEvent(new ButtonStatusEvent(false)); + } })); return endTurnButton; } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java index 70e8cf8..cd0cef0 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java @@ -64,7 +64,7 @@ public class Bankrupt extends Dialog { // Beenden-Button Button quitButton = bankruptContainer.addChild(new Button("Bestätigen", new ElementId("button"))); quitButton.setFontSize(32); - quitButton.addClickCommands(source -> close()); + quitButton.addClickCommands(source -> ifTopDialog(this::close)); // Zentriere das Popup