From 29e9b54cc42ede9862acb2d8855273db8ca7d477 Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Sun, 1 Dec 2024 21:24:33 +0100 Subject: [PATCH] trigger NoMoneyPopUp --- .../client/src/main/java/pp/monopoly/client/gui/TestWorld.java | 2 ++ .../src/main/java/pp/monopoly/game/client/ClientGameLogic.java | 2 ++ .../model/src/main/java/pp/monopoly/game/server/Player.java | 1 + 3 files changed, 5 insertions(+) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java index a39684c..90c9064 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java @@ -294,6 +294,8 @@ public class TestWorld implements GameEventListener { new ConfirmTrade(app).open(); } else if (event.msg().equals("goingToJail")) { new Gulag(app).open(); + } else if (event.msg().equals("NoMoneyWarning")) { + new NoMoneyWarning(app).open(); } } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java index 841e7d9..39314eb 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java @@ -345,6 +345,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker { notifyListeners(new PopUpEvent("rent", msg)); } else if (msg.getKeyWord().equals("jailpay")) { notifyListeners(new PopUpEvent(msg.getKeyWord(), msg)); + } else if(msg.getKeyWord().equals("NoMoneyWarning")) { + notifyListeners(new PopUpEvent("NoMoneyWarning", msg)); } } } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/Player.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/Player.java index b3cd33b..eabfa99 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/Player.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/Player.java @@ -332,6 +332,7 @@ public class Player implements FieldVisitor{ public Void visit(BuildingProperty field) { if(field.getOwner() == null) { if (field.getPrice() <= accountBalance) getHandler().getLogic().send(this, new BuyPropertyRequest()); + else getHandler().getLogic().send(this, new NotificationMessage("NoMoneyWarning")); } else if (field.getOwner() != this){ int rent = field.calcRent(); field.getOwner().earnMoney(rent);