Merge commit

This commit is contained in:
Felix
2024-11-27 08:44:29 +01:00
97 changed files with 1674 additions and 752 deletions

View File

@@ -1,17 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="MdgaApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="pp.mdga.client.MdgaApp" />
<module name="Projekte.mdga.client.main" />
<option name="VM_PARAMETERS" value="-Djava.util.logging.config.file=logging.properties -ea" />
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="pp.mdga.client.board.Outline.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -1,16 +1,19 @@
package pp.mdga.client; package pp.mdga.client;
import pp.mdga.client.ceremonyState.CeremonyStateMachine;
public class Ceremony extends ClientState { public class Ceremony extends ClientState {
private final CeremonyStateMachine ceremonyStateMachine;
public Ceremony(ClientState parent, ClientGameLogic logic) { public Ceremony(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
this.ceremonyStateMachine = new CeremonyStateMachine(parent, logic);
} }
public CeremonyStateMachine getCeremonyStateMachine() { @Override
return ceremonyStateMachine; public void enter() {
}
@Override
public void exit() {
} }
} }

View File

@@ -1,24 +0,0 @@
package pp.mdga.client;
public class ClientAutomaton extends ClientStateMachine {
private Dialogs dialogs;
private Ceremony ceremony;
private Game game;
private Interrupt interrupt;
public ClientAutomaton(ClientGameLogic logic){
super(null, logic);
dialogs = new Dialogs(this, logic);
ceremony = new Ceremony(this, logic);
game = new Game(this, logic);
entry();
}
@Override
public Dialogs initialState(){
return dialogs;
}
}

View File

