merge dev int test #29

Merged
j23f0712 merged 4 commits from development into dev/test 2024-12-01 23:33:43 +01:00
Showing only changes of commit aafc804c3f - Show all commits

View File

@@ -2,6 +2,7 @@
import pp.mdga.server.ServerGameLogic; import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.TurnState; import pp.mdga.server.automaton.game.TurnState;
import pp.mdga.server.automaton.game.turn.choosepiece.*;
public class ChoosePieceState extends TurnAutomatonState { 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()); 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. * Constructs a server state of the specified game logic.
* *
@@ -17,6 +28,12 @@ public class ChoosePieceState extends TurnAutomatonState {
*/ */
public ChoosePieceState(TurnState turnAutomaton, ServerGameLogic logic) { public ChoosePieceState(TurnState turnAutomaton, ServerGameLogic logic) {
super(turnAutomaton, 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 @Override
@@ -28,4 +45,27 @@ public void enter() {
public void exit() { public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered ChoosePieceState state."); 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();
}
} }