From aafc804c3f0f99c7da5ecc755b40484fd752ac7d Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Sun, 1 Dec 2024 23:26:53 +0100 Subject: [PATCH 1/3] Updated 'ChoosePieceState' class. Updated the 'ChoosePieceState' to work correctly as a state automaton. --- .../automaton/game/turn/ChoosePieceState.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/ChoosePieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/ChoosePieceState.java index cb0e04c4..0ee5f273 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/ChoosePieceState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/ChoosePieceState.java @@ -2,6 +2,7 @@ import pp.mdga.server.ServerGameLogic; import pp.mdga.server.automaton.game.TurnState; +import pp.mdga.server.automaton.game.turn.choosepiece.*; public class ChoosePieceState extends TurnAutomatonState { /** @@ -9,6 +10,16 @@ public class ChoosePieceState extends TurnAutomatonState { */ private static final System.Logger LOGGER = System.getLogger(ChoosePieceState.class.getName()); + /** + * Create ChoosePieceState attributes. + */ + private ChoosePieceAutomatonState currentState; + private final NoPieceState noPieceState; + private final NoTurnState noTurnState; + private final WaitingPieceState waitingPieceState; + private final StartPieceState startPieceState; + private final SelectPieceState selectPieceState; + /** * Constructs a server state of the specified game logic. * @@ -17,6 +28,12 @@ public class ChoosePieceState extends TurnAutomatonState { */ public ChoosePieceState(TurnState turnAutomaton, ServerGameLogic logic) { super(turnAutomaton, logic); + this.noPieceState = new NoPieceState(this, logic); + this.noTurnState = new NoTurnState(this, logic); + this.waitingPieceState = new WaitingPieceState(this, logic); + this.startPieceState = new StartPieceState(this, logic); + this.selectPieceState = new SelectPieceState(this, logic); + this.setCurrentState(this.noPieceState); } @Override @@ -28,4 +45,27 @@ public void enter() { public void exit() { LOGGER.log(System.Logger.Level.DEBUG, "Entered ChoosePieceState state."); } + + /** + * This method will be used to return currentState attribute of ChoosePieceState class. + * + * @return currentState as a + */ + public ChoosePieceAutomatonState getCurrentState() { + return this.currentState; + } + + /** + * This method will be used to set currentState attribute of ChoosePieceState class to the given state parameter. + * In Addition, the currentState will be exited, changed and entered. + * + * @param state as the new currentState attribute as a ChoosePieceAutomatonState object. + */ + public void setCurrentState(ChoosePieceAutomatonState state) { + if (this.currentState != null) { + this.currentState.exit(); + } + this.currentState = state; + this.currentState.enter(); + } } -- 2.43.0 From e68369074f24177ddbab8e145e334b192fbc15fc Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Sun, 1 Dec 2024 23:27:45 +0100 Subject: [PATCH 2/3] Updated 'RollDiceState' class. Updated the 'RollDiceState' class by removing a spelling mistake. --- .../java/pp/mdga/server/automaton/game/turn/RollDiceState.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/RollDiceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/RollDiceState.java index 6a0ce0f8..0d4fd1e8 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/RollDiceState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/RollDiceState.java @@ -32,6 +32,7 @@ public RollDiceState(TurnState turnAutomaton, ServerGameLogic logic) { this.firstRollState = new FirstRollState(this, logic); this.secondRollState = new SecondRollState(this, logic); this.thirdRollState = new ThirdRollState(this, logic); + this.setCurrentState(this.firstRollState); } @Override @@ -58,7 +59,7 @@ public RollDiceAutomatonState getCurrentState() { * * @return firstRollState as a FirstRollState object. */ - public FirstRollState getFirstRollStateState() { + public FirstRollState getFirstRollState() { return this.firstRollState; } -- 2.43.0 From 02d7ef1dd8a4464c772c0855ad9629066405c1a4 Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Sun, 1 Dec 2024 23:28:50 +0100 Subject: [PATCH 3/3] Updated 'ChoosePieceState' class. Updated the 'ChoosePieceState' to work correctly as a state automaton. --- .../automaton/game/turn/ChoosePieceState.java | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/ChoosePieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/ChoosePieceState.java index 0ee5f273..63479370 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/ChoosePieceState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/ChoosePieceState.java @@ -49,12 +49,57 @@ public void exit() { /** * This method will be used to return currentState attribute of ChoosePieceState class. * - * @return currentState as a + * @return currentState as a ChoosePieceAutomatonState object. */ public ChoosePieceAutomatonState getCurrentState() { return this.currentState; } + /** + * This method will be used to return noPieceState attribute of ChoosePieceState class. + * + * @return noPieceState as a NoOPieceState object. + */ + public NoPieceState getNoPieceState() { + return this.noPieceState; + } + + /** + * This method will be used to return noTurnState attribute of ChoosePieceState class. + * + * @return noTurnState as a NoTurnState object. + */ + public NoTurnState getNoTurnState() { + return this.noTurnState; + } + + /** + * This method will be used to return waitingPieceState attribute of ChoosePieceState class. + * + * @return waitingPieceState as a WaitingPieceState object. + */ + public WaitingPieceState getWaitingPieceState() { + return this.waitingPieceState; + } + + /** + * This method will be used to return startPieceState attribute of ChoosePieceState class. + * + * @return startPieceState as a StartPieceState object. + */ + public StartPieceState getStartPieceState() { + return this.startPieceState; + } + + /** + * This method will be used to return selectPieceState attribute of ChoosePieceState class. + * + * @return selectPieceState as a SelectPieceState object. + */ + public SelectPieceState getSelectPieceState() { + return this.selectPieceState; + } + /** * This method will be used to set currentState attribute of ChoosePieceState class to the given state parameter. * In Addition, the currentState will be exited, changed and entered. -- 2.43.0