From f7149f225ce28bc1bbe6826b6f57d5de04010994 Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Wed, 13 Nov 2024 18:54:24 +0100 Subject: [PATCH] Interpreter fuer messages hinzugefuegt --- .../monopoly/game/client/ClientGameLogic.java | 77 +++++++++++++++++++ .../monopoly/game/server/ServerGameLogic.java | 49 ++++++++++++ .../message/client/ClientInterpreter.java | 54 +++++++++++++ .../message/server/ServerInterpreter.java | 76 ++++++++++++++++++ .../{TradeResponse.java => TradeRequest.java} | 2 +- 5 files changed, 257 insertions(+), 1 deletion(-) rename Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/{TradeResponse.java => TradeRequest.java} (89%) 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 13d20e3..d805f6c 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 @@ -8,7 +8,18 @@ package pp.monopoly.game.client; import pp.monopoly.message.client.ClientMessage; +import pp.monopoly.message.server.BuyPropertyResponse; +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.PlayerStatusUpdate; import pp.monopoly.message.server.ServerInterpreter; +import pp.monopoly.message.server.TimeOutWarning; +import pp.monopoly.message.server.TradeRequest; +import pp.monopoly.message.server.UpdatePlayerAssets; +import pp.monopoly.message.server.ViewAssetsResponse; import pp.monopoly.model.IntPoint; import pp.monopoly.model.Board; import pp.monopoly.notification.ClientStateEvent; @@ -170,4 +181,70 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker { public void update(float delta) { state.update(delta); } + + @Override + public void received(BuyPropertyResponse msg) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(DiceResult msg) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(EventDrawCard msg) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(GameOver msg) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(GameStart msg) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(JailEvent msg) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(PlayerStatusUpdate msg) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(TimeOutWarning msg) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(TradeRequest msg) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(UpdatePlayerAssets msg) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(ViewAssetsResponse msg) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } } 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 35279b6..31b241b 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 @@ -8,7 +8,14 @@ package pp.monopoly.game.server; import pp.monopoly.MonopolyConfig; +import pp.monopoly.message.client.BuyPropertyRequest; import pp.monopoly.message.client.ClientInterpreter; +import pp.monopoly.message.client.EndTurn; +import pp.monopoly.message.client.PlayerReady; +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.ServerMessage; import pp.monopoly.model.IntPoint; @@ -122,4 +129,46 @@ public class ServerGameLogic implements ClientInterpreter { throw new UnsupportedOperationException("Unimplemented method"); } + @Override + public void received(BuyPropertyRequest msg, int from) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(EndTurn msg, int from) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(PlayerReady msg, int from) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(RollDice msg, int from) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(TradeOffer msg, int from) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(TradeResponse msg, int from) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + + @Override + public void received(ViewAssetsRequest msg, int from) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'received'"); + } + } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/ClientInterpreter.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/ClientInterpreter.java index 91c274b..cb83ff6 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/ClientInterpreter.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/ClientInterpreter.java @@ -11,5 +11,59 @@ package pp.monopoly.message.client; * Visitor interface for processing all client messages. */ public interface ClientInterpreter { + /** + * Processes a received BuyPropertyRequest. + * + * @param msg the BuyPropertyRequest to be processed + * @param from the connection ID from which the message was received + */ + void received(BuyPropertyRequest msg, int from); + /** + * Processes a received EndTurn. + * + * @param msg the EndTurn to be processed + * @param from the connection ID from which the message was received + */ + void received(EndTurn msg, int from); + + /** + * Processes a received PlayerReady. + * + * @param msg the PlayerReady to be processed + * @param from the connection ID from which the message was received + */ + void received(PlayerReady msg, int from); + + /** + * Processes a received RollDice. + * + * @param msg the RollDice to be processed + * @param from the connection ID from which the message was received + */ + void received(RollDice msg, int from); + + /** + * Processes a received TradeOffer. + * + * @param msg the TradeOffer to be processed + * @param from the connection ID from which the message was received + */ + void received(TradeOffer msg, int from); + + /** + * Processes a received TradeResponse. + * + * @param msg the TradeResponse to be processed + * @param from the connection ID from which the message was received + */ + void received(TradeResponse msg, int from); + + /** + * Processes a received ViewAssetsRequest. + * + * @param msg the ViewAssetsRequest to be processed + * @param from the connection ID from which the message was received + */ + void received(ViewAssetsRequest msg, int from); } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/ServerInterpreter.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/ServerInterpreter.java index 73a3359..d99cd42 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/ServerInterpreter.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/ServerInterpreter.java @@ -13,4 +13,80 @@ package pp.monopoly.message.server; */ public interface ServerInterpreter { + /** + * Handles a BuyPropertyResponse message received from the server. + * + * @param msg the BuyPropertyResponse message received + */ + void received(BuyPropertyResponse msg); + + /** + * Handles a DiceResult message received from the server. + * + * @param msg the DiceResult message received + */ + void received(DiceResult msg); + + /** + * Handles a EventDrawCard message received from the server. + * + * @param msg the EventDrawCard message received + */ + void received(EventDrawCard msg); + + /** + * Handles a GameOver message received from the server. + * + * @param msg the GameOver message received + */ + void received(GameOver msg); + + /** + * Handles a GameStart message received from the server. + * + * @param msg the GameStart message received + */ + void received(GameStart msg); + + /** + * Handles a JailEvent message received from the server. + * + * @param msg the JailEvent message received + */ + void received(JailEvent msg); + + /** + * Handles a PlayerStatusUpdate message received from the server. + * + * @param msg the PlayerStatusUpdate message received + */ + void received(PlayerStatusUpdate msg); + + /** + * Handles a TimeOutWarning message received from the server. + * + * @param msg the TimeOutWarning message received + */ + void received(TimeOutWarning msg); + + /** + * Handles a TradeRequest message received from the server. + * + * @param msg the TradeRequest message received + */ + void received(TradeRequest msg); + + /** + * Handles a UpdatePlayerAssets message received from the server. + * + * @param msg the UpdatePlayerAssets message received + */ + void received(UpdatePlayerAssets msg); + + /** + * Handles a ViewAssetsResponse message received from the server. + * + * @param msg the ViewAssetsResponse message received + */ + void received(ViewAssetsResponse msg); } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeResponse.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeRequest.java similarity index 89% rename from Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeResponse.java rename to Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeRequest.java index 5a16522..cffd567 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeResponse.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeRequest.java @@ -1,6 +1,6 @@ package pp.monopoly.message.server; -public class TradeResponse extends ServerMessage{ +public class TradeRequest extends ServerMessage{ @Override public void accept(ServerInterpreter interpreter) {