From 9b4cac4e56b071ca8512862c78060973d31abf5c Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Sun, 24 Nov 2024 16:51:00 +0100 Subject: [PATCH] send PlayerHandler when starting game --- .../pp/monopoly/game/client/ClientGameLogic.java | 10 +++++----- .../pp/monopoly/game/server/ServerGameLogic.java | 2 +- .../java/pp/monopoly/message/server/GameStart.java | 14 ++++++-------- 3 files changed, 12 insertions(+), 14 deletions(-) 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 2eccfa6..ad93f0e 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 @@ -5,7 +5,7 @@ import java.lang.System.Logger.Level; import java.util.ArrayList; import java.util.List; -import pp.monopoly.game.server.Player; +import pp.monopoly.game.server.PlayerHandler; import pp.monopoly.message.client.ClientMessage; import pp.monopoly.message.server.BuyPropertyResponse; import pp.monopoly.message.server.DiceResult; @@ -51,7 +51,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker { /** The current state of the client game logic. */ private ClientState state = new LobbyState(this); - private List players; + private PlayerHandler playerHandler; /** * Constructs a ClientGameLogic with the specified sender object. @@ -83,8 +83,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker { state.entry(); } - public List getPlayers() { - return players; + public PlayerHandler getPlayerHandler() { + return playerHandler; } /** @@ -243,7 +243,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker { */ @Override public void received(GameStart msg) { - players = msg.getPlayers(); + playerHandler = msg.getPlayerHandler(); setInfoText("The game has started! Good luck!"); setState(new WaitForTurnState(this)); } 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 a901fac..53555a5 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 @@ -204,7 +204,7 @@ public class ServerGameLogic implements ClientInterpreter { if(playerHandler.allPlayersReady()) { playerHandler.setStartBalance(startMoney); for (Player p : playerHandler.getPlayers()) { - send(p, new GameStart(playerHandler.getPlayers())); + send(p, new GameStart(playerHandler)); } playerHandler.randomOrder(); send(playerHandler.getPlayerAtIndex(0), new NextPlayerTurn(playerHandler.getPlayerAtIndex(0))); diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameStart.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameStart.java index cfdfe54..17679e5 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameStart.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameStart.java @@ -1,19 +1,17 @@ package pp.monopoly.message.server; -import java.util.List; - -import pp.monopoly.game.server.Player; +import pp.monopoly.game.server.PlayerHandler; public class GameStart extends ServerMessage{ - private final List players; + private final PlayerHandler ph; - public GameStart(List players) { - this.players = players; + public GameStart(PlayerHandler ph) { + this.ph = ph; } - public List getPlayers() { - return players; + public PlayerHandler getPlayerHandler() { + return ph; } @Override