@@ -1,6 +1,12 @@
package pp.mdga.client; package pp.mdga.client;
public abstract class ClientState implements Observer { import pp.mdga.game.Color;
import pp.mdga.message.server.*;
import java.lang.System.Logger.Level;
import java.util.UUID;
public abstract class ClientState implements Observer, ServerInterpreter {
protected static final System.Logger LOGGER = System.getLogger(ClientState.class.getName()); protected static final System.Logger LOGGER = System.getLogger(ClientState.class.getName());
protected ClientState parent; protected ClientState parent;
@@ -12,13 +18,9 @@ protected ClientState(ClientState parent, ClientGameLogic logic){
this.logic = logic; this.logic = logic;
} }
public void entry(){/* do nothing */} public abstract void enter();
public void exit() {/* do nothing*/} public abstract void exit();
public void gotoState(ClientState newState){
throw new IllegalStateException("not in a statemachine");
}
public ClientState getParent(){ public ClientState getParent(){
return parent; return parent;
@@ -30,4 +32,187 @@ public void update() {/* do nothing */}
public String toString(){ public String toString(){
return getClass().getSimpleName(); return getClass().getSimpleName();
} }
@Override
public void received(ActivePlayer msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(AnyPiece msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(Briefing msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(CeremonyMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(Die msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(DiceAgain msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(DiceNow msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(EndOfTurn msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(LobbyAccept msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(LobbyDeny msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(LobbyPlayerJoin msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(LobbyPlayerLeave msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(MoveMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(NoTurn msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(PauseGame msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(PlayCard msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(PossibleCard msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(PossiblePiece msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(RankingResponse msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(RankingRollAgain msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(ReconnectBriefing msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(ResumeGame msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(ServerStartGame msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(StartPiece msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(UpdateReady msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(UpdateTSK msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(WaitPiece msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
public void selectPiece(UUID id) {
LOGGER.log(Level.DEBUG, "Selecting piece not allowed.");
}
public void selectCard(UUID id) {
LOGGER.log(Level.DEBUG, "Selecting card not allowed.");
}
public void selectTSK(Color color) {
LOGGER.log(Level.DEBUG, "Selecting TSK not allowed.");
}
public void selectDice() {
LOGGER.log(Level.DEBUG, "Selecting dice not allowed.");
}
public void setName(String name) {
LOGGER.log(Level.DEBUG, "Setting name not allowed.");
}
public void selectReady() {
LOGGER.log(Level.DEBUG, "Selecting ready not allowed.");
}
public void selectHost() {
LOGGER.log(Level.DEBUG, "Selecting host not allowed.");
}
public void selectJoin() {
LOGGER.log(Level.DEBUG, "Selecting join not allowed.");
}
public void selectLeave() {
LOGGER.log(Level.DEBUG, "Selecting leave not allowed.");
}
public void deselectTSK(Color color) {
LOGGER.log(Level.DEBUG, "Deselecting TSK not allowed.");
}
public void selectUnready(){
LOGGER.log(Level.DEBUG, "Selecting unready not allowed.");
}
public void selectStart(){
LOGGER.log(Level.DEBUG, "Starting not allowed");
}
} }

View File

@@ -1,44 +0,0 @@
package pp.mdga.client;
public abstract class ClientStateMachine extends ClientState {
private ClientState state;
protected ClientStateMachine(ClientState parent, ClientGameLogic logic){
super(parent, logic);
}
public abstract ClientState initialState();
@Override
public void gotoState(ClientState newState){
LOGGER.log(System.Logger.Level.DEBUG, "{0}: {1} --> {2}", this, state, newState);
enter(newState);
}
@Override
public void entry(){
final ClientState newState = initialState();
LOGGER.log(System.Logger.Level.DEBUG, "{0}: initial state={1}", this, newState);
enter(newState);
}
private void enter(ClientState newState){
if(newState.parent != this)
throw new IllegalArgumentException("Wrong state: " + newState + " belongs to " + newState.parent + " instead of " + this);
state = newState;
state.entry();
}
@Override
public void exit(){state.exit();}
@Override
public String toString(){
return super.toString() + "(in " + state + ")";
}
public ClientState getState(){
return state;
}
}

View File

@@ -1,16 +1,53 @@
package pp.mdga.client; package pp.mdga.client;
import pp.mdga.client.dialogState.DialogsStateMachine; import pp.mdga.client.dialogState.DialogStates;
import pp.mdga.client.dialogState.Lobby;
import pp.mdga.client.dialogState.NetworkDialog;
import pp.mdga.client.dialogState.StartDialog;
public class Dialogs extends ClientState { public class Dialogs extends ClientState {
private final DialogsStateMachine dialogsStateMachine;
private DialogStates currentState;
private final Lobby lobby = new Lobby(this, logic);
private final NetworkDialog networkDialog = new NetworkDialog(this, logic);
private final StartDialog startDialog = new StartDialog(this, logic);
public Dialogs(ClientState parent, ClientGameLogic logic) { public Dialogs(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
this.dialogsStateMachine = new DialogsStateMachine(parent, logic);
} }
public DialogsStateMachine getDialogsStateMachine() { @Override
return dialogsStateMachine; public void exit(){
currentState.exit();
}
@Override
public void enter(){
currentState = startDialog;
}
public void setState(DialogStates newState){
currentState.exit();
currentState = newState;
currentState.enter();
}
public Lobby getLobby() {
return lobby;
}
public NetworkDialog getNetworkDialog() {
return networkDialog;
}
public StartDialog getStartDialog() {
return startDialog;
}
public void startGame(){
exit();
logic.setState(logic.getGameState());
} }
} }

View File

@@ -1,16 +0,0 @@
package pp.mdga.client;
import pp.mdga.client.gameState.GameStateMachine;
public class Game extends ClientState {
private final GameStateMachine gameStateMachine;
public Game(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.gameStateMachine = new GameStateMachine(parent, logic);
}
public GameStateMachine getGameStateMachine() {
return gameStateMachine;
}
}

View File

@@ -0,0 +1,29 @@
package pp.mdga.client;
import pp.mdga.client.gameState.*;
public class GameState extends ClientState {
private GameStates state;
private Animation animation = new Animation(this, logic);
private DetermineStartPlayer determineStartPlayer = new DetermineStartPlayer(this, logic);
private Spectator spectator = new Spectator(this, logic);
private Turn turn = new Turn(this, logic);
private Waiting waiting = new Waiting(this, logic);
public GameState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
state = determineStartPlayer;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -2,10 +2,17 @@
public class Interrupt extends ClientState { public class Interrupt extends ClientState {
private final Game lastState; public Interrupt(ClientState parent, ClientGameLogic logic) {
public Interrupt(ClientState parent, ClientGameLogic logic, Game lastState) {
super(parent, logic); super(parent, logic);
this.lastState = lastState; }
@Override
public void enter() {
}
@Override
public void exit() {
} }
} }

View File

@@ -1,16 +1,18 @@
package pp.mdga.client; package pp.mdga.client;
import pp.mdga.client.settingsState.SettingsStateMachine;
public class Settings extends ClientState { public class Settings extends ClientState {
private final SettingsStateMachine settingsStateMachine;
public Settings(ClientState parent, ClientGameLogic logic) { public Settings(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
this.settingsStateMachine = new SettingsStateMachine(parent, logic);
} }
public SettingsStateMachine getSettingsStateMachine() { @Override
return settingsStateMachine; public void enter() {
}
@Override
public void exit() {
} }
} }

View File

@@ -1,18 +0,0 @@
package pp.mdga.client.ceremonyState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.ClientStateMachine;
public class CeremonyStateMachine extends ClientStateMachine {
public CeremonyStateMachine(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public Podium initialState() {
return new Podium(this, logic);
}
}

View File

@@ -0,0 +1,10 @@
package pp.mdga.client.ceremonyState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public abstract class CeremonyStates extends ClientState {
protected CeremonyStates(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
}

View File

@@ -3,8 +3,18 @@
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
public class Podium extends ClientState { public class Podium extends CeremonyStates {
public Podium(ClientState parent, ClientGameLogic logic) { public Podium(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -3,8 +3,18 @@
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
public class Statistics extends ClientState { public class Statistics extends CeremonyStates {
public Statistics(ClientState parent, ClientGameLogic logic) { public Statistics(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -1,16 +0,0 @@
package pp.mdga.client.dialogState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.ClientStateMachine;
public class DialogsStateMachine extends ClientStateMachine {
public DialogsStateMachine(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public StartDialog initialState() {
return new StartDialog(this, logic);
}
}

View File

@@ -2,9 +2,62 @@
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.Dialogs;
import pp.mdga.game.Color;
import pp.mdga.message.client.*;
import pp.mdga.message.server.ServerStartGame;
public class Lobby extends DialogStates { public class Lobby extends DialogStates {
private final Dialogs parent;
public Lobby(ClientState parent, ClientGameLogic logic) { public Lobby(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
this.parent = (Dialogs) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void selectLeave() {
parent.setState(parent.getStartDialog());
}
@Override
public void selectTSK(Color color) {
logic.send(new SelectTSK(color));
}
@Override
public void deselectTSK(Color color) {
logic.send(new DeselectTSK(color));
}
@Override
public void selectReady() {
logic.send(new LobbyReady());
}
@Override
public void selectUnready(){
logic.send(new LobbyNotReady());
}
@Override
public void selectStart(){
logic.send(new StartGame());
}
@Override
public void received(ServerStartGame msg){
parent.startGame();
} }
} }

View File

@@ -2,9 +2,61 @@
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.Dialogs;
public class NetworkDialog extends DialogStates { public class NetworkDialog extends DialogStates {
private final Dialogs parent;
public NetworkDialog(ClientState parent, ClientGameLogic logic) { public NetworkDialog(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
this.parent = (Dialogs) parent;
}
private boolean checkIP(String IP){
String[] parts = IP.split("\\.");
// Step 2: Check if there are exactly 4 parts
if (parts.length != 4) {
return false;
}
// Step 3: Check each part for valid number
for (String part : parts) {
try {
// Step 4: Convert each part into a number
int num = Integer.parseInt(part);
// Step 5: Check whether the number lies in between 0 and 255
if (num < 0 || num > 255) {
return false;
}
} catch (NumberFormatException e) {
// If parsing fails, it's not a valid number
return false;
}
}
// If all checks passed, return true
return true;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
public void selectBack() {
parent.setState(parent.getStartDialog());
}
public void selectJoin(String IP) {
if(checkIP(IP)){
parent.setState(parent.getLobby());
}
} }
} }

View File

@@ -2,9 +2,36 @@
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.Dialogs;
public class StartDialog extends DialogStates { public class StartDialog extends DialogStates {
private final Dialogs parent;
public StartDialog(ClientState parent, ClientGameLogic logic) { public StartDialog(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
this.parent = (Dialogs) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
public void selectJoin() {
parent.setState(parent.getNetworkDialog());
}
public void selectHost() {
parent.setState(parent.getLobby());
}
public void selectLeave() {
parent.exit();
} }
} }

View File

@@ -7,4 +7,14 @@ public class Animation extends GameStates {
public Animation(ClientState parent, ClientGameLogic logic) { public Animation(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -1,16 +0,0 @@
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.ClientStateMachine;
public class GameStateMachine extends ClientStateMachine {
public GameStateMachine(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public ClientState initialState() {
return null;
}
}

View File

@@ -7,4 +7,14 @@ public class Spectator extends GameStates {
public Spectator(ClientState parent, ClientGameLogic logic) { public Spectator(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -2,17 +2,20 @@
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.TurnStateMachine;
public class Turn extends GameStates { public class Turn extends GameStates {
private final TurnStateMachine turnStateMachine;
public Turn(ClientState parent, ClientGameLogic logic) { public Turn(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
this.turnStateMachine = new TurnStateMachine(parent, logic);
} }
public TurnStateMachine getTurnStateMachine() { @Override
return turnStateMachine; public void enter() {
}
@Override
public void exit() {
} }
} }

View File

@@ -7,4 +7,14 @@ public class Waiting extends GameStates {
public Waiting(ClientState parent, ClientGameLogic logic) { public Waiting(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -4,8 +4,9 @@
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.GameStates; import pp.mdga.client.gameState.GameStates;
public class DetermineStartPlayerStates extends GameStates { public abstract class DetermineStartPlayerStates extends GameStates {
public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) { public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
} }

View File

@@ -7,4 +7,14 @@ public class RollRankingDice extends DetermineStartPlayerStates {
public RollRankingDice(ClientState parent, ClientGameLogic logic) { public RollRankingDice(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -8,4 +8,14 @@ public class WaitRanking extends GameStates {
public WaitRanking(ClientState parent, ClientGameLogic logic) { public WaitRanking(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -1,19 +1,21 @@
package pp.mdga.client.gameState.turnState; package pp.mdga.client.gameState.turnState;
import pp.mdga.client.gameState.turnState.choosePieceState.ChoosePieceStateMachine;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
public class ChoosePiece extends TurnStates { public class ChoosePiece extends TurnStates {
private final ChoosePieceStateMachine choosePieceStateMachine;
public ChoosePiece(ClientState parent, ClientGameLogic logic) { public ChoosePiece(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
this.choosePieceStateMachine = new ChoosePieceStateMachine(parent, logic);
} }
public ChoosePieceStateMachine getChoosePieceStateMachine() { @Override
return choosePieceStateMachine; public void enter() {
}
@Override
public void exit() {
} }
} }

View File

@@ -7,4 +7,14 @@ public class MovePiece extends TurnStates {
public MovePiece(ClientState parent, ClientGameLogic logic) { public MovePiece(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -7,4 +7,14 @@ public class PlayPowerCard extends TurnStates {
public PlayPowerCard(ClientState parent, ClientGameLogic logic) { public PlayPowerCard(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -2,17 +2,20 @@
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.powerCardState.PowerCardStateMachine;
public class PowerCard extends TurnStates { public class PowerCard extends TurnStates {
private final PowerCardStateMachine powerCardStateMachine;
public PowerCard(ClientState parent, ClientGameLogic logic) { public PowerCard(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
this.powerCardStateMachine = new PowerCardStateMachine(parent, logic);
} }
public PowerCardStateMachine getPowerCardStateMachine() { @Override
return powerCardStateMachine; public void enter() {
}
@Override
public void exit() {
} }
} }

View File

@@ -7,4 +7,14 @@ public class RollDice extends TurnStates {
public RollDice(ClientState parent, ClientGameLogic logic) { public RollDice(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -1,16 +0,0 @@
package pp.mdga.client.gameState.turnState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.ClientStateMachine;
public class TurnStateMachine extends ClientStateMachine {
public TurnStateMachine(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public PowerCard initialState() {
return new PowerCard(this, logic);
}
}

View File

@@ -1,16 +0,0 @@
package pp.mdga.client.gameState.turnState.choosePieceState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.ClientStateMachine;
public class ChoosePieceStateMachine extends ClientStateMachine {
public ChoosePieceStateMachine(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public NoPiece initialState() {
return new NoPiece(this, logic);
}
}

View File

@@ -7,4 +7,14 @@ public class NoPiece extends ChoosePieceStates {
public NoPiece(ClientState parent, ClientGameLogic logic) { public NoPiece(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -7,4 +7,14 @@ public class SelectPiece extends ChoosePieceStates {
public SelectPiece(ClientState parent, ClientGameLogic logic) { public SelectPiece(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -7,4 +7,14 @@ public class StartPiece extends ChoosePieceStates {
public StartPiece(ClientState parent, ClientGameLogic logic) { public StartPiece(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -7,4 +7,14 @@ public class WaitingPiece extends ChoosePieceStates {
public WaitingPiece(ClientState parent, ClientGameLogic logic) { public WaitingPiece(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -7,4 +7,14 @@ public class ChoosePowerCard extends PowerCardStates {
public ChoosePowerCard(ClientState parent, ClientGameLogic logic) { public ChoosePowerCard(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -1,16 +0,0 @@
package pp.mdga.client.gameState.turnState.powerCardState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.ClientStateMachine;
public class PowerCardStateMachine extends ClientStateMachine {
public PowerCardStateMachine(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public ChoosePowerCard initialState() {
return new ChoosePowerCard(this, logic);
}
}

View File

@@ -7,4 +7,14 @@ public class Shield extends PowerCardStates {
public Shield(ClientState parent, ClientGameLogic logic) { public Shield(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -7,4 +7,14 @@ public class Swap extends PowerCardStates {
public Swap(ClientState parent, ClientGameLogic logic) { public Swap(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -7,4 +7,14 @@ public class AudioSettings extends SettingStates {
public AudioSettings(ClientState parent, ClientGameLogic logic) { public AudioSettings(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -7,4 +7,14 @@ public class MainSettings extends ClientState {
public MainSettings(ClientState parent, ClientGameLogic logic) { public MainSettings(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -1,16 +0,0 @@
package pp.mdga.client.settingsState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.ClientStateMachine;
public class SettingsStateMachine extends ClientStateMachine {
public SettingsStateMachine(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public ClientState initialState() {
return null;
}
}

View File

@@ -7,4 +7,14 @@ public class VideoSettings extends SettingStates {
public VideoSettings(ClientState parent, ClientGameLogic logic) { public VideoSettings(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -1,9 +1,12 @@
package pp.mdga.game; package pp.mdga.game;
public enum Color { public enum Color {
ARMY, AIRFORCE,
NAVY,
CYBER, CYBER,
AIRFORCE NAVY,
ARMY;
public Color next() {
return values()[(ordinal() + 1) % values().length];
}
} }

View File

@@ -6,22 +6,12 @@
* This class will be used to handle general PlayerData * This class will be used to handle general PlayerData
*/ */
public class Player { public class Player {
private String name; private String name;
private Statistic playerStatistic; private Statistic playerStatistic;
private ArrayList<BonusCard> handCards; private ArrayList<BonusCard> handCards;
private final int id;
private Color color; private Color color;
private boolean isReady; private boolean isReady;
private boolean active = true;
/**
* This constructor constructs a new Player object
*/
public Player(int id) {
this.id = id;
playerStatistic = new Statistic();
handCards = new ArrayList<>();
}
/** /**
* This constructor constructs a new Player object * This constructor constructs a new Player object
@@ -32,7 +22,13 @@ public Player(String name) {
this.name = name; this.name = name;
playerStatistic = new Statistic(); playerStatistic = new Statistic();
handCards = new ArrayList<>(); handCards = new ArrayList<>();
id = 0; }
/**
* Constructor.
*/
public Player() {
this("");
} }
/** /**
@@ -94,15 +90,6 @@ public BonusCard removeHandCard(BonusCard card) {
return cardToRemove; return cardToRemove;
} }
/**
* Returns the id of the connection to the client represented by this player.
*
* @return the id
*/
public int getId() {
return id;
}
/** /**
* This method returns the color of the player * This method returns the color of the player
* *
@@ -130,6 +117,15 @@ public boolean isReady() {
return isReady; return isReady;
} }
/**
* This method will be used to return active attribute of Player class.
*
* @return active as a Boolean.
*/
public boolean isActive() {
return this.active;
}
/** /**
* This method sets the player to ready * This method sets the player to ready
* *
@@ -138,4 +134,13 @@ public boolean isReady() {
public void setReady(boolean ready) { public void setReady(boolean ready) {
isReady = ready; isReady = ready;
} }
/**
* This method will be used to set active attribute of Player class to the given active parameter.
*
* @param active as the new active value as a Boolean.
*/
public void setActive(boolean active) {
this.active = active;
}
} }

View File

@@ -20,14 +20,13 @@ public interface ClientInterpreter {
*/ */
void received(DeselectTSK msg, int from); void received(DeselectTSK msg, int from);
/** /**
* Processes a received ForceStartGame message. * Processes a received ForceStartGame message.
* *
* @param msg the ForceStartGame message to be processed * @param msg the ForceStartGame message to be processed
* @param from the connection ID from which the message was received * @param from the connection ID from which the message was received
*/ */
void received(ForceStartGame msg, int from); void received(StartGame msg, int from);
/** /**
* Processes a received JoinServer message. * Processes a received JoinServer message.
@@ -61,6 +60,14 @@ public interface ClientInterpreter {
*/ */
void received(LobbyReady msg, int from); void received(LobbyReady msg, int from);
/**
* Processes a received Disconnected message.
*
* @param msg the Disconnected message to be processed
* @param from the connection ID from which the message was received
*/
void received(Disconnected msg, int from);
/** /**
* Processes a received RequestBriefing message. * Processes a received RequestBriefing message.
* *
@@ -70,12 +77,12 @@ public interface ClientInterpreter {
void received(RequestBriefing msg, int from); void received(RequestBriefing msg, int from);
/** /**
* Processes a received RequestDice message. * Processes a received RequestDie message.
* *
* @param msg the RequestDice message to be processed * @param msg the RequestDie message to be processed
* @param from the connection ID from which the message was received * @param from the connection ID from which the message was received
*/ */
void received(RequestDice msg, int from); void received(RequestDie msg, int from);
/** /**
* Processes a received RequestMove message. * Processes a received RequestMove message.

View File

@@ -0,0 +1,34 @@
package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
/**
*
*/
@Serializable
public class Disconnected extends ClientMessage {
public Disconnected() {
super();
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "ClientStartGame{}";
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override
public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from);
}
}

View File

@@ -7,11 +7,23 @@
*/ */
@Serializable @Serializable
public class JoinServer extends ClientMessage { public class JoinServer extends ClientMessage {
private final String name;
/**
* Constructs a new JoinServer instance.
*/
public JoinServer(String name) {
super();
this.name = name;
}
/** /**
* Constructs a new JoinServer instance. * Constructs a new JoinServer instance.
*/ */
public JoinServer() { public JoinServer() {
super(); super();
name = null;
} }
/** /**

View File

@@ -6,11 +6,11 @@
* A message sent by a client to request a die roll. * A message sent by a client to request a die roll.
*/ */
@Serializable @Serializable
public class RequestDice extends ClientMessage { public class RequestDie extends ClientMessage {
/** /**
* Constructs a new RequestDice instance. * Constructs a new RequestDie instance.
*/ */
public RequestDice() { public RequestDie() {
super(); super();
} }
@@ -21,7 +21,7 @@ public RequestDice() {
*/ */
@Override @Override
public String toString() { public String toString() {
return "RequestDice{}"; return "RequestDie{}";
} }
/** /**

View File

@@ -6,12 +6,21 @@
* A message sent by the host to force start the game when not everyone is ready or not everyone has selected a TSK. * A message sent by the host to force start the game when not everyone is ready or not everyone has selected a TSK.
*/ */
@Serializable @Serializable
public class ForceStartGame extends ClientMessage { public class StartGame extends ClientMessage {
private final boolean forceStartGame;
public StartGame(boolean forceStartGame){
super();
this.forceStartGame = forceStartGame;
}
/** /**
* Constructs a new ForceStartGame message. * Constructs a new ForceStartGame message.
*/ */
public ForceStartGame() { public StartGame() {
super(); super();
forceStartGame = false;
} }
/** /**

View File

@@ -8,7 +8,7 @@
* A message sent by the server to the client to inform about the dice roll. * A message sent by the server to the client to inform about the dice roll.
*/ */
@Serializable @Serializable
public class Dice extends ServerMessage { public class Die extends ServerMessage {
/** /**
* The eye of the dice * The eye of the dice
*/ */
@@ -25,7 +25,7 @@ public class Dice extends ServerMessage {
* @param diceEye the eye of the dice * @param diceEye the eye of the dice
* @param moveablePieces the pieces that can be moved * @param moveablePieces the pieces that can be moved
*/ */
public Dice(int diceEye, List<String> moveablePieces) { public Die(int diceEye, List<String> moveablePieces) {
super(); super();
this.diceEye = diceEye; this.diceEye = diceEye;
this.moveablePieces = moveablePieces; this.moveablePieces = moveablePieces;
@@ -34,7 +34,7 @@ public Dice(int diceEye, List<String> moveablePieces) {
/** /**
* Default constructor for serialization purposes. * Default constructor for serialization purposes.
*/ */
private Dice() { private Die() {
diceEye = 0; diceEye = 0;
moveablePieces = null; moveablePieces = null;
} }
@@ -45,8 +45,8 @@ private Dice() {
* @param diceEye the eye of the dice * @param diceEye the eye of the dice
* @return a new Dice object * @return a new Dice object
*/ */
public static Dice inactivePlayer(int diceEye) { public static Die inactivePlayer(int diceEye) {
return new Dice(diceEye, null); return new Die(diceEye, null);
} }
/** /**
@@ -56,8 +56,8 @@ public static Dice inactivePlayer(int diceEye) {
* @param moveablePieces the pieces that can be moved * @param moveablePieces the pieces that can be moved
* @return a new Dice object * @return a new Dice object
*/ */
public static Dice activePlayer(int diceEye, List<String> moveablePieces) { public static Die activePlayer(int diceEye, List<String> moveablePieces) {
return new Dice(diceEye, moveablePieces); return new Die(diceEye, moveablePieces);
} }
/** /**

View File

@@ -13,14 +13,20 @@ public class LobbyPlayerJoin extends ServerMessage {
*/ */
private final String name; private final String name;
/**
* The ID of the new Player
*/
private final int id;
/** /**
* Constructs a new LobbyPlayerJoin instance with the specified player name. * Constructs a new LobbyPlayerJoin instance with the specified player name.
* *
* @param name the name of the player joining the lobby * @param name the name of the player joining the lobby
*/ */
public LobbyPlayerJoin(String name) { public LobbyPlayerJoin(int id, String name) {
super(); super();
this.name = name; this.name = name;
this.id = id;
} }
/** /**
@@ -28,6 +34,7 @@ public LobbyPlayerJoin(String name) {
*/ */
private LobbyPlayerJoin() { private LobbyPlayerJoin() {
name = null; name = null;
id = 0;
} }
/** /**
@@ -39,6 +46,15 @@ public String getName() {
return name; return name;
} }
/**
* Returns the id of the new Player
*
* @return the id of the player
*/
public int getId(){
return id;
}
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *

View File

@@ -11,7 +11,7 @@ public class LobbyPlayerLeave extends ServerMessage {
/** /**
* The name of the player leaving the lobby. * The name of the player leaving the lobby.
*/ */
private final String name; private final int id;
/** /**
* The color associated with the player leaving the lobby. * The color associated with the player leaving the lobby.
@@ -21,12 +21,12 @@ public class LobbyPlayerLeave extends ServerMessage {
/** /**
* Constructs a new LobbyPlayerLeave instance with the specified player name and color. * Constructs a new LobbyPlayerLeave instance with the specified player name and color.
* *
* @param name the name of the player leaving the lobby * @param id the id of the player leaving the lobby
* @param color the color associated with the player leaving the lobby * @param color the color associated with the player leaving the lobby
*/ */
public LobbyPlayerLeave(String name, Color color) { public LobbyPlayerLeave(int id, Color color) {
super(); super();
this.name = name; this.id = id;
this.color = color; this.color = color;
} }
@@ -34,7 +34,7 @@ public LobbyPlayerLeave(String name, Color color) {
* Default constructor for serialization purposes. * Default constructor for serialization purposes.
*/ */
private LobbyPlayerLeave() { private LobbyPlayerLeave() {
name = null; id = 0;
color = null; color = null;
} }
@@ -43,8 +43,8 @@ private LobbyPlayerLeave() {
* *
* @return the name of the player leaving the lobby * @return the name of the player leaving the lobby
*/ */
public String getName() { public int getId() {
return name; return id;
} }
/** /**

View File

@@ -34,11 +34,11 @@ public interface ServerInterpreter {
void received(CeremonyMessage msg); void received(CeremonyMessage msg);
/** /**
* Handles a Dice message received from the server. * Handles a Die message received from the server.
* *
* @param msg the Dice message received * @param msg the Dice message received
*/ */
void received(Dice msg); void received(Die msg);
/** /**
* Handles a DiceAgain message received from the server. * Handles a DiceAgain message received from the server.
@@ -193,4 +193,11 @@ public interface ServerInterpreter {
* @param msg the WaitPiece message received * @param msg the WaitPiece message received
*/ */
void received(WaitPiece msg); void received(WaitPiece msg);
/**
* Handles a Spectator message received from the server.
*
* @param msg the Spectator message received.
*/
void received(Spectator msg);
} }

View File

@@ -0,0 +1,32 @@
package pp.mdga.message.server;
/**
*
*/
public class Spectator extends ServerMessage {
/**
* Construc
*/
public Spectator() {
super();
}
/**
*
* @param interpreter the visitor to process this message
*/
@Override
public void accept(ServerInterpreter interpreter) {
interpreter.received(this);
}
/**
*
* @return
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -11,7 +11,7 @@ public class UpdateTSK extends ServerMessage {
/** /**
* The name associated with the update. * The name associated with the update.
*/ */
private final String name; private final int id;
/** /**
* The color associated with the update. * The color associated with the update.
@@ -21,12 +21,12 @@ public class UpdateTSK extends ServerMessage {
/** /**
* Constructs a new UpdateTSK instance with the specified name and color. * Constructs a new UpdateTSK instance with the specified name and color.
* *
* @param name the name associated with the update * @param id the name associated with the update
* @param color the color associated with the update * @param color the color associated with the update
*/ */
public UpdateTSK(String name, Color color) { public UpdateTSK(int id, Color color) {
super(); super();
this.name = name; this.id = id;
this.color = color; this.color = color;
} }
@@ -34,7 +34,7 @@ public UpdateTSK(String name, Color color) {
* Default constructor for serialization purposes. * Default constructor for serialization purposes.
*/ */
private UpdateTSK() { private UpdateTSK() {
this("", null); this(0, null);
} }
/** /**
@@ -42,8 +42,8 @@ private UpdateTSK() {
* *
* @return the name * @return the name
*/ */
public String getName() { public int getId() {
return name; return id;
} }
/** /**

View File

@@ -1,7 +0,0 @@
package pp.mdga.server;
public class Ceremony extends ServerState {
public Ceremony(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server;
public class ChoosePiece extends Turn {
public ChoosePiece(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,7 @@
package pp.mdga.server;
public class ChoosePieceState extends TurnState {
public ChoosePieceState(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,9 @@
package pp.mdga.server;
import pp.mdga.server.automaton.GameState;
public class DetermineStartPlayerState extends GameState {
public DetermineStartPlayerState(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server;
public class FirstRoll extends RollDice {
public FirstRoll(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,7 @@
package pp.mdga.server;
public class FirstRollStateState extends RollDiceState {
public FirstRollStateState(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server;
public class Interrupt extends ServerState {
public Interrupt(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -1,14 +0,0 @@
package pp.mdga.server;
public class Lobby extends ServerState {
/**
* Constructs a server state of the specified game logic.
*
* @param logic the game logic
*/
public Lobby(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server;
public class MovePiece extends Turn {
public MovePiece(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,7 @@
package pp.mdga.server;
public class MovePieceState extends TurnState {
public MovePieceState(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server;
public class NoPiece extends ChoosePiece {
public NoPiece(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,7 @@
package pp.mdga.server;
public class NoPieceState extends ChoosePieceState {
public NoPieceState(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server;
public class NoTurn extends ChoosePiece {
public NoTurn(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,7 @@
package pp.mdga.server;
public class NoTurnState extends ChoosePieceState {
public NoTurnState(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server;
public class PowerCard extends Turn {
public PowerCard(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,7 @@
package pp.mdga.server;
public class PowerCardState extends TurnState {
public PowerCardState(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server;
public class RollDice extends Turn {
public RollDice(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,7 @@
package pp.mdga.server;
public class RollDiceState extends TurnState {
public RollDiceState(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server;
public class SecondRoll extends RollDice {
public SecondRoll(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,7 @@
package pp.mdga.server;
public class SecondRollState extends RollDiceState {
public SecondRollState(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server;
public class SelectPiece extends ChoosePiece {
public SelectPiece(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,7 @@
package pp.mdga.server;
public class SelectPieceState extends ChoosePieceState {
public SelectPieceState(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -13,4 +13,12 @@ public interface ServerSender {
* @param message the message * @param message the message
*/ */
void send(int id, ServerMessage message); void send(int id, ServerMessage message);
/**
* This method will be used to send the given message parameter to all connected players which are saved inside the
* players attribute of Game class.
*
* @param message as the message which will be sent to all players as a ServerMessage.
*/
void broadcast(ServerMessage message);
} }

View File

@@ -1,25 +0,0 @@
package pp.mdga.server;
/**
* Defines the behavior and state transitions for the server-side game logic.
* Different states of the game logic implement this interface to handle various game events and actions.
*/
public class ServerState {
/**
* The server logic object.
*/
private final ServerGameLogic logic;
/**
* Constructs a server state of the specified game logic.
*
* @param logic the game logic
*/
public ServerState(ServerGameLogic logic) {
this.logic = logic;
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server;
public class StartPiece extends ChoosePiece {
public StartPiece(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,7 @@
package pp.mdga.server;
public class StartPieceState extends ChoosePieceState {
public StartPieceState(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server;
public class ThirdRoll extends RollDice {
public ThirdRoll(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,7 @@
package pp.mdga.server;
public class ThirdRollState extends RollDiceState {
public ThirdRollState(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,9 @@
package pp.mdga.server;
import pp.mdga.server.automaton.GameState;
public class TurnState extends GameState {
public TurnState(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server;
public class WaitingPiece extends ChoosePiece {
public WaitingPiece(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,7 @@
package pp.mdga.server;
public class WaitingPieceState extends ChoosePieceState {
public WaitingPieceState(ServerGameLogic logic) {
super(logic);
}
}

View File

@@ -0,0 +1,33 @@
package pp.mdga.server.automaton;
import pp.mdga.server.ServerGameLogic;
/**
*
*/
public class CeremonyState extends ServerState {
/**
* Constructor.
*
* @param logic as the server game logic which is the automaton as a ServerGameLogic object.
*/
public CeremonyState(ServerGameLogic logic) {
super(logic);
}
/**
* This method will be used whenever this state will be entered.
*/
@Override
public void enter() {
// ToDo: Close server.
}
/**
* This method will be used whenever this state will be exited.
*/
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,60 @@
package pp.mdga.server.automaton;
import pp.mdga.message.client.Disconnected;
import pp.mdga.message.client.LeaveGame;
import pp.mdga.message.server.PauseGame;
import pp.mdga.server.ServerGameLogic;
/**
*
*/
public class GameState extends ServerState {
/**
* Constructor.
*
* @param logic as the server game logic which is the automaton as a ServerGameLogic object.
*/
public GameState(ServerGameLogic logic) {
super(logic);
}
/**
* This method will be used whenever this state will be entered.
*/
@Override
public void enter() {
}
/**
* This method will be used whenever this state will be exited.
*/
@Override
public void exit() {
}
/**
*
* @param msg as the message which was sent by the player as a Disconnected object.
* @param from as the client id of the player as an Integer.
*/
@Override
public void received(Disconnected msg, int from) {
this.logic.getServerSender().broadcast(new PauseGame());
this.logic.setCurrentState(this.logic.getInterruptState());
}
/**
*
* @param msg as the message which was sent by the player as a LeaveGame object.
* @param from as the client id of the player as an Integer.
*/
@Override
public void received(LeaveGame msg, int from) {
this.logic.getGame().updatePlayerActiveState(from, false);
if (this.logic.getGame().getNumberOfActivePlayers() == 1) {
this.logic.setCurrentState(this.logic.getCeremonyState());
}
}
}

View File

@@ -0,0 +1,47 @@
package pp.mdga.server.automaton;
import com.jme3.system.Timer;
import pp.mdga.message.client.ForceContinueGame;
import pp.mdga.message.server.ResumeGame;
import pp.mdga.server.ServerGameLogic;
/**
*
*/
public class InterruptState extends ServerState {
/**
* Attributes.
*/
private Timer timer;
/**
* Constructor.
*
* @param logic as the server game logic which is the automaton as a ServerGameLogic object.
*/
public InterruptState(ServerGameLogic logic) {
super(logic);
}
/**
* This method will be used whenever this state will be entered.
*/
@Override
public void enter() {
// Create timer and connect signal.
}
/**
* This method will be used whenever this state will be exited.
*/
@Override
public void exit() {
}
@Override
public void received(ForceContinueGame msg, int from) {
this.logic.getServerSender().broadcast(new ResumeGame());
this.logic.setCurrentState(this.logic.getGameState());
}
}

View File

@@ -0,0 +1,88 @@
package pp.mdga.server.automaton;
import pp.mdga.message.client.*;
import pp.mdga.message.server.ServerStartGame;
import pp.mdga.message.server.UpdateReady;
import pp.mdga.message.server.UpdateTSK;
import pp.mdga.server.ServerGameLogic;
/**
*
*/
public class LobbyState extends ServerState {
/**
* Constructs a server state of the specified game logic.
*
* @param logic the game logic
*/
public LobbyState(ServerGameLogic logic) {
super(logic);
}
/**
* This method will be used whenever this state will be entered.
*/
@Override
public void enter() {
}
/**
* This method will be used whenever this state will be exited.
*/
@Override
public void exit() {
}
/**
*
* @param msg as the message which was sent by the player as a SelectTSK object.
* @param from as the client id of the player as an Integer.
*/
@Override
public void received(SelectTSK msg, int from) {
this.logic.getServerSender().broadcast(new UpdateTSK(from, msg.getColor()));
}
/**
*
* @param msg as the message which was sent by the player as a DeselectTSK object.
* @param from as the client id of the player as an Integer.
*/
@Override
public void received(DeselectTSK msg, int from) {
this.logic.getServerSender().broadcast(new UpdateTSK(from, msg.getColor()));
}
/**
*
* @param msg as the message which was sent by the player as a LobbyReady object.
* @param from as the client id of the player as an Integer.
*/
@Override
public void received(LobbyReady msg, int from) {
this.logic.getServerSender().broadcast(new UpdateReady(from, true));
}
/**
*
* @param msg as the message which was sent by the player as a LobbyNotReady object.
* @param from as the client id of the player as an Integer.
*/
@Override
public void received(LobbyNotReady msg, int from) {
this.logic.getServerSender().broadcast(new UpdateReady(from, false));
}
/**
*
* @param msg as the message which was sent by the player as a ForceStartGame object.
* @param from as the client id of the player as an Integer.
*/
@Override
public void received(ForceStartGame msg, int from) {
this.logic.getServerSender().broadcast(new ServerStartGame());
this.logic.setCurrentState(this.logic.getGameState());
}
}

View File

@@ -0,0 +1,196 @@
package pp.mdga.server.automaton;
import pp.mdga.message.client.*;
import pp.mdga.server.ServerGameLogic;
/**
* Defines the behavior and state transitions for the server-side game logic.
* Different states of the game logic implement this interface to handle various game events and actions.
*/
public abstract class ServerState {
/**
* The server logic object.
*/
protected final ServerGameLogic logic;
/**
* Constructs a server state of the specified game logic.
*
* @param logic the game logic
*/
public ServerState(ServerGameLogic logic) {
this.logic = logic;
}
/**
* This method will be used whenever this state will be entered.
*/
public abstract void enter();
/**
* This method will be used whenever this state will be exited.
*/
public abstract void exit();
/**
* This method will be called whenever the server received an AnimationEnd 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 AnimationEnd object.
* @param from as the client id of the player as an Integer.
*/
public void received(AnimationEnd msg, int from) {}
/**
* This method will be called whenever the server received an DeselectTSK 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 DeselectTSK object.
* @param from as the client id of the player as an Integer.
*/
public void received(DeselectTSK msg, int from) {}
/**
* This method will be called whenever the server received a StartGame 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 StartGame object.
* @param from as the client id of the player as an Integer.
*/
public void received(StartGame msg, int from) {}
/**
* This method will be called whenever the server received a JoinServer 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 JoinServer object.
* @param from as the client id of the player as an Integer.
*/
public void received(JoinServer msg, int from) {}
/**
* This method will be called whenever the server received an LeaveGame 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 LeaveGame object.
* @param from as the client id of the player as an Integer.
*/
public void received(LeaveGame msg, int from) {}
/**
* This method will be called whenever the server received a LobbyReady 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 LobbyReady object.
* @param from as the client id of the player as an Integer.
*/
public void received(LobbyReady msg, int from) {}
/**
* This method will be called whenever the server received a LobbyNotReady 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 LobbyNotReady object.
* @param from as the client id of the player as an Integer.
*/
public void received(LobbyNotReady msg, int from) {}
/**
* This method will be called whenever the server received a Disconnected 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 Disconnected object.
* @param from as the client id of the player as an Integer.
*/
public void received(Disconnected msg, int from) {}
/**
* This method will be called whenever the server received a Briefing 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 Briefing object.
* @param from as the client id of the player as an Integer.
*/
public void received(RequestBriefing msg, int from) {}
/**
* This method will be called whenever the server received a Die 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 Die object.
* @param from as the client id of the player as an Integer.
*/
public void received(RequestDie msg, int from) {}
/**
* This method will be called whenever the server received a RequestMove 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 RequestMove object.
* @param from as the client id of the player as an Integer.
*/
public void received(RequestMove msg, int from) {}
/**
* This method will be called whenever the server received a PlayCard 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 PlayCard object.
* @param from as the client id of the player as an Integer.
*/
public void received(RequestPlayCard msg, int from) {}
/**
* This method will be called whenever the server received a SelectCard 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 SelectCard object.
* @param from as the client id of the player as an Integer.
*/
public void received(SelectCard msg, int from) {}
/**
* This method will be called whenever the server received a SelectTSK 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 SelectTSK object.
* @param from as the client id of the player as an Integer.
*/
public void received(SelectTSK msg, int from) {}
/**
* This method will be called whenever the server received a ForceContinueGame 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 ForceContinueGame object.
* @param from as the client id of the player as an Integer.
*/
public void received(ForceContinueGame msg, int from) {}
/**
* This method will be called whenever the server received a ClientStartGame 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 ClientStartGame object.
* @param from as the client id of the player as an Integer.
*/
public void received(ClientStartGame msg, int from) {}
/**
* This method will be called whenever the server received a NoPowerCard 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 NoPowerCard object.
* @param from as the client id of the player as an Integer.
*/
public void received(NoPowerCard msg, int from) {}
/**
* This method will be called whenever the server received a SelectedPieces 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 SelectedPieces object.
* @param from as the client id of the player as an Integer.
*/
public void received(SelectedPieces msg, int from) {}
}

View File

@@ -6,7 +6,7 @@
/** /**
* this test-class tests the testcases T084-T095 * this test-class tests the testcases T084-T095
*/ */
public class LobbyTest { public class LobbyStateTest {
@Before @Before
public void setUp() { public void setUp() {

View File

@@ -4,10 +4,8 @@
import org.junit.Test; import org.junit.Test;
import pp.mdga.client.*; import pp.mdga.client.*;
import pp.mdga.client.Ceremony; import pp.mdga.client.Ceremony;
import pp.mdga.client.ceremonyState.CeremonyStateMachine;
import pp.mdga.client.ceremonyState.Podium; import pp.mdga.client.ceremonyState.Podium;
import pp.mdga.client.ceremonyState.Statistics; import pp.mdga.client.ceremonyState.Statistics;
import pp.mdga.client.dialogState.DialogsStateMachine;
import pp.mdga.client.dialogState.Lobby; import pp.mdga.client.dialogState.Lobby;
import pp.mdga.client.dialogState.NetworkDialog; import pp.mdga.client.dialogState.NetworkDialog;
import pp.mdga.client.dialogState.StartDialog; import pp.mdga.client.dialogState.StartDialog;
@@ -16,13 +14,11 @@
import pp.mdga.client.gameState.determineStartPlayer.DetermineStartPlayerStateMachine; import pp.mdga.client.gameState.determineStartPlayer.DetermineStartPlayerStateMachine;
import pp.mdga.client.gameState.turnState.*; import pp.mdga.client.gameState.turnState.*;
import pp.mdga.client.gameState.turnState.powerCardState.ChoosePowerCard; import pp.mdga.client.gameState.turnState.powerCardState.ChoosePowerCard;
import pp.mdga.client.gameState.turnState.powerCardState.PowerCardStateMachine;
import pp.mdga.client.gameState.turnState.powerCardState.Shield; import pp.mdga.client.gameState.turnState.powerCardState.Shield;
import pp.mdga.client.gameState.turnState.powerCardState.Swap; import pp.mdga.client.gameState.turnState.powerCardState.Swap;
import pp.mdga.client.Settings; import pp.mdga.client.Settings;
import pp.mdga.client.settingsState.AudioSettings; import pp.mdga.client.settingsState.AudioSettings;
import pp.mdga.client.settingsState.MainSettings; import pp.mdga.client.settingsState.MainSettings;
import pp.mdga.client.settingsState.SettingsStateMachine;
import pp.mdga.client.settingsState.VideoSettings; import pp.mdga.client.settingsState.VideoSettings;
import pp.mdga.game.BonusCard; import pp.mdga.game.BonusCard;
import pp.mdga.game.Color; import pp.mdga.game.Color;
@@ -53,7 +49,7 @@ public class ClientStateTest {
private DetermineStartPlayerStateMachine determineStartPlayerStateMachine; private DetermineStartPlayerStateMachine determineStartPlayerStateMachine;
private Dialogs dialogs; private Dialogs dialogs;
private DialogsStateMachine dialogsStateMachine; private DialogsStateMachine dialogsStateMachine;
private Game gameState; private GameState gameState;
private GameStateMachine gameStateMachine; private GameStateMachine gameStateMachine;
private Interrupt interrupt; private Interrupt interrupt;
private Lobby lobby; private Lobby lobby;
@@ -197,7 +193,7 @@ public void send(ClientMessage msg) {
//initialize the states //initialize the states
dialogs = new Dialogs(clientAutomaton,clientGameLogic); dialogs = new Dialogs(clientAutomaton,clientGameLogic);
gameState = new Game(clientAutomaton,clientGameLogic); gameState = new GameState(clientAutomaton,clientGameLogic);
ceremony = new Ceremony(clientAutomaton,clientGameLogic); ceremony = new Ceremony(clientAutomaton,clientGameLogic);
interrupt = new Interrupt(clientAutomaton,clientGameLogic,gameState); interrupt = new Interrupt(clientAutomaton,clientGameLogic,gameState);
@@ -261,10 +257,10 @@ public void testDialogsToGame() {
clientGameLogic.receive(startGame); clientGameLogic.receive(startGame);
//tests if the client is in the gameState after receiving the message //tests if the client is in the gameState after receiving the message
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//tests if the new State of the GameStateMachine is in DetermineStartPlayer //tests if the new State of the GameStateMachine is in DetermineStartPlayer
Game gameState1 = (Game) clientAutomaton.getState(); GameState gameState1 = (GameState) clientAutomaton.getState();
GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine(); GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine();
assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer);
@@ -290,7 +286,7 @@ public void testDialogsToClientStateEndState() {
public void testClientGameToCeremony() { public void testClientGameToCeremony() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the Ceremony-Message to the client //sends the Ceremony-Message to the client
clientGameLogic.receive(ceremonyMessage); clientGameLogic.receive(ceremonyMessage);
@@ -313,7 +309,7 @@ public void testClientGameSubStatesToInterrupt() {
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
//tests if the client is in GameState //tests if the client is in GameState
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the Ceremony-Message to the client //sends the Ceremony-Message to the client
clientGameLogic.receive(interrupt); clientGameLogic.receive(interrupt);
@@ -356,7 +352,7 @@ public void testClientInterruptToGame() {
//Todo sends the continue-message //Todo sends the continue-message
//tests if the client is in the game //tests if the client is in the game
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
} }
/** /**
@@ -580,10 +576,10 @@ public void testLobbyToRollRankingDice() {
clientGameLogic.receive();//TODO message clientGameLogic.receive();//TODO message
//tests if the clientStateMachine is in the GameState //tests if the clientStateMachine is in the GameState
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//tests if the clientStateMachine is in the DetermineStartPlayer //tests if the clientStateMachine is in the DetermineStartPlayer
Game gameState1 = (Game) clientAutomaton.getState(); GameState gameState1 = (GameState) clientAutomaton.getState();
GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine(); GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine();
assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer);
@@ -608,7 +604,7 @@ public void testDetermineStartPlayerToWait() {
public void testWaitToAnimation() { public void testWaitToAnimation() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the client in WaitState //sends the client in WaitState
gameStateMachine.gotoState(waiting); gameStateMachine.gotoState(waiting);
@@ -616,7 +612,7 @@ public void testWaitToAnimation() {
//tests if a piece is moved,that the client goes into Animation //tests if a piece is moved,that the client goes into Animation
clientGameLogic.receive(moveMessage); //Todo ??? richtige message clientGameLogic.receive(moveMessage); //Todo ??? richtige message
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Animation); assertTrue(gameStateMachine.getState() instanceof Animation);
//sends the client in WaitState //sends the client in WaitState
@@ -625,7 +621,7 @@ public void testWaitToAnimation() {
//tests if a powerCard is played,that the client goes into Animation //tests if a powerCard is played,that the client goes into Animation
clientGameLogic.receive(playCardTurbo); //Todo ??? richtige message clientGameLogic.receive(playCardTurbo); //Todo ??? richtige message
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Animation); assertTrue(gameStateMachine.getState() instanceof Animation);
//sends the client in WaitState //sends the client in WaitState
@@ -634,7 +630,7 @@ public void testWaitToAnimation() {
//tests if a die is rolled,that the client goes into Animation //tests if a die is rolled,that the client goes into Animation
clientGameLogic.receive(dice); //Todo ??? richtige message clientGameLogic.receive(dice); //Todo ??? richtige message
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Animation); assertTrue(gameStateMachine.getState() instanceof Animation);
} }
@@ -645,7 +641,7 @@ public void testWaitToAnimation() {
public void testWaitToTurn() { public void testWaitToTurn() {
//sends client in gameState //sends client in gameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Waiting //sends the gameStateMachine in the Waiting
gameStateMachine.gotoState(waiting); gameStateMachine.gotoState(waiting);
@@ -655,7 +651,7 @@ public void testWaitToTurn() {
clientGameLogic.receive(activePlayer); clientGameLogic.receive(activePlayer);
//tests if the client is in GameState //tests if the client is in GameState
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//tests if Client is in Turn //tests if Client is in Turn
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
@@ -732,7 +728,7 @@ public void testPowerCardSubStatesToRollDice() {
public void testStayInPlayPowerCard() { public void testStayInPlayPowerCard() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -745,7 +741,7 @@ public void testStayInPlayPowerCard() {
//Todo send messages to test to stay in playPowerCard //Todo send messages to test to stay in playPowerCard
//tests if the client is in PlayPowerCard //tests if the client is in PlayPowerCard
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); assertTrue(turnStateMachine.getState() instanceof PlayPowerCard);
} }
@@ -757,7 +753,7 @@ public void testStayInPlayPowerCard() {
public void testPlayPowerCardToRollDice() { public void testPlayPowerCardToRollDice() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -771,7 +767,7 @@ public void testPlayPowerCardToRollDice() {
//Todo test other messages, that there is no state change //Todo test other messages, that there is no state change
//tests if the client is in RollDice //tests if the client is in RollDice
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof RollDice); assertTrue(turnStateMachine.getState() instanceof RollDice);
} }
@@ -857,7 +853,7 @@ public void testChoosePowerCardToRollDice() {
//TODO //TODO
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -874,7 +870,7 @@ public void testChoosePowerCardToRollDice() {
//todo send the messages, to force a state change to rollDice //todo send the messages, to force a state change to rollDice
//tests if the turnStateMachine is in RollDice //tests if the turnStateMachine is in RollDice
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof RollDice); assertTrue(turnStateMachine.getState() instanceof RollDice);
} }
@@ -886,7 +882,7 @@ public void testChoosePowerCardToRollDice() {
public void testChoosePowerCardToSwap() { public void testChoosePowerCardToSwap() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -903,7 +899,7 @@ public void testChoosePowerCardToSwap() {
//todo send the messages, to force a state change to swap //todo send the messages, to force a state change to swap
//tests if the client is in Swap //tests if the client is in Swap
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof PowerCard); assertTrue(turnStateMachine.getState() instanceof PowerCard);
assertTrue(powerCardStateMachine.getState() instanceof Swap); assertTrue(powerCardStateMachine.getState() instanceof Swap);
@@ -916,7 +912,7 @@ public void testChoosePowerCardToSwap() {
public void testChoosePowerCardToShield() { public void testChoosePowerCardToShield() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -933,7 +929,7 @@ public void testChoosePowerCardToShield() {
//todo send the messages, to force a state change to shield //todo send the messages, to force a state change to shield
//tests if the client is in Shield //tests if the client is in Shield
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof PowerCard); assertTrue(turnStateMachine.getState() instanceof PowerCard);
assertTrue(powerCardStateMachine.getState() instanceof Shield); assertTrue(powerCardStateMachine.getState() instanceof Shield);
@@ -946,7 +942,7 @@ public void testChoosePowerCardToShield() {
public void testStayInShield() { public void testStayInShield() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -963,7 +959,7 @@ public void testStayInShield() {
//todo send the messages, which dont force a statechange //todo send the messages, which dont force a statechange
//tests if the client is in PlayPowerCard //tests if the client is in PlayPowerCard
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof PowerCard); assertTrue(turnStateMachine.getState() instanceof PowerCard);
assertTrue(powerCardStateMachine.getState() instanceof PlayPowerCard); assertTrue(powerCardStateMachine.getState() instanceof PlayPowerCard);
@@ -976,7 +972,7 @@ public void testStayInShield() {
public void testShieldToPowerCardEndState() { public void testShieldToPowerCardEndState() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -994,7 +990,7 @@ public void testShieldToPowerCardEndState() {
//todo send the message to force the statechange //todo send the message to force the statechange
//tests if the client is in PlayPowerCard //tests if the client is in PlayPowerCard
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); assertTrue(turnStateMachine.getState() instanceof PlayPowerCard);
} }
@@ -1006,7 +1002,7 @@ public void testShieldToPowerCardEndState() {
public void testSwapToPowerCardEndState() { public void testSwapToPowerCardEndState() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -1023,7 +1019,7 @@ public void testSwapToPowerCardEndState() {
//todo send the message to force the statechange //todo send the message to force the statechange
//tests if the client is in PlayPowerCard //tests if the client is in PlayPowerCard
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); assertTrue(turnStateMachine.getState() instanceof PlayPowerCard);
} }
@@ -1035,7 +1031,7 @@ public void testSwapToPowerCardEndState() {
public void testNoPieceInWaitingPiece() { public void testNoPieceInWaitingPiece() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -1054,7 +1050,7 @@ public void testNoPieceInWaitingPiece() {
//sends to the clientGameLogic the message WaitPiece //sends to the clientGameLogic the message WaitPiece
clientGameLogic.receive(waitPiece); clientGameLogic.receive(waitPiece);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePiece);
assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece);
@@ -1067,7 +1063,7 @@ public void testNoPieceInWaitingPiece() {
public void testNoPieceInSelectedPiece() { public void testNoPieceInSelectedPiece() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -1086,7 +1082,7 @@ public void testNoPieceInSelectedPiece() {
//sends to the clientGameLogic the message SelectPiece //sends to the clientGameLogic the message SelectPiece
clientGameLogic.receive(selectPiece); clientGameLogic.receive(selectPiece);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePiece);
assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece);
@@ -1099,7 +1095,7 @@ public void testNoPieceInSelectedPiece() {
public void testNoPieceInStartPiece() { public void testNoPieceInStartPiece() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -1118,7 +1114,7 @@ public void testNoPieceInStartPiece() {
//sends to the clientGameLogic the message StartPiece //sends to the clientGameLogic the message StartPiece
clientGameLogic.receive(startPiece); clientGameLogic.receive(startPiece);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePiece);
assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); assertTrue(choosePieceStateMachine.getState() instanceof StartPiece);
@@ -1131,7 +1127,7 @@ public void testNoPieceInStartPiece() {
public void testNoPieceInWait() { public void testNoPieceInWait() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -1150,7 +1146,7 @@ public void testNoPieceInWait() {
//sends to the clientGameLogic the message NoTurn //sends to the clientGameLogic the message NoTurn
clientGameLogic.receive(noTurn); clientGameLogic.receive(noTurn);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof Waiting); assertTrue(turnStateMachine.getState() instanceof Waiting);
} }
@@ -1162,7 +1158,7 @@ public void testNoPieceInWait() {
public void testStayInWaitingPiece() { public void testStayInWaitingPiece() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -1178,7 +1174,7 @@ public void testStayInWaitingPiece() {
//TODO send all sever-messages except ... to the clientGameLogic to test there are no state change //TODO send all sever-messages except ... to the clientGameLogic to test there are no state change
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePiece);
assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece);
@@ -1191,7 +1187,7 @@ public void testStayInWaitingPiece() {
public void testWaitingPieceInChoosePieceEndState() { public void testWaitingPieceInChoosePieceEndState() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -1207,7 +1203,7 @@ public void testWaitingPieceInChoosePieceEndState() {
//Todo send the message to the clientGameLogic to force a state change //Todo send the message to the clientGameLogic to force a state change
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof MovePiece); assertTrue(turnStateMachine.getState() instanceof MovePiece);
} }
@@ -1219,7 +1215,7 @@ public void testWaitingPieceInChoosePieceEndState() {
public void testStayInSelectedPiece() { public void testStayInSelectedPiece() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -1235,7 +1231,7 @@ public void testStayInSelectedPiece() {
//Todo send all server messages which dont force a state change here //Todo send all server messages which dont force a state change here
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePiece);
assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece);
@@ -1248,7 +1244,7 @@ public void testStayInSelectedPiece() {
public void testSelectedPieceInChoosePieceEndState() { public void testSelectedPieceInChoosePieceEndState() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -1264,7 +1260,7 @@ public void testSelectedPieceInChoosePieceEndState() {
//Todo send the message which force a state change //Todo send the message which force a state change
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof MovePiece); assertTrue(turnStateMachine.getState() instanceof MovePiece);
} }
@@ -1276,7 +1272,7 @@ public void testSelectedPieceInChoosePieceEndState() {
public void testStayInStartPiece() { public void testStayInStartPiece() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -1292,7 +1288,7 @@ public void testStayInStartPiece() {
//todo send all messages which dont force a state change //todo send all messages which dont force a state change
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePiece);
assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); assertTrue(choosePieceStateMachine.getState() instanceof StartPiece);
@@ -1305,7 +1301,7 @@ public void testStayInStartPiece() {
public void testStartPieceToChoosePieceEndState() { public void testStartPieceToChoosePieceEndState() {
//sends the ClientAutomaton in GameState //sends the ClientAutomaton in GameState
clientAutomaton.gotoState(gameState); clientAutomaton.gotoState(gameState);
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in the Turn //sends the gameStateMachine in the Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turn);
@@ -1321,7 +1317,7 @@ public void testStartPieceToChoosePieceEndState() {
//Todo send the message which force a state change //Todo send the message which force a state change
assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(clientAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof Turn);
assertTrue(turnStateMachine.getState() instanceof MovePiece); assertTrue(turnStateMachine.getState() instanceof MovePiece);
} }

View File

@@ -5,6 +5,11 @@
import pp.mdga.game.Game; import pp.mdga.game.Game;
import pp.mdga.message.server.ServerMessage; import pp.mdga.message.server.ServerMessage;
import pp.mdga.server.*; import pp.mdga.server.*;
import pp.mdga.server.automaton.CeremonyState;
import pp.mdga.server.automaton.InterruptState;
import pp.mdga.server.automaton.LobbyState;
import pp.mdga.server.automaton.ServerAutomaton;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
@@ -46,25 +51,25 @@ public class ServerStateTest {
//TODO //TODO
private Animation animation; private Animation animation;
private Ceremony ceremony; private CeremonyState ceremonyState;
private ChoosePiece choosePiece; private ChoosePieceState choosePieceState;
private DetermineStartPlayer determineStartPlayer; private DetermineStartPlayerState determineStartPlayerState;
private FirstRoll firstRoll; private FirstRollStateState firstRollState;
private GameState gameState; private GameState gameState;
private Interrupt interrupt; private InterruptState interruptState;
private Lobby lobby; private LobbyState lobbyState;
private MovePiece movePiece; private MovePieceState movePieceState;
private NoPiece noPiece; private NoPieceState noPiece;
private NoTurn noTurn; private NoTurnState noTurnState;
private PlayPowerCard playPowerCard; private PlayPowerCard playPowerCard;
private PowerCard powerCard; private PowerCardState powerCardState;
private RollDice rollDice; private RollDiceState rollDiceState;
private SecondRoll secondRoll; private SecondRollState secondRoll;
private SelectPiece selectPiece; private SelectPieceState selectPiece;
private StartPiece startPiece; private StartPieceState startPiece;
private ThirdRoll thirdRoll; private ThirdRollState thirdRoll;
private Turn turn; private TurnState turnState;
private WaitingPiece waitingPiece; private WaitingPieceState waitingPiece;
/** /**
* TODO * TODO
@@ -115,36 +120,36 @@ public void send(int id, ServerMessage msg) {
from = 1234; from = 1234;
fromHost = 2345; fromHost = 2345;
choosePieceStateMachine = choosePiece.getChoosePieceMachine(); choosePieceStateMachine = choosePieceState.getChoosePieceMachine();
rollDiceMachine = rollDice.getRollDicemachine(); rollDiceMachine = rollDiceState.getRollDicemachine();
turnStateMachine = turn.getTurnStatemachine(); turnStateMachine = turnState.getTurnStatemachine();
serverAutomaton = logic.getServerAutomaton(); serverAutomaton = logic.getServerAutomaton();
gameStateMachine = gameState.getGameStatemachine(); gameStateMachine = gameState.getGameStatemachine();
thirdRoll = new ThirdRoll(rollDiceMachine, logic); thirdRoll = new ThirdRollState(rollDiceMachine, logic);
secondRoll = new SecondRoll(rollDiceMachine, logic); secondRoll = new SecondRollState(rollDiceMachine, logic);
firstRoll = new FirstRoll(rollDiceMachine, logic); firstRollState = new FirstRollStateState(rollDiceMachine, logic);
noPiece = new NoPiece(choosePieceStateMachine, logic); noPiece = new NoPieceState(choosePieceStateMachine, logic);
noTurn = new NoTurn(choosePieceStateMachine, logic); noTurnState = new NoTurnState(choosePieceStateMachine, logic);
waitingPiece = new WaitingPiece(choosePieceStateMachine, logic); waitingPiece = new WaitingPieceState(choosePieceStateMachine, logic);
startPiece = new StartPiece(choosePieceStateMachine, logic); startPiece = new StartPieceState(choosePieceStateMachine, logic);
selectPiece = new SelectPiece(choosePieceStateMachine, logic); selectPiece = new SelectPieceState(choosePieceStateMachine, logic);
powerCard = new PowerCard(turnStateMachine, logic); powerCardState = new PowerCardState(turnStateMachine, logic);
playPowerCard = new PlayPowerCard(turnStateMachine, logic); playPowerCard = new PlayPowerCard(turnStateMachine, logic);
rollDice = new RollDice(turnStateMachine, logic); rollDiceState = new RollDiceState(turnStateMachine, logic);
choosePiece = new ChoosePiece(turnStateMachine, logic); choosePieceState = new ChoosePieceState(turnStateMachine, logic);
movePiece = new MovePiece(turnStateMachine, logic); movePieceState = new MovePieceState(turnStateMachine, logic);
determineStartPlayer = new DetermineStartPlayer(gameStateMachine, logic); determineStartPlayerState = new DetermineStartPlayerState(gameStateMachine, logic);
turn = new Turn(gameStateMachine, logic); turnState = new TurnState(gameStateMachine, logic);
animation = new Animation(gameStateMachine, logic); animation = new Animation(gameStateMachine, logic);
lobby = new Lobby(serverAutomaton, logic); lobbyState = new LobbyState(serverAutomaton, logic);
gameState = new GameState(serverAutomaton, logic); gameState = new GameState(serverAutomaton, logic);
ceremony = new Ceremony(serverAutomaton, logic); ceremonyState = new CeremonyState(serverAutomaton, logic);
interrupt = new Interrupt(serverAutomaton, logic, gameState); interruptState = new InterruptState(serverAutomaton, logic, gameState);
} }
/** /**
@@ -152,7 +157,7 @@ public void send(int id, ServerMessage msg) {
*/ */
@Test @Test
public void testInitialStateServerState() { public void testInitialStateServerState() {
assertTrue(serverAutomaton.getState() instanceof Lobby); assertTrue(serverAutomaton.getState() instanceof LobbyState);
} }
/** /**
@@ -162,8 +167,8 @@ public void testInitialStateServerState() {
@Test @Test
public void testLobbyToDetermineStartPlayer() { public void testLobbyToDetermineStartPlayer() {
//sends the server in the lobby-state //sends the server in the lobby-state
serverAutomaton.gotoState(lobby); serverAutomaton.gotoState(lobbyState);
assertTrue(serverAutomaton.getState() instanceof Lobby); assertTrue(serverAutomaton.getState() instanceof LobbyState);
//sends the startGame message from the Host to the server //sends the startGame message from the Host to the server
logic.received(clientStartGame, from); logic.received(clientStartGame, from);
@@ -172,7 +177,7 @@ public void testLobbyToDetermineStartPlayer() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
GameState gameState1 = (GameState) serverAutomaton.getState();//Todo erzeuge state GameState gameState1 = (GameState) serverAutomaton.getState();//Todo erzeuge state
GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); GameStateMachine gameStateMachine1 = gameState.getGameStateMachine();
assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayerState);
} }
/** /**
@@ -181,8 +186,8 @@ public void testLobbyToDetermineStartPlayer() {
@Test @Test
public void testStayInLobby() { public void testStayInLobby() {
//sends the server in the lobby-state //sends the server in the lobby-state
serverAutomaton.gotoState(lobby); serverAutomaton.gotoState(lobbyState);
assertTrue(serverAutomaton.getState() instanceof Lobby); assertTrue(serverAutomaton.getState() instanceof LobbyState);
//TODO logic gets all messages //TODO logic gets all messages
logic.received(animationEnd, from); logic.received(animationEnd, from);
@@ -203,7 +208,7 @@ public void testStayInLobby() {
logic.received(selectTSK, from); logic.received(selectTSK, from);
//tests if Server is still in Lobby //tests if Server is still in Lobby
assertTrue(serverAutomaton.getState() instanceof Lobby); assertTrue(serverAutomaton.getState() instanceof LobbyState);
} }
/** /**
@@ -218,7 +223,7 @@ public void testServerGameSubStatesToInterrupt() {
//TODO create interrupt //TODO create interrupt
//tests if the server is in the Interrupt-state //tests if the server is in the Interrupt-state
assertTrue(serverAutomaton.getState() instanceof Interrupt); assertTrue(serverAutomaton.getState() instanceof InterruptState);
} }
/** /**
@@ -233,7 +238,7 @@ public void testServerGameToCeremony() {
//Todo game is finished //Todo game is finished
//tests if the server is in the Ceremony-state //tests if the server is in the Ceremony-state
assertTrue(serverAutomaton.getState() instanceof Ceremony); assertTrue(serverAutomaton.getState() instanceof CeremonyState);
} }
/** /**
@@ -242,8 +247,8 @@ public void testServerGameToCeremony() {
@Test @Test
public void testInterruptToGameContinue() { public void testInterruptToGameContinue() {
//sends the server in the Interrupt-State //sends the server in the Interrupt-State
serverAutomaton.gotoState(interrupt); serverAutomaton.gotoState(interruptState);
assertTrue(serverAutomaton.getState() instanceof Interrupt); assertTrue(serverAutomaton.getState() instanceof InterruptState);
//sends the continue-message to the server //sends the continue-message to the server
logic.received(forceContinueGame, from); logic.received(forceContinueGame, from);
@@ -258,8 +263,8 @@ public void testInterruptToGameContinue() {
@Test @Test
public void testInterruptToGameReconnect() { public void testInterruptToGameReconnect() {
//sends the server in the Interrupt-State //sends the server in the Interrupt-State
serverAutomaton.gotoState(interrupt); serverAutomaton.gotoState(interruptState);
assertTrue(serverAutomaton.getState() instanceof Interrupt); assertTrue(serverAutomaton.getState() instanceof InterruptState);
//todo implement the timer //todo implement the timer
@@ -273,8 +278,8 @@ public void testInterruptToGameReconnect() {
@Test @Test
public void testInterruptToGameTimer() { public void testInterruptToGameTimer() {
//sends the server in the Interrupt-State //sends the server in the Interrupt-State
serverAutomaton.gotoState(interrupt); serverAutomaton.gotoState(interruptState);
assertTrue(serverAutomaton.getState() instanceof Interrupt); assertTrue(serverAutomaton.getState() instanceof InterruptState);
//Todo implement the timer //Todo implement the timer
@@ -301,14 +306,14 @@ public void testDetermineStartPlayerToDetermineStartPlayer1() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in DSP-state //sends the gameStateMachine in DSP-state
gameStateMachine.gotoState(determineStartPlayer); gameStateMachine.gotoState(determineStartPlayerState);
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayerState);
//TODO sends messages to the server //TODO sends messages to the server
//tests if the server is still in DSP-state //tests if the server is still in DSP-state
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayerState);
} }
/** /**
@@ -321,14 +326,14 @@ public void testDetermineStartPlayerToDetermineStartPlayer2() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in DSP-state //sends the gameStateMachine in DSP-state
gameStateMachine.gotoState(determineStartPlayer); gameStateMachine.gotoState(determineStartPlayerState);
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayerState);
//TODO sends messages 2 RequestDiceMessage, die gleich geränkt werden to the server //TODO sends messages 2 RequestDiceMessage, die gleich geränkt werden to the server
//tests if the server is still in DSP-state //tests if the server is still in DSP-state
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayerState);
} }
/** /**
@@ -341,8 +346,8 @@ public void testDetermineStartPlayerToAnimation() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in DSP-state //sends the gameStateMachine in DSP-state
gameStateMachine.gotoState(determineStartPlayer); gameStateMachine.gotoState(determineStartPlayerState);
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayerState);
//TODO sends messages 2 RequestDiceMessage, die ungleich geränkt werden, sodass der server weitergeht //TODO sends messages 2 RequestDiceMessage, die ungleich geränkt werden, sodass der server weitergeht
@@ -375,10 +380,10 @@ public void testAnimationToPowerCard() {
//tests if the server is in the PowerCard-state //tests if the server is in the PowerCard-state
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
Turn turn1 = (Turn) gameStateMachine.getState(); TurnState turnState1 = (TurnState) gameStateMachine.getState();
TurnStateMachine turnStateMachine = (TurnStateMachine) turn1.getTurnStateMachine(); TurnStateMachine turnStateMachine = (TurnStateMachine) turnState1.getTurnStateMachine();
assertTrue(turnStateMachine.getState() instanceof PowerCard); assertTrue(turnStateMachine.getState() instanceof PowerCardState);
} }
/** /**
@@ -392,8 +397,8 @@ public void testTurnToAnimation() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in Turn //sends the gameStateMachine in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//todo set the turn finished and there are still two players left //todo set the turn finished and there are still two players left
@@ -413,13 +418,13 @@ public void testTurnToGameEndState() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in Turn //sends the gameStateMachine in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//todo set the turn finished and there is only one players left //todo set the turn finished and there is only one players left
//tests if the server is in the end-state of game, Ceremony //tests if the server is in the end-state of game, Ceremony
assertTrue(serverAutomaton.getState() instanceof Ceremony); assertTrue(serverAutomaton.getState() instanceof CeremonyState);
} }
/** /**
@@ -433,19 +438,19 @@ public void testStayInPowerCard() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in Turn //sends the gameStateMachine in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the TurnStateMachine in PowerCard //sends the TurnStateMachine in PowerCard
turnStateMachine.gotoState(powerCard); turnStateMachine.gotoState(powerCardState);
assertTrue(turnStateMachine.getState() instanceof PowerCard); assertTrue(turnStateMachine.getState() instanceof PowerCardState);
//Todo: receive messages which dont lead to a state change //Todo: receive messages which dont lead to a state change
//tests if the server is in PowerCard //tests if the server is in PowerCard
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof PowerCard); assertTrue(turnStateMachine.getState() instanceof PowerCardState);
} }
/** /**
@@ -459,18 +464,18 @@ public void testPowerCardToPlayPowerCard() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in Turn //sends the gameStateMachine in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the TurnStateMachine in PowerCard //sends the TurnStateMachine in PowerCard
turnStateMachine.gotoState(powerCard); turnStateMachine.gotoState(powerCardState);
assertTrue(turnStateMachine.getState() instanceof PowerCard); assertTrue(turnStateMachine.getState() instanceof PowerCardState);
//todo //todo
//tests if the server is in PlayPowerCard //tests if the server is in PlayPowerCard
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); assertTrue(turnStateMachine.getState() instanceof PlayPowerCard);
} }
@@ -485,8 +490,8 @@ public void testPlayPowerCardToRollDice() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in Turn //sends the gameStateMachine in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the TurnStateMachine in PowerCard //sends the TurnStateMachine in PowerCard
turnStateMachine.gotoState(playPowerCard); turnStateMachine.gotoState(playPowerCard);
@@ -495,7 +500,7 @@ public void testPlayPowerCardToRollDice() {
//receive first AnimationEndMessage from the host //receive first AnimationEndMessage from the host
logic.received(animationEnd, fromHost); logic.received(animationEnd, fromHost);
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); assertTrue(turnStateMachine.getState() instanceof PlayPowerCard);
//receive second AnimationEndMessage //receive second AnimationEndMessage
@@ -503,11 +508,11 @@ public void testPlayPowerCardToRollDice() {
//tests if the server is in RollDice and in FirstRoll //tests if the server is in RollDice and in FirstRoll
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof RollDice); assertTrue(turnStateMachine.getState() instanceof RollDiceState);
RollDice rollDice = (RollDice) turnStateMachine.getState(); RollDiceState rollDiceState = (RollDiceState) turnStateMachine.getState();
RollDiceMachine rollDiceMachine1 = rollDice.getRollDiceStateMachine(); RollDiceMachine rollDiceMachine1 = rollDiceState.getRollDiceStateMachine();
assertTrue(rollDiceMachine1.getState() instanceof FirstRoll); assertTrue(rollDiceMachine1.getState() instanceof FirstRollStateState);
} }
/** /**
@@ -521,18 +526,18 @@ public void testChoosePieceToMovePiece() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in Turn //sends the gameStateMachine in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the TurnStateMachine in ChoosePiece //sends the TurnStateMachine in ChoosePiece
turnStateMachine.gotoState(choosePiece); turnStateMachine.gotoState(choosePieceState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
//Todo ??? //Todo ???
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof MovePiece); assertTrue(turnStateMachine.getState() instanceof MovePieceState);
} }
/** /**
@@ -546,12 +551,12 @@ public void testMovePieceToTurnEndState() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in Turn //sends the gameStateMachine in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the TurnStateMachine in MovePiece //sends the TurnStateMachine in MovePiece
turnStateMachine.gotoState(movePiece); turnStateMachine.gotoState(movePieceState);
assertTrue(turnStateMachine.getState() instanceof MovePiece); assertTrue(turnStateMachine.getState() instanceof MovePieceState);
//Todo no 6 was rolled, so the server looks, if there are 2 or less player are still in the game //Todo no 6 was rolled, so the server looks, if there are 2 or less player are still in the game
//TODO //TODO
@@ -569,21 +574,21 @@ public void testMovePieceToFirstRoll() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in Turn //sends the gameStateMachine in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the TurnStateMachine in MovePiece //sends the TurnStateMachine in MovePiece
turnStateMachine.gotoState(movePiece); turnStateMachine.gotoState(movePieceState);
assertTrue(turnStateMachine.getState() instanceof MovePiece); assertTrue(turnStateMachine.getState() instanceof MovePieceState);
//Todo the player rolled a 6 and the player is not finished //Todo the player rolled a 6 and the player is not finished
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof RollDice); assertTrue(turnStateMachine.getState() instanceof RollDiceState);
RollDice rollDice = (RollDice) turnStateMachine.getState(); RollDiceState rollDiceState = (RollDiceState) turnStateMachine.getState();
RollDiceMachine rollDiceMachine1 = rollDice.getRollDiceStateMachine(); RollDiceMachine rollDiceMachine1 = rollDiceState.getRollDiceStateMachine();
assertTrue(rollDiceMachine1.getState() instanceof FirstRoll); assertTrue(rollDiceMachine1.getState() instanceof FirstRollStateState);
} }
/** /**
@@ -597,26 +602,26 @@ public void testFirstRollToRollDiceEndState() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in Turn //sends the gameStateMachine in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the TurnStateMachine in RollDice //sends the TurnStateMachine in RollDice
turnStateMachine.gotoState(rollDice); turnStateMachine.gotoState(rollDiceState);
assertTrue(turnStateMachine.getState() instanceof RollDice); assertTrue(turnStateMachine.getState() instanceof RollDiceState);
//sends the RollDiceMachine in FirstRoll //sends the RollDiceMachine in FirstRoll
rollDiceMachine.gotoState(firstRoll); rollDiceMachine.gotoState(firstRollState);
assertTrue(rollDiceMachine.getState() instanceof FirstRoll); assertTrue(rollDiceMachine.getState() instanceof FirstRollStateState);
//TODO 2 Möglichkeiten //TODO 2 Möglichkeiten
//tests if the server is in NoPiece of ChoosePiece //tests if the server is in NoPiece of ChoosePiece
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
ChoosePiece choosePiece1 = (ChoosePiece) turnStateMachine.getState(); ChoosePieceState choosePieceState1 = (ChoosePieceState) turnStateMachine.getState();
ChoosePieceStateMachine choosePieceStateMachine = choosePiece1.getChoosePieceStateMachine(); ChoosePieceStateMachine choosePieceStateMachine = choosePieceState1.getChoosePieceStateMachine();
assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState);
} }
/** /**
@@ -630,24 +635,24 @@ public void testFirstRollToSecondRoll() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in Turn //sends the gameStateMachine in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the TurnStateMachine in RollDice //sends the TurnStateMachine in RollDice
turnStateMachine.gotoState(rollDice); turnStateMachine.gotoState(rollDiceState);
assertTrue(turnStateMachine.getState() instanceof RollDice); assertTrue(turnStateMachine.getState() instanceof RollDiceState);
//sends the RollDiceMachine in FirstRoll //sends the RollDiceMachine in FirstRoll
rollDiceMachine.gotoState(firstRoll); rollDiceMachine.gotoState(firstRollState);
assertTrue(rollDiceMachine.getState() instanceof FirstRoll); assertTrue(rollDiceMachine.getState() instanceof FirstRollStateState);
//Todo player has no figures to move and had no 6 //Todo player has no figures to move and had no 6
//tests if the server is in the SecondRoll //tests if the server is in the SecondRoll
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof RollDice); assertTrue(turnStateMachine.getState() instanceof RollDiceState);
assertTrue(rollDiceMachine.getState() instanceof SecondRoll); assertTrue(rollDiceMachine.getState() instanceof SecondRollState);
} }
/** /**
@@ -661,26 +666,26 @@ public void testSecondRollToRollDiceEndState() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in Turn //sends the gameStateMachine in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the TurnStateMachine in RollDice //sends the TurnStateMachine in RollDice
turnStateMachine.gotoState(rollDice); turnStateMachine.gotoState(rollDiceState);
assertTrue(turnStateMachine.getState() instanceof RollDice); assertTrue(turnStateMachine.getState() instanceof RollDiceState);
//sends the RollDiceMachine in SecondRoll //sends the RollDiceMachine in SecondRoll
rollDiceMachine.gotoState(secondRoll); rollDiceMachine.gotoState(secondRoll);
assertTrue(rollDiceMachine.getState() instanceof SecondRoll); assertTrue(rollDiceMachine.getState() instanceof SecondRollState);
//Todo //Todo
//tests if the server is in NoPiece of ChoosePiece //tests if the server is in NoPiece of ChoosePiece
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
ChoosePiece choosePiece1 = (ChoosePiece) turnStateMachine.getState(); ChoosePieceState choosePieceState1 = (ChoosePieceState) turnStateMachine.getState();
ChoosePieceStateMachine choosePieceStateMachine = choosePiece1.getChoosePieceStateMachine(); ChoosePieceStateMachine choosePieceStateMachine = choosePieceState1.getChoosePieceStateMachine();
assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState);
} }
/** /**
@@ -694,24 +699,24 @@ public void testSecondRollToThirdRoll() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in Turn //sends the gameStateMachine in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the TurnStateMachine in RollDice //sends the TurnStateMachine in RollDice
turnStateMachine.gotoState(rollDice); turnStateMachine.gotoState(rollDiceState);
assertTrue(turnStateMachine.getState() instanceof RollDice); assertTrue(turnStateMachine.getState() instanceof RollDiceState);
//sends the RollDiceMachine in SecondRoll //sends the RollDiceMachine in SecondRoll
rollDiceMachine.gotoState(secondRoll); rollDiceMachine.gotoState(secondRoll);
assertTrue(rollDiceMachine.getState() instanceof SecondRoll); assertTrue(rollDiceMachine.getState() instanceof SecondRollState);
//Todo player has no figures to move and had no 6 //Todo player has no figures to move and had no 6
//tests if the server is in the ThirdRoll //tests if the server is in the ThirdRoll
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof RollDice); assertTrue(turnStateMachine.getState() instanceof RollDiceState);
assertTrue(rollDiceMachine.getState() instanceof ThirdRoll); assertTrue(rollDiceMachine.getState() instanceof ThirdRollState);
} }
/** /**
@@ -725,26 +730,26 @@ public void testThirdRollToRollDiceEndState() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in Turn //sends the gameStateMachine in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the TurnStateMachine in RollDice //sends the TurnStateMachine in RollDice
turnStateMachine.gotoState(rollDice); turnStateMachine.gotoState(rollDiceState);
assertTrue(turnStateMachine.getState() instanceof RollDice); assertTrue(turnStateMachine.getState() instanceof RollDiceState);
//sends the RollDiceMachine in ThirdRoll //sends the RollDiceMachine in ThirdRoll
rollDiceMachine.gotoState(thirdRoll); rollDiceMachine.gotoState(thirdRoll);
assertTrue(rollDiceMachine.getState() instanceof ThirdRoll); assertTrue(rollDiceMachine.getState() instanceof ThirdRollState);
//Todo //Todo
//tests if the server is in NoPiece of ChoosePiece //tests if the server is in NoPiece of ChoosePiece
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
ChoosePiece choosePiece1 = (ChoosePiece) turnStateMachine.getState(); ChoosePieceState choosePieceState1 = (ChoosePieceState) turnStateMachine.getState();
ChoosePieceStateMachine choosePieceStateMachine = choosePiece1.getChoosePieceStateMachine(); ChoosePieceStateMachine choosePieceStateMachine = choosePieceState1.getChoosePieceStateMachine();
assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState);
} }
/** /**
@@ -758,16 +763,16 @@ public void testThirdRollToTurnEndState() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the gameStateMachine in Turn //sends the gameStateMachine in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the TurnStateMachine in RollDice //sends the TurnStateMachine in RollDice
turnStateMachine.gotoState(rollDice); turnStateMachine.gotoState(rollDiceState);
assertTrue(turnStateMachine.getState() instanceof RollDice); assertTrue(turnStateMachine.getState() instanceof RollDiceState);
//sends the RollDiceMachine in ThirdRoll //sends the RollDiceMachine in ThirdRoll
rollDiceMachine.gotoState(thirdRoll); rollDiceMachine.gotoState(thirdRoll);
assertTrue(rollDiceMachine.getState() instanceof ThirdRoll); assertTrue(rollDiceMachine.getState() instanceof ThirdRollState);
//Todo //Todo
} }
@@ -783,24 +788,24 @@ public void testNoPieceToWaitingPiece() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the server in Turn //sends the server in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the server in ChoosePiece //sends the server in ChoosePiece
turnStateMachine.gotoState(choosePiece); turnStateMachine.gotoState(choosePieceState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
//sends the server in NoPiece //sends the server in NoPiece
choosePieceStateMachine.gotoState(noPiece); choosePieceStateMachine.gotoState(noPiece);
assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState);
//TODO //TODO
//tests if the server is in WaitingPiece //tests if the server is in WaitingPiece
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState);
} }
@@ -815,24 +820,24 @@ public void testNoPieceToNoTurn() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the server in Turn //sends the server in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the server in ChoosePiece //sends the server in ChoosePiece
turnStateMachine.gotoState(choosePiece); turnStateMachine.gotoState(choosePieceState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
//sends the server in NoPiece //sends the server in NoPiece
choosePieceStateMachine.gotoState(noPiece); choosePieceStateMachine.gotoState(noPiece);
assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState);
//TODO //TODO
//tests if the server is in NoTurn //tests if the server is in NoTurn
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
assertTrue(choosePieceStateMachine.getState() instanceof NoTurn); assertTrue(choosePieceStateMachine.getState() instanceof NoTurnState);
} }
/** /**
@@ -846,16 +851,16 @@ public void testNoTurnToTurnEndState() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the server in Turn //sends the server in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the server in ChoosePiece //sends the server in ChoosePiece
turnStateMachine.gotoState(choosePiece); turnStateMachine.gotoState(choosePieceState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
//sends the server in NoTurn //sends the server in NoTurn
choosePieceStateMachine.gotoState(noTurn); choosePieceStateMachine.gotoState(noTurnState);
assertTrue(choosePieceStateMachine.getState() instanceof NoTurn); assertTrue(choosePieceStateMachine.getState() instanceof NoTurnState);
//TODO //TODO
} }
@@ -871,24 +876,24 @@ public void testStayInWaitingPiece() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the server in Turn //sends the server in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the server in ChoosePiece //sends the server in ChoosePiece
turnStateMachine.gotoState(choosePiece); turnStateMachine.gotoState(choosePieceState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
//sends the server in WaitingPiece //sends the server in WaitingPiece
choosePieceStateMachine.gotoState(waitingPiece); choosePieceStateMachine.gotoState(waitingPiece);
assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState);
//TODO //TODO
//tests if the server is in WaitingPiece //tests if the server is in WaitingPiece
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState);
} }
/** /**
@@ -902,16 +907,16 @@ public void testWaitingPieceToMovePiece() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the server in Turn //sends the server in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the server in ChoosePiece //sends the server in ChoosePiece
turnStateMachine.gotoState(choosePiece); turnStateMachine.gotoState(choosePieceState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
//sends the server in WaitingPiece //sends the server in WaitingPiece
choosePieceStateMachine.gotoState(waitingPiece); choosePieceStateMachine.gotoState(waitingPiece);
assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState);
//TODO //TODO
} }
@@ -927,24 +932,24 @@ public void testNoPieceToSelectPiece() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the server in Turn //sends the server in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the server in ChoosePiece //sends the server in ChoosePiece
turnStateMachine.gotoState(choosePiece); turnStateMachine.gotoState(choosePieceState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
//sends the server in NoPiece //sends the server in NoPiece
choosePieceStateMachine.gotoState(noPiece); choosePieceStateMachine.gotoState(noPiece);
assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState);
//TODO //TODO
//tests if the server is in SelectPiece //tests if the server is in SelectPiece
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState);
} }
/** /**
@@ -958,24 +963,24 @@ public void testNoPieceToStartPiece() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the server in Turn //sends the server in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the server in ChoosePiece //sends the server in ChoosePiece
turnStateMachine.gotoState(choosePiece); turnStateMachine.gotoState(choosePieceState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
//sends the server in NoPiece //sends the server in NoPiece
choosePieceStateMachine.gotoState(noPiece); choosePieceStateMachine.gotoState(noPiece);
assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState);
//TODO //TODO
//tests if the server is in StartPiece //tests if the server is in StartPiece
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState);
} }
/** /**
@@ -989,24 +994,24 @@ public void testStayInSelectPiece() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the server in Turn //sends the server in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the server in ChoosePiece //sends the server in ChoosePiece
turnStateMachine.gotoState(choosePiece); turnStateMachine.gotoState(choosePieceState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
//sends the server in SelectPiece //sends the server in SelectPiece
choosePieceStateMachine.gotoState(selectPiece); choosePieceStateMachine.gotoState(selectPiece);
assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState);
//TODO //TODO
//tests if the server is in SelectPiece //tests if the server is in SelectPiece
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState);
} }
/** /**
@@ -1020,16 +1025,16 @@ public void testSelectPieceToMovePiece() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the server in Turn //sends the server in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the server in ChoosePiece //sends the server in ChoosePiece
turnStateMachine.gotoState(choosePiece); turnStateMachine.gotoState(choosePieceState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
//sends the server in SelectPiece //sends the server in SelectPiece
choosePieceStateMachine.gotoState(selectPiece); choosePieceStateMachine.gotoState(selectPiece);
assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState);
//TODO //TODO
} }
@@ -1045,24 +1050,24 @@ public void testStayInStartPiece() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the server in Turn //sends the server in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the server in ChoosePiece //sends the server in ChoosePiece
turnStateMachine.gotoState(choosePiece); turnStateMachine.gotoState(choosePieceState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
//sends the server in StartPiece //sends the server in StartPiece
choosePieceStateMachine.gotoState(startPiece); choosePieceStateMachine.gotoState(startPiece);
assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState);
//TODO //TODO
//tests if the server is in StartPiece //tests if the server is in StartPiece
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState);
} }
/** /**
@@ -1076,16 +1081,16 @@ public void testStartPieceToMovePiece() {
assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(serverAutomaton.getState() instanceof GameState);
//sends the server in Turn //sends the server in Turn
gameStateMachine.gotoState(turn); gameStateMachine.gotoState(turnState);
assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(gameStateMachine.getState() instanceof TurnState);
//sends the server in ChoosePiece //sends the server in ChoosePiece
turnStateMachine.gotoState(choosePiece); turnStateMachine.gotoState(choosePieceState);
assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(turnStateMachine.getState() instanceof ChoosePieceState);
//sends the server in StartPiece //sends the server in StartPiece
choosePieceStateMachine.gotoState(startPiece); choosePieceStateMachine.gotoState(startPiece);
assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState);
//TODO //TODO
} }