Updated 'TurnState' class.

Updated the 'TurnState' class by adding the 'player' attribute and its getter method to it.
This commit is contained in:
Daniel Grigencha
2024-12-06 00:50:48 +01:00
parent 84776c71b2
commit dd95356abd

View File

@@ -1,5 +1,6 @@
package pp.mdga.server.automaton.game;
import pp.mdga.game.Player;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.GameState;
import pp.mdga.server.automaton.game.turn.*;
@@ -22,6 +23,7 @@ public class TurnState extends GameAutomatonState {
private final RollDiceState rollDiceState;
private final ChoosePieceState choosePieceState;
private final MovePieceState movePieceState;
private Player player;
/**
* Constructs a server state of the specified game logic.
@@ -42,6 +44,7 @@ public TurnState(GameState gameAutomaton, ServerGameLogic logic) {
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered TurnState state.");
this.player = this.logic.getGame().getPlayerById(this.logic.getGame().getActivePlayerId());
}
@Override
@@ -103,6 +106,15 @@ public MovePieceState getMovePieceState() {
return this.movePieceState;
}
/**
* This method will be used to return player attribute of TurnState class.
*
* @return player as a Player object.
*/
public Player getPlayer() {
return this.player;
}
/**
* This method will be used to set currentState attribute of TurnState class to the given state parameter.
* In Addition, the currentState will be exited, changed and entered.