From 628b98af9b7796882de4f394eab49c719f18a21e Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Sat, 16 Nov 2024 18:03:19 +0100 Subject: [PATCH] recive logic for messages --- .../message/client/BuyPropertyRequest.java | 3 +-- .../java/pp/monopoly/message/client/EndTurn.java | 3 +-- .../pp/monopoly/message/client/PlayerReady.java | 3 +-- .../java/pp/monopoly/message/client/RollDice.java | 3 +-- .../pp/monopoly/message/client/TradeOffer.java | 3 +-- .../pp/monopoly/message/client/TradeResponse.java | 3 +-- .../monopoly/message/client/ViewAssetsRequest.java | 3 +-- .../pp/monopoly/message/server/DiceResult.java | 7 +++++-- .../pp/monopoly/message/server/EventDrawCard.java | 3 +-- .../java/pp/monopoly/message/server/GameOver.java | 3 +-- .../java/pp/monopoly/message/server/GameStart.java | 3 +-- .../java/pp/monopoly/message/server/JailEvent.java | 3 +-- .../message/server/PlayerStatusUpdate.java | 3 +-- .../monopoly/message/server/ServerInterpreter.java | 14 ++++++++++++++ .../pp/monopoly/message/server/TimeOutWarning.java | 3 +-- .../pp/monopoly/message/server/TradeReply.java | 3 +-- .../pp/monopoly/message/server/TradeRequest.java | 3 +-- .../message/server/UpdatePlayerAssets.java | 3 +-- .../message/server/ViewAssetsResponse.java | 3 +-- 19 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/BuyPropertyRequest.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/BuyPropertyRequest.java index 4085311..12a6bc9 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/BuyPropertyRequest.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/BuyPropertyRequest.java @@ -26,7 +26,6 @@ public class BuyPropertyRequest extends ClientMessage{ @Override public void accept(ClientInterpreter interpreter, int from) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this, from); } } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/EndTurn.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/EndTurn.java index a996818..dae8120 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/EndTurn.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/EndTurn.java @@ -6,8 +6,7 @@ public class EndTurn extends ClientMessage{ @Override public void accept(ClientInterpreter interpreter, int from) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this, from); } } \ No newline at end of file diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/PlayerReady.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/PlayerReady.java index 067c104..1d4a417 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/PlayerReady.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/PlayerReady.java @@ -26,7 +26,6 @@ public class PlayerReady extends ClientMessage{ @Override public void accept(ClientInterpreter interpreter, int from) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this, from); } } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/RollDice.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/RollDice.java index 141adb5..9fb0b93 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/RollDice.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/RollDice.java @@ -6,8 +6,7 @@ public class RollDice extends ClientMessage{ @Override public void accept(ClientInterpreter interpreter, int from) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this, from); } } \ No newline at end of file diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/TradeOffer.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/TradeOffer.java index d3369d1..b614365 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/TradeOffer.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/TradeOffer.java @@ -26,8 +26,7 @@ public class TradeOffer extends ClientMessage{ @Override public void accept(ClientInterpreter interpreter, int from) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this, from); } } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/TradeResponse.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/TradeResponse.java index 9d3395c..d317c6f 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/TradeResponse.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/TradeResponse.java @@ -27,7 +27,6 @@ public class TradeResponse extends ClientMessage{ @Override public void accept(ClientInterpreter interpreter, int from) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this, from); } } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/ViewAssetsRequest.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/ViewAssetsRequest.java index a6eecde..f78d778 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/ViewAssetsRequest.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/ViewAssetsRequest.java @@ -6,8 +6,7 @@ public class ViewAssetsRequest extends ClientMessage{ @Override public void accept(ClientInterpreter interpreter, int from) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this, from); } } \ No newline at end of file diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/DiceResult.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/DiceResult.java index 1a00cb1..53a137e 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/DiceResult.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/DiceResult.java @@ -16,8 +16,7 @@ public class DiceResult extends ServerMessage{ @Override public void accept(ServerInterpreter interpreter) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this); } @Override @@ -26,4 +25,8 @@ public class DiceResult extends ServerMessage{ throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'"); } + public boolean isDoublets() { + return rollResult.get(0) == rollResult.get(1); + } + } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/EventDrawCard.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/EventDrawCard.java index 90ef339..7ed4938 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/EventDrawCard.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/EventDrawCard.java @@ -4,8 +4,7 @@ public class EventDrawCard extends ServerMessage{ @Override public void accept(ServerInterpreter interpreter) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this); } @Override diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameOver.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameOver.java index 486fa88..9b2cff3 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameOver.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameOver.java @@ -4,8 +4,7 @@ public class GameOver extends ServerMessage{ @Override public void accept(ServerInterpreter interpreter) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this); } @Override 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 0855fef..bf39031 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 @@ -4,8 +4,7 @@ public class GameStart extends ServerMessage{ @Override public void accept(ServerInterpreter interpreter) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this); } @Override diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/JailEvent.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/JailEvent.java index 8c04ead..a802398 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/JailEvent.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/JailEvent.java @@ -4,8 +4,7 @@ public class JailEvent extends ServerMessage{ @Override public void accept(ServerInterpreter interpreter) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this); } @Override diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/PlayerStatusUpdate.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/PlayerStatusUpdate.java index 692a25d..8b51066 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/PlayerStatusUpdate.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/PlayerStatusUpdate.java @@ -4,8 +4,7 @@ public class PlayerStatusUpdate extends ServerMessage{ @Override public void accept(ServerInterpreter interpreter) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this); } @Override 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 770db4f..3480d20 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 @@ -82,4 +82,18 @@ public interface ServerInterpreter { * @param msg the ViewAssetsResponse message received */ void received(ViewAssetsResponse msg); + + /** + * Handles a TradeReply message received from the server. + * + * @param msg the TradeReply message received + */ + void received(TradeReply msg); + + /** + * Handles a TradeRequest message received from the server. + * + * @param msg the TradeRequest message received + */ + void received(TradeRequest msg); } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TimeOutWarning.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TimeOutWarning.java index 65e80c9..f9510a7 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TimeOutWarning.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TimeOutWarning.java @@ -4,8 +4,7 @@ public class TimeOutWarning extends ServerMessage{ @Override public void accept(ServerInterpreter interpreter) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this); } @Override diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeReply.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeReply.java index 5924542..6535906 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeReply.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeReply.java @@ -27,8 +27,7 @@ public class TradeReply extends ServerMessage{ @Override public void accept(ServerInterpreter interpreter) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this); } @Override diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeRequest.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeRequest.java index 323ad25..5320953 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeRequest.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeRequest.java @@ -27,8 +27,7 @@ public class TradeRequest extends ServerMessage{ @Override public void accept(ServerInterpreter interpreter) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this); } @Override diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/UpdatePlayerAssets.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/UpdatePlayerAssets.java index 782f695..e37c78c 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/UpdatePlayerAssets.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/UpdatePlayerAssets.java @@ -4,8 +4,7 @@ public class UpdatePlayerAssets extends ServerMessage{ @Override public void accept(ServerInterpreter interpreter) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this); } @Override diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/ViewAssetsResponse.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/ViewAssetsResponse.java index f1a9f08..116366e 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/ViewAssetsResponse.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/ViewAssetsResponse.java @@ -26,8 +26,7 @@ public class ViewAssetsResponse extends ServerMessage{ @Override public void accept(ServerInterpreter interpreter) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'accept'"); + interpreter.received(this); } @Override