merge Development into test #27
@@ -25,10 +25,10 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
* States
|
||||
*/
|
||||
private ServerState currentState;
|
||||
private final ServerState lobbyState;
|
||||
private final ServerState gameState;
|
||||
private final ServerState interruptState;
|
||||
private final ServerState ceremonyState;
|
||||
private final LobbyState lobbyState;
|
||||
private final GameState gameState;
|
||||
private final InterruptState interruptState;
|
||||
private final CeremonyState ceremonyState;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -167,36 +167,36 @@ public ServerState getCurrentState() {
|
||||
/**
|
||||
* This method will be used to return lobbyState attribute of ServerGameLogic class.
|
||||
*
|
||||
* @return lobbyState as a ServerState object.
|
||||
* @return lobbyState as a LobbyState object.
|
||||
*/
|
||||
public ServerState getLobbyState() {
|
||||
public LobbyState getLobbyState() {
|
||||
return this.lobbyState;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return gameState attribute of ServerGameLogic class.
|
||||
*
|
||||
* @return gameState as a ServerState object.
|
||||
* @return gameState as a GameState object.
|
||||
*/
|
||||
public ServerState getGameState() {
|
||||
public GameState getGameState() {
|
||||
return this.gameState;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return interruptState attribute of ServerGameLogic class.
|
||||
*
|
||||
* @return interruptState as a ServerState object.
|
||||
* @return interruptState as a InterruptState object.
|
||||
*/
|
||||
public ServerState getInterruptState() {
|
||||
public InterruptState getInterruptState() {
|
||||
return this.interruptState;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return ceremonyState attribute of ServerGameLogic class.
|
||||
*
|
||||
* @return ceremonyState as a ServerState object.
|
||||
* @return ceremonyState as a CeremonyState object.
|
||||
*/
|
||||
public ServerState getCeremonyState() {
|
||||
public CeremonyState getCeremonyState() {
|
||||
return this.ceremonyState;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public abstract class GameAutomatonState extends ServerState {
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
* @param gameAutomaton as the automaton of the game state as a GameState object.
|
||||
* @param logic the game logic
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public GameAutomatonState(GameState gameAutomaton, ServerGameLogic logic) {
|
||||
super(logic);
|
||||
|
||||
@@ -2,8 +2,23 @@
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.GameState;
|
||||
import pp.mdga.server.automaton.game.turn.*;
|
||||
|
||||
/**
|
||||
* This class represents the turn state of the server state automaton.
|
||||
* It will also be used as the turn automaton.
|
||||
*/
|
||||
public class TurnState extends GameAutomatonState {
|
||||
/**
|
||||
* Create TurnState states.
|
||||
*/
|
||||
private TurnAutomatonState currentState;
|
||||
private final PowerCardState powerCardState;
|
||||
private final PlayPowerCardState playPowerCardState;
|
||||
private final RollDiceState rollDiceState;
|
||||
private final ChoosePieceState choosePieceState;
|
||||
private final MovePieceState movePieceState;
|
||||
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
@@ -12,6 +27,11 @@ public class TurnState extends GameAutomatonState {
|
||||
*/
|
||||
public TurnState(GameState gameAutomaton, ServerGameLogic logic) {
|
||||
super(gameAutomaton, logic);
|
||||
this.powerCardState = new PowerCardState(this, logic);
|
||||
this.playPowerCardState = new PlayPowerCardState(this, logic);
|
||||
this.rollDiceState = new RollDiceState(this, logic);
|
||||
this.choosePieceState = new ChoosePieceState(this, logic);
|
||||
this.movePieceState = new MovePieceState(this, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -23,4 +43,72 @@ public void enter() {
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return currentState attribute of TurnState class.
|
||||
*
|
||||
* @return currentState as a TurnAutomatonState object.
|
||||
*/
|
||||
public TurnAutomatonState getCurrentState() {
|
||||
return this.currentState;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return powerCardState attribute of TurnState class.
|
||||
*
|
||||
* @return powerCardState as a PowerCardState object.
|
||||
*/
|
||||
public PowerCardState getPowerCardState() {
|
||||
return this.powerCardState;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return playPowerCardState attribute of TurnState class.
|
||||
*
|
||||
* @return playPowerState as a PlayPowerCardState object.
|
||||
*/
|
||||
public PlayPowerCardState getPlayPowerCardState() {
|
||||
return this.playPowerCardState;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return rollDiceState attribute of TurnState class.
|
||||
*
|
||||
* @return rollDiceState as a RollDiceState object.
|
||||
*/
|
||||
public RollDiceState getRollDiceState() {
|
||||
return this.rollDiceState;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return choosePieceState attribute of TurnState class.
|
||||
*
|
||||
* @return choosePieceState as a ChoosePieceState object.
|
||||
*/
|
||||
public ChoosePieceState getChoosePieceState() {
|
||||
return this.choosePieceState;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return movePieceState attribute of TurnState class.
|
||||
*
|
||||
* @return movePieceState as a MovePieceState object.
|
||||
*/
|
||||
public MovePieceState getMovePieceState() {
|
||||
return this.movePieceState;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param state as the new currentState attribute as a TurnAutomatonState object.
|
||||
*/
|
||||
public void setCurrentState(TurnAutomatonState state) {
|
||||
if (this.currentState != null) {
|
||||
this.currentState.exit();
|
||||
}
|
||||
this.currentState = state;
|
||||
this.currentState.enter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,5 +3,24 @@
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.TurnState;
|
||||
|
||||
public class ChoosePieceState {
|
||||
public class ChoosePieceState extends TurnAutomatonState {
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
* @param turnAutomaton as the automaton of the turn state as a GameState object.
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public ChoosePieceState(TurnState turnAutomaton, ServerGameLogic logic) {
|
||||
super(turnAutomaton, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,25 @@
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.TurnState;
|
||||
|
||||
public class MovePieceState {
|
||||
public class MovePieceState extends TurnAutomatonState {
|
||||
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
* @param turnAutomaton as the automaton of the turn state as a GameState object.
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public MovePieceState(TurnState turnAutomaton, ServerGameLogic logic) {
|
||||
super(turnAutomaton, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package pp.mdga.server.automaton.game.turn;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.TurnState;
|
||||
|
||||
public class PlayPowerCardState extends TurnAutomatonState {
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
* @param turnAutomaton as the automaton of the turn state as a GameState object.
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public PlayPowerCardState(TurnState turnAutomaton, ServerGameLogic logic) {
|
||||
super(turnAutomaton, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,5 +3,24 @@
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.TurnState;
|
||||
|
||||
public class PowerCardState {
|
||||
public class PowerCardState extends TurnAutomatonState {
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
* @param turnAutomaton as the automaton of the turn state as a GameState object.
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public PowerCardState(TurnState turnAutomaton, ServerGameLogic logic) {
|
||||
super(turnAutomaton, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,5 +3,24 @@
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.TurnState;
|
||||
|
||||
public class RollDiceState {
|
||||
public class RollDiceState extends TurnAutomatonState {
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
* @param turnAutomaton as the automaton of the turn state as a GameState object.
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public RollDiceState(TurnState turnAutomaton, ServerGameLogic logic) {
|
||||
super(turnAutomaton, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package pp.mdga.server.automaton.game.turn;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.ServerState;
|
||||
import pp.mdga.server.automaton.game.TurnState;
|
||||
|
||||
public abstract class TurnAutomatonState extends ServerState {
|
||||
/**
|
||||
* Create TurnAutomatonState attributes.
|
||||
*/
|
||||
protected final TurnState turnAutomaton;
|
||||
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
* @param turnAutomaton as the automaton of the turn state as a GameState object.
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public TurnAutomatonState(TurnState turnAutomaton, ServerGameLogic logic) {
|
||||
super(logic);
|
||||
this.turnAutomaton = turnAutomaton;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package pp.mdga.server.automaton.game.turn.choosepiece;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.ServerState;
|
||||
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
|
||||
|
||||
public abstract class ChoosePieceAutomatonState extends ServerState {
|
||||
/**
|
||||
* Create ChoosePieceAutomatonState attributes.
|
||||
*/
|
||||
protected final ChoosePieceState choosePieceAutomaton;
|
||||
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public ChoosePieceAutomatonState(ChoosePieceState choosePieceAutomaton, ServerGameLogic logic) {
|
||||
super(logic);
|
||||
this.choosePieceAutomaton = choosePieceAutomaton;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package pp.mdga.server.automaton.game.turn.rolldice;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.ServerState;
|
||||
import pp.mdga.server.automaton.game.turn.RollDiceState;
|
||||
|
||||
public abstract class RollDiceAutomatonState extends ServerState {
|
||||
/**
|
||||
* Create RollDiceAutomatonState attributes.
|
||||
*/
|
||||
protected final RollDiceState rollDiceAutomaton;
|
||||
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public RollDiceAutomatonState(RollDiceState rollDiceAutomaton, ServerGameLogic logic) {
|
||||
super(logic);
|
||||
this.rollDiceAutomaton = rollDiceAutomaton;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user