From dd002746aa1b59845d3d2739b7592b19359a4bec Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Sun, 1 Dec 2024 20:52:29 +0100 Subject: [PATCH] trigger winner and looser popup --- .../src/main/java/pp/monopoly/game/server/Player.java | 1 + .../main/java/pp/monopoly/game/server/ServerGameLogic.java | 7 +++++++ .../src/main/java/pp/monopoly/server/MonopolyServer.java | 2 ++ 3 files changed, 10 insertions(+) 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 6e220b2..920b8fe 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 @@ -494,6 +494,7 @@ public class Player implements FieldVisitor{ */ private static int rollDice() { return random.nextInt(6) + 1; + // return 3; } } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java index f09feb0..6156ba2 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java @@ -20,6 +20,7 @@ import pp.monopoly.message.client.RollDice; import pp.monopoly.message.client.TradeOffer; import pp.monopoly.message.client.TradeResponse; import pp.monopoly.message.client.ViewAssetsRequest; +import pp.monopoly.message.server.GameOver; import pp.monopoly.message.server.GameStart; import pp.monopoly.message.server.NextPlayerTurn; import pp.monopoly.message.server.PlayerStatusUpdate; @@ -182,8 +183,14 @@ public class ServerGameLogic implements ClientInterpreter { send(next, new NextPlayerTurn()); send(next, new PlayerStatusUpdate(playerHandler)); send(player, new PlayerStatusUpdate(playerHandler)); + } else { + send(player, new GameOver(false)); + playerHandler.removePlayer(player); } } + if(playerHandler.getPlayers().size() == 1) { + send(playerHandler.getPlayerAtIndex(0), new GameOver(true)); + } updateAllPlayers(); } diff --git a/Projekte/monopoly/server/src/main/java/pp/monopoly/server/MonopolyServer.java b/Projekte/monopoly/server/src/main/java/pp/monopoly/server/MonopolyServer.java index 2fa1a50..ac65ca7 100644 --- a/Projekte/monopoly/server/src/main/java/pp/monopoly/server/MonopolyServer.java +++ b/Projekte/monopoly/server/src/main/java/pp/monopoly/server/MonopolyServer.java @@ -41,6 +41,7 @@ import pp.monopoly.message.client.ViewAssetsRequest; import pp.monopoly.message.server.BuyPropertyRequest; import pp.monopoly.message.server.DiceResult; import pp.monopoly.message.server.EventDrawCard; +import pp.monopoly.message.server.GameOver; import pp.monopoly.message.server.GameStart; import pp.monopoly.message.server.JailEvent; import pp.monopoly.message.server.NextPlayerTurn; @@ -176,6 +177,7 @@ public class MonopolyServer implements MessageListener, Connec Serializer.registerClass(NotificationMessage.class); Serializer.registerClass(JailEvent.class); Serializer.registerClass(AlterProperty.class); + Serializer.registerClass(GameOver.class); } private void registerListeners() {