From 77b0207214302adfb8099b8b6ba7bf4ceef8b9ea Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Fri, 6 Dec 2024 08:56:21 +0100 Subject: [PATCH] Updated 'TurnState' class. Updated the 'TurnState' class by adding the 'SelectedPiecesMessage', 'NoPowerCardMessage', 'RequestDieMessage' and 'ReuqestMoveMessage' handling to it. --- .../mdga/server/automaton/game/TurnState.java | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/TurnState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/TurnState.java index 11c8de5b..4ed6feb8 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/TurnState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/TurnState.java @@ -1,6 +1,10 @@ package pp.mdga.server.automaton.game; import pp.mdga.game.Player; +import pp.mdga.message.client.NoPowerCardMessage; +import pp.mdga.message.client.RequestDieMessage; +import pp.mdga.message.client.RequestMoveMessage; +import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.server.ServerGameLogic; import pp.mdga.server.automaton.GameState; import pp.mdga.server.automaton.game.turn.ChoosePieceState; @@ -49,8 +53,9 @@ public TurnState(GameState gameAutomaton, ServerGameLogic logic) { @Override public void enter() { - LOGGER.log(Level.DEBUG, "Entered TurnState state."); + LOGGER.log(Level.INFO, "Entered TurnState state."); this.player = this.logic.getGame().getPlayerById(this.logic.getGame().getActivePlayerId()); + this.setCurrentState(this.powerCardState); } @Override @@ -58,6 +63,54 @@ public void exit() { LOGGER.log(Level.DEBUG, "Exited TurnState state."); } + /** + * This method will be called whenever the server received an SelectedPiecesMessage message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a SelectedPiecesMessage object. + * @param from as the client id of the player as an Integer. + */ + @Override + public void received(SelectedPiecesMessage msg, int from) { + this.currentState.received(msg, from); + } + + /** + * This method will be called whenever the server received an NoPowerCardMessage message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a NoPowerCardMessage object. + * @param from as the client id of the player as an Integer. + */ + @Override + public void received(NoPowerCardMessage msg, int from) { + this.currentState.received(msg, from); + } + + /** + * This method will be called whenever the server received a RequestDieMessage message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a RequestDieMessage object. + * @param from as the client id of the player as an Integer. + */ + @Override + public void received(RequestDieMessage msg, int from) { + this.currentState.received(msg, from); + } + + /** + * This method will be called whenever the server received a RequestMoveMessage message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a RequestMoveMessage object. + * @param from as the client id of the player as an Integer. + */ + @Override + public void received(RequestMoveMessage msg, int from) { + this.currentState.received(msg, from); + } + /** * This method will be used to return currentState attribute of TurnState class. *