Merge branch 'development' into 'dev/test'
merge edited model into test See merge request progproj/gruppen-ht24/Gruppe-01!18
This commit is contained in:
		@@ -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>
 | 
			
		||||
@@ -1,14 +1,11 @@
 | 
			
		||||
package pp.mdga.client.server;
 | 
			
		||||
 | 
			
		||||
import com.jme3.network.ConnectionListener;
 | 
			
		||||
import com.jme3.network.HostedConnection;
 | 
			
		||||
import com.jme3.network.Message;
 | 
			
		||||
import com.jme3.network.MessageListener;
 | 
			
		||||
import com.jme3.network.Network;
 | 
			
		||||
import com.jme3.network.Server;
 | 
			
		||||
import com.jme3.network.*;
 | 
			
		||||
import com.jme3.network.serializing.Serializer;
 | 
			
		||||
import pp.mdga.game.Game;
 | 
			
		||||
import pp.mdga.game.Player;
 | 
			
		||||
import pp.mdga.message.client.*;
 | 
			
		||||
import pp.mdga.message.server.ServerMessage;
 | 
			
		||||
import pp.mdga.server.ServerGameLogic;
 | 
			
		||||
import pp.mdga.server.ServerSender;
 | 
			
		||||
 | 
			
		||||
@@ -16,6 +13,7 @@
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.lang.System.Logger;
 | 
			
		||||
import java.lang.System.Logger.Level;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.concurrent.BlockingQueue;
 | 
			
		||||
import java.util.concurrent.LinkedBlockingQueue;
 | 
			
		||||
import java.util.logging.LogManager;
 | 
			
		||||
@@ -53,7 +51,7 @@ public static void main(String[] args) {
 | 
			
		||||
     */
 | 
			
		||||
    public MdgaServer() {
 | 
			
		||||
        LOGGER.log(Level.INFO, "Creating MdgaServer"); //NON-NLS
 | 
			
		||||
        logic = new ServerGameLogic(new Game(), this);
 | 
			
		||||
        logic = new ServerGameLogic(this, new Game());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void run() {
 | 
			
		||||
@@ -92,14 +90,14 @@ private void initializeSerializables() {
 | 
			
		||||
        Serializer.registerClass(ClientStartGame.class);
 | 
			
		||||
        Serializer.registerClass(DeselectTSK.class);
 | 
			
		||||
        Serializer.registerClass(ForceContinueGame.class);
 | 
			
		||||
        Serializer.registerClass(ForceStartGame.class);
 | 
			
		||||
        Serializer.registerClass(StartGame.class);
 | 
			
		||||
        Serializer.registerClass(JoinServer.class);
 | 
			
		||||
        Serializer.registerClass(LeaveGame.class);
 | 
			
		||||
        Serializer.registerClass(LobbyNotReady.class);
 | 
			
		||||
        Serializer.registerClass(LobbyReady.class);
 | 
			
		||||
        Serializer.registerClass(NoPowerCard.class);
 | 
			
		||||
        Serializer.registerClass(RequestBriefing.class);
 | 
			
		||||
        Serializer.registerClass(RequestDice.class);
 | 
			
		||||
        Serializer.registerClass(RequestDie.class);
 | 
			
		||||
        Serializer.registerClass(RequestMove.class);
 | 
			
		||||
        Serializer.registerClass(RequestPlayCard.class);
 | 
			
		||||
        Serializer.registerClass(SelectCard.class);
 | 
			
		||||
@@ -147,7 +145,7 @@ private void registerListeners() {
 | 
			
		||||
        myServer.addMessageListener(this, LobbyReady.class);
 | 
			
		||||
        myServer.addMessageListener(this, NoPowerCard.class);
 | 
			
		||||
        myServer.addMessageListener(this, RequestBriefing.class);
 | 
			
		||||
        myServer.addMessageListener(this, RequestDice.class);
 | 
			
		||||
        myServer.addMessageListener(this, RequestDie.class);
 | 
			
		||||
        myServer.addMessageListener(this, RequestMove.class);
 | 
			
		||||
        myServer.addMessageListener(this, RequestPlayCard.class);
 | 
			
		||||
        myServer.addMessageListener(this, SelectCard.class);
 | 
			
		||||
@@ -156,32 +154,42 @@ private void registerListeners() {
 | 
			
		||||
        myServer.addConnectionListener(this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void messageReceived(HostedConnection source, Message message) {
 | 
			
		||||
 | 
			
		||||
    public void messageReceived(HostedConnection source, ClientMessage message) {
 | 
			
		||||
        LOGGER.log(Level.INFO, "message received from {0}: {1}", source.getId(), message); //NON-NLS
 | 
			
		||||
        if (message instanceof ClientMessage clientMessage)
 | 
			
		||||
            pendingMessages.add(new ReceivedMessage(clientMessage, source.getId()));
 | 
			
		||||
        pendingMessages.add(new ReceivedMessage(message, source.getId()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void connectionAdded(Server server, HostedConnection hostedConnection) {
 | 
			
		||||
        LOGGER.log(Level.INFO, "new connection {0}", hostedConnection); //NON-NLS
 | 
			
		||||
        logic.addPlayer(hostedConnection.getId());
 | 
			
		||||
        // ToDo: Synchronize data between server and client.
 | 
			
		||||
        logic.getGame().addPlayer(hostedConnection.getId(), new Player());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void connectionRemoved(Server server, HostedConnection hostedConnection) {
 | 
			
		||||
        LOGGER.log(Level.INFO, "connection closed: {0}", hostedConnection); //NON-NLS
 | 
			
		||||
        final Player player = logic.getPlayerById(hostedConnection.getId());
 | 
			
		||||
        final Player player = logic.getGame().getPlayerById(hostedConnection.getId());
 | 
			
		||||
        if (player == null)
 | 
			
		||||
            LOGGER.log(Level.INFO, "closed connection does not belong to an active player"); //NON-NLS
 | 
			
		||||
        else { //NON-NLS
 | 
			
		||||
            LOGGER.log(Level.INFO, "closed connection belongs to {0}", player); //NON-NLS
 | 
			
		||||
            exit(0);
 | 
			
		||||
            // exit(0);
 | 
			
		||||
            this.handleDisconnect(hostedConnection.getId());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void exit(int exitValue) { //NON-NLS
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to handle unintentional disconnections from players.
 | 
			
		||||
     *
 | 
			
		||||
     * @param id as the id of the disconnected player.
 | 
			
		||||
     */
 | 
			
		||||
    public void handleDisconnect(int id) {
 | 
			
		||||
        this.logic.received(new Disconnected(), id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void exit(int exitValue) { //NON-NLS
 | 
			
		||||
        LOGGER.log(Level.INFO, "close request"); //NON-NLS
 | 
			
		||||
        if (myServer != null)
 | 
			
		||||
            for (HostedConnection client : myServer.getConnections()) //NON-NLS
 | 
			
		||||
@@ -206,4 +214,16 @@ public void send(int id, ServerMessage message) {
 | 
			
		||||
        else
 | 
			
		||||
            LOGGER.log(Level.ERROR, "there is no connection with id={0}", id); //NON-NLS
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 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.
 | 
			
		||||
     */
 | 
			
		||||
    public void broadcast(ServerMessage message) {
 | 
			
		||||
        for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
 | 
			
		||||
            this.send(entry.getValue().getId(), message);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Animation extends ClientState {
 | 
			
		||||
    public Animation(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class AudioSettings extends ClientState {
 | 
			
		||||
    public AudioSettings(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,14 +1,19 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Ceremony extends ClientState {
 | 
			
		||||
    private final CeremonyStateMachine ceremonyStateMachine;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public Ceremony(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
        this.ceremonyStateMachine = new CeremonyStateMachine(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public CeremonyStateMachine getCeremonyStateMachine() {
 | 
			
		||||
        return ceremonyStateMachine;
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class CeremonyStateMachine extends ClientStateMachine {
 | 
			
		||||
 | 
			
		||||
    public CeremonyStateMachine(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Podium initialState() {
 | 
			
		||||
        return new Podium(this, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,15 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class ChoosePiece extends ClientState {
 | 
			
		||||
 | 
			
		||||
    private final ChoosePieceStateMachine choosePieceStateMachine;
 | 
			
		||||
 | 
			
		||||
    public ChoosePiece(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
        this.choosePieceStateMachine = new ChoosePieceStateMachine(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ChoosePieceStateMachine getChoosePieceStateMachine() {
 | 
			
		||||
        return choosePieceStateMachine;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class ChoosePieceStateMachine extends ClientStateMachine{
 | 
			
		||||
    public ChoosePieceStateMachine(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public NoPiece initialState() {
 | 
			
		||||
        return new NoPiece(this, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class ChoosePowerCard extends ClientState {
 | 
			
		||||
    public ChoosePowerCard(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class ClientAutomaton extends ClientStateMachine {
 | 
			
		||||
 | 
			
		||||
    public ClientAutomaton(ClientGameLogic logic){
 | 
			
		||||
        super(null, logic);
 | 
			
		||||
        entry();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Dialogs initialState(){
 | 
			
		||||
        return new Dialogs(this, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,20 +1,33 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.game.BonusCard;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
import pp.mdga.game.Game;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.message.client.ClientMessage;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
public class ClientGameLogic implements ServerInterpreter {
 | 
			
		||||
    static final System.Logger LOGGER = System.getLogger(ClientGameLogic.class.getName());
 | 
			
		||||
 | 
			
		||||
    private Game game;
 | 
			
		||||
    private final ClientSender clientSender;
 | 
			
		||||
    private ClientState state;
 | 
			
		||||
    private Map<UUID, Piece> pieces;
 | 
			
		||||
    private Map<UUID, BonusCard> cards;
 | 
			
		||||
 | 
			
		||||
    private Dialogs dialogs = new Dialogs(null, this);
 | 
			
		||||
    private GameState gameState = new GameState(null, this);
 | 
			
		||||
    private Ceremony ceremony = new Ceremony(null, this);
 | 
			
		||||
    private Interrupt interrupt = new Interrupt(null, this);
 | 
			
		||||
 | 
			
		||||
    public ClientGameLogic(Game game, ClientSender clientSender) {
 | 
			
		||||
        this.game = game;
 | 
			
		||||
        this.clientSender = clientSender;
 | 
			
		||||
        state = new ClientAutomaton(this);
 | 
			
		||||
        state = dialogs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void send(ClientMessage msg){
 | 
			
		||||
@@ -36,136 +49,197 @@ public ClientState getState(){
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ActivePlayer msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(AnyPiece msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(Briefing msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(CeremonyMessage msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(Dice msg) {
 | 
			
		||||
 | 
			
		||||
    public void received(Die msg) {
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DiceAgain msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DiceNow msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(EndOfTurn msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyAccept msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyDeny msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyPlayerJoin msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyPlayerLeave msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(MoveMessage msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(NoTurn msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PauseGame msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PlayCard msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PossibleCard msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PossiblePiece msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RankingResponse msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RankingRollAgain msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ReconnectBriefing msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ResumeGame msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ServerStartGame msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(StartPiece msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(UpdateReady msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(UpdateTSK msg) {
 | 
			
		||||
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(WaitPiece msg) {
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectPiece(UUID pieceId){
 | 
			
		||||
        state.selectPiece(pieceId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectCard(UUID cardId){
 | 
			
		||||
        state.selectCard(cardId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectTsk(Color color){
 | 
			
		||||
        state.selectTSK(color);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectDice(){
 | 
			
		||||
        state.selectDice();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectName(String name){
 | 
			
		||||
        state.setName(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectReady(boolean ready){
 | 
			
		||||
        state.selectReady();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectHost(){
 | 
			
		||||
        state.selectHost();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectLeave(){
 | 
			
		||||
        state.selectLeave();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectJoin(){
 | 
			
		||||
        state.selectJoin();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectStart(){
 | 
			
		||||
        state.selectStart();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setState(ClientState state){
 | 
			
		||||
        this.state.exit();
 | 
			
		||||
        this.state = state;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public GameState getGameState(){
 | 
			
		||||
        return gameState;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Ceremony getCeremony(){
 | 
			
		||||
        return ceremony;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Interrupt getInterrupt(){
 | 
			
		||||
        return interrupt;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Dialogs getDialogs(){
 | 
			
		||||
        return dialogs;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,12 @@
 | 
			
		||||
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 ClientState parent;
 | 
			
		||||
@@ -12,13 +18,9 @@ protected ClientState(ClientState parent, ClientGameLogic logic){
 | 
			
		||||
        this.logic = logic;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void entry(){/* do nothing */}
 | 
			
		||||
    public abstract void enter();
 | 
			
		||||
 | 
			
		||||
    public void exit() {/* do nothing*/}
 | 
			
		||||
 | 
			
		||||
    public void gotoState(ClientState newState){
 | 
			
		||||
        throw new IllegalStateException("not in a statemachine");
 | 
			
		||||
    }
 | 
			
		||||
    public abstract void exit();
 | 
			
		||||
 | 
			
		||||
    public ClientState getParent(){
 | 
			
		||||
        return parent;
 | 
			
		||||
@@ -30,4 +32,187 @@ public void update() {/* do nothing */}
 | 
			
		||||
    public String toString(){
 | 
			
		||||
        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");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class DetermineStartPlayer extends ClientState {
 | 
			
		||||
    private final DetermineStartPlayerStateMachine determineStartPlayerStateMachine;
 | 
			
		||||
 | 
			
		||||
    public DetermineStartPlayer(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
        this.determineStartPlayerStateMachine = new DetermineStartPlayerStateMachine(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public DetermineStartPlayerStateMachine getDetermineStartPlayerStateMachine() {
 | 
			
		||||
        return determineStartPlayerStateMachine;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class DetermineStartPlayerStateMachine extends ClientStateMachine{
 | 
			
		||||
    public DetermineStartPlayerStateMachine(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public RollRankingDice initialState() {
 | 
			
		||||
        return new RollRankingDice(this, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,8 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public abstract class DialogStates extends ClientState{
 | 
			
		||||
 | 
			
		||||
    public DialogStates(ClientState parent, ClientGameLogic logic){
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,14 +1,53 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
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 {
 | 
			
		||||
    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) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
        this.dialogsStateMachine = new DialogsStateMachine(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public DialogsStateMachine getDialogsStateMachine() {
 | 
			
		||||
        return dialogsStateMachine;
 | 
			
		||||
    @Override
 | 
			
		||||
    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());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class DialogsStateMachine extends ClientStateMachine {
 | 
			
		||||
    public DialogsStateMachine(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public StartDialog initialState() {
 | 
			
		||||
        return new StartDialog(this, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,14 +1,29 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.gameState.*;
 | 
			
		||||
 | 
			
		||||
public class GameState extends ClientState {
 | 
			
		||||
    private final GameStateMachine gameStateMachine;
 | 
			
		||||
 | 
			
		||||
    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);
 | 
			
		||||
        this.gameStateMachine = new GameStateMachine(parent, logic);
 | 
			
		||||
        state = determineStartPlayer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public GameStateMachine getGameStateMachine() {
 | 
			
		||||
        return gameStateMachine;
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class GameStateMachine extends ClientStateMachine {
 | 
			
		||||
    public GameStateMachine(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ClientState initialState() {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -2,10 +2,17 @@
 | 
			
		||||
 | 
			
		||||
public class Interrupt extends ClientState {
 | 
			
		||||
 | 
			
		||||
    private final GameState lastState;
 | 
			
		||||
 | 
			
		||||
    public Interrupt(ClientState parent, ClientGameLogic logic, GameState lastState) {
 | 
			
		||||
    public Interrupt(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
        this.lastState = lastState;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Lobby extends ClientState {
 | 
			
		||||
    public Lobby(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class MainSettings extends ClientState {
 | 
			
		||||
    public MainSettings(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class MovePiece extends ClientState {
 | 
			
		||||
    public MovePiece(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class NetworkDialog extends ClientState {
 | 
			
		||||
    public NetworkDialog(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class NoPiece extends ClientState {
 | 
			
		||||
    public NoPiece(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class PlayPowerCard extends ClientState {
 | 
			
		||||
    public PlayPowerCard(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Podium extends ClientState {
 | 
			
		||||
    public Podium(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class PowerCard extends ClientState {
 | 
			
		||||
    private final PowerCardStateMachine powerCardStateMachine;
 | 
			
		||||
 | 
			
		||||
    public PowerCard(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
        this.powerCardStateMachine = new PowerCardStateMachine(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public PowerCardStateMachine getPowerCardStateMachine() {
 | 
			
		||||
        return powerCardStateMachine;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class PowerCardStateMachine extends ClientStateMachine {
 | 
			
		||||
    public PowerCardStateMachine(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ChoosePowerCard initialState() {
 | 
			
		||||
        return new ChoosePowerCard(this, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class RollDice extends ClientState {
 | 
			
		||||
    public RollDice(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class RollRankingDice extends ClientState {
 | 
			
		||||
    public RollRankingDice(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class SelectPiece extends ClientState {
 | 
			
		||||
    public SelectPiece(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,14 +1,18 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Settings extends ClientState {
 | 
			
		||||
    private final SettingsStateMachine settingsStateMachine;
 | 
			
		||||
 | 
			
		||||
    public Settings(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
        this.settingsStateMachine = new SettingsStateMachine(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public SettingsStateMachine getSettingsStateMachine() {
 | 
			
		||||
        return settingsStateMachine;
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class SettingsStateMachine extends ClientStateMachine {
 | 
			
		||||
    public SettingsStateMachine(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ClientState initialState() {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Shield extends ClientState {
 | 
			
		||||
    public Shield(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Spectator extends ClientState {
 | 
			
		||||
    public Spectator(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class StartDialog extends DialogStates {
 | 
			
		||||
    public StartDialog(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class StartPiece extends ClientState {
 | 
			
		||||
    public StartPiece(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Statistics extends ClientState {
 | 
			
		||||
    public Statistics(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Swap extends ClientState {
 | 
			
		||||
    public Swap(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Turn extends ClientState {
 | 
			
		||||
    private final TurnStateMachine turnStateMachine;
 | 
			
		||||
 | 
			
		||||
    public Turn(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
        this.turnStateMachine = new TurnStateMachine(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public TurnStateMachine getTurnStateMachine() {
 | 
			
		||||
        return turnStateMachine;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class TurnStateMachine extends ClientStateMachine {
 | 
			
		||||
    public TurnStateMachine(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public PowerCard initialState() {
 | 
			
		||||
        return new PowerCard(this, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class VideoSettings extends ClientState {
 | 
			
		||||
    public VideoSettings(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class WaitRanking extends ClientState {
 | 
			
		||||
    public WaitRanking(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Waiting extends ClientState {
 | 
			
		||||
    public Waiting(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class WaitingPiece extends ClientState {
 | 
			
		||||
    public WaitingPiece(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.ceremonyState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class Podium extends CeremonyStates {
 | 
			
		||||
    public Podium(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.ceremonyState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class Statistics extends CeremonyStates {
 | 
			
		||||
    public Statistics(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,11 @@
 | 
			
		||||
package pp.mdga.client.dialogState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public abstract class DialogStates extends ClientState {
 | 
			
		||||
 | 
			
		||||
    public DialogStates(ClientState parent, ClientGameLogic logic){
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,63 @@
 | 
			
		||||
package pp.mdga.client.dialogState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
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 {
 | 
			
		||||
 | 
			
		||||
    private final Dialogs parent;
 | 
			
		||||
 | 
			
		||||
    public Lobby(ClientState parent, ClientGameLogic 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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,62 @@
 | 
			
		||||
package pp.mdga.client.dialogState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.Dialogs;
 | 
			
		||||
 | 
			
		||||
public class NetworkDialog extends DialogStates {
 | 
			
		||||
 | 
			
		||||
    private final Dialogs parent;
 | 
			
		||||
 | 
			
		||||
    public NetworkDialog(ClientState parent, ClientGameLogic 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());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,37 @@
 | 
			
		||||
package pp.mdga.client.dialogState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.Dialogs;
 | 
			
		||||
 | 
			
		||||
public class StartDialog extends DialogStates {
 | 
			
		||||
 | 
			
		||||
    private final Dialogs parent;
 | 
			
		||||
 | 
			
		||||
    public StartDialog(ClientState parent, ClientGameLogic 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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.gameState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class Animation extends GameStates {
 | 
			
		||||
    public Animation(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,21 @@
 | 
			
		||||
package pp.mdga.client.gameState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class DetermineStartPlayer extends GameStates {
 | 
			
		||||
 | 
			
		||||
    public DetermineStartPlayer(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,10 @@
 | 
			
		||||
package pp.mdga.client.gameState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public abstract class GameStates extends ClientState {
 | 
			
		||||
    public GameStates(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.gameState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class Spectator extends GameStates {
 | 
			
		||||
    public Spectator(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,21 @@
 | 
			
		||||
package pp.mdga.client.gameState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class Turn extends GameStates {
 | 
			
		||||
 | 
			
		||||
    public Turn(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.gameState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class Waiting extends GameStates {
 | 
			
		||||
    public Waiting(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,12 @@
 | 
			
		||||
package pp.mdga.client.gameState.determineStartPlayerState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.GameStates;
 | 
			
		||||
 | 
			
		||||
public abstract class DetermineStartPlayerStates extends GameStates {
 | 
			
		||||
    public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.gameState.determineStartPlayerState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class RollRankingDice extends DetermineStartPlayerStates {
 | 
			
		||||
    public RollRankingDice(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,21 @@
 | 
			
		||||
package pp.mdga.client.gameState.determineStartPlayerState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.GameStates;
 | 
			
		||||
 | 
			
		||||
public class WaitRanking extends GameStates {
 | 
			
		||||
    public WaitRanking(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,21 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class ChoosePiece extends TurnStates {
 | 
			
		||||
 | 
			
		||||
    public ChoosePiece(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class MovePiece extends TurnStates {
 | 
			
		||||
    public MovePiece(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class PlayPowerCard extends TurnStates {
 | 
			
		||||
    public PlayPowerCard(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,21 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class PowerCard extends TurnStates {
 | 
			
		||||
 | 
			
		||||
    public PowerCard(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class RollDice extends TurnStates {
 | 
			
		||||
    public RollDice(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,11 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.GameStates;
 | 
			
		||||
 | 
			
		||||
public  abstract class TurnStates extends GameStates {
 | 
			
		||||
    public TurnStates(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,11 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.choosePieceState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.TurnStates;
 | 
			
		||||
 | 
			
		||||
public abstract class ChoosePieceStates extends TurnStates {
 | 
			
		||||
    public ChoosePieceStates(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.choosePieceState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class NoPiece extends ChoosePieceStates {
 | 
			
		||||
    public NoPiece(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.choosePieceState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class SelectPiece extends ChoosePieceStates {
 | 
			
		||||
    public SelectPiece(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.choosePieceState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class StartPiece extends ChoosePieceStates {
 | 
			
		||||
    public StartPiece(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.choosePieceState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class WaitingPiece extends ChoosePieceStates {
 | 
			
		||||
    public WaitingPiece(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.powerCardState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class ChoosePowerCard extends PowerCardStates {
 | 
			
		||||
    public ChoosePowerCard(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,11 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.powerCardState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.TurnStates;
 | 
			
		||||
 | 
			
		||||
public abstract class PowerCardStates extends TurnStates {
 | 
			
		||||
    public PowerCardStates(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.powerCardState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class Shield extends PowerCardStates {
 | 
			
		||||
    public Shield(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.powerCardState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class Swap extends PowerCardStates {
 | 
			
		||||
    public Swap(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.settingsState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class AudioSettings extends SettingStates {
 | 
			
		||||
    public AudioSettings(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.settingsState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class MainSettings extends ClientState {
 | 
			
		||||
    public MainSettings(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,10 @@
 | 
			
		||||
package pp.mdga.client.settingsState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public abstract class SettingStates extends ClientState {
 | 
			
		||||
    public SettingStates(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package pp.mdga.client.settingsState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
 | 
			
		||||
public class VideoSettings extends SettingStates {
 | 
			
		||||
    public VideoSettings(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,9 +1,12 @@
 | 
			
		||||
package pp.mdga.game;
 | 
			
		||||
 | 
			
		||||
public enum Color {
 | 
			
		||||
    ARMY,
 | 
			
		||||
    NAVY,
 | 
			
		||||
    AIRFORCE,
 | 
			
		||||
    CYBER,
 | 
			
		||||
    AIRFORCE
 | 
			
		||||
    NAVY,
 | 
			
		||||
    ARMY;
 | 
			
		||||
 | 
			
		||||
    public Color next() {
 | 
			
		||||
        return values()[(ordinal() + 1) % values().length];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,29 +8,27 @@
 | 
			
		||||
 * The game state is updated by the game logic.
 | 
			
		||||
 */
 | 
			
		||||
public class Game {
 | 
			
		||||
    /**
 | 
			
		||||
     * Constants.
 | 
			
		||||
     */
 | 
			
		||||
    public static final int AMOUNT_OF_TURBO_CARDS = 16;
 | 
			
		||||
    public static final int AMOUNT_OF_SHIELD_AND_SWAP_CARDS = 12;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Attributes.
 | 
			
		||||
     */
 | 
			
		||||
    private int diceModifier = 1;
 | 
			
		||||
    private int diceEyes;
 | 
			
		||||
    private Map<Color, Player> players = new EnumMap<>(Color.class);
 | 
			
		||||
    private Map<Integer, Player> players = new HashMap<>();
 | 
			
		||||
    private Statistic gameStatistics;
 | 
			
		||||
    private List<BonusCard> drawPile;
 | 
			
		||||
    private List<BonusCard> discardPile = new ArrayList<>();
 | 
			
		||||
    private Board board;
 | 
			
		||||
    private Color activeColor;
 | 
			
		||||
    private List<Color> order;
 | 
			
		||||
    private final ArrayList<Player> playerList = new ArrayList<>(4);
 | 
			
		||||
 | 
			
		||||
    private final ArrayList<Observer> observers = new ArrayList<>();
 | 
			
		||||
    private Player startPlayer;
 | 
			
		||||
    private Boolean gameHasStarted = false;
 | 
			
		||||
    private Boolean playerHasDisconnected = false;
 | 
			
		||||
    private Boolean gameIsInterrupted = false;
 | 
			
		||||
    private Boolean allRanked = false;
 | 
			
		||||
    private Boolean movablePieces = false;
 | 
			
		||||
 | 
			
		||||
    private Boolean allReady = false;
 | 
			
		||||
 | 
			
		||||
    private static final int AMOUNT_OF_TURBO_CARDS = 16;
 | 
			
		||||
    private static final int AMOUNT_OF_SHIELD_AND_SWAP_CARDS = 12;
 | 
			
		||||
    private boolean allRanked = false;
 | 
			
		||||
    private boolean movablePieces = false;
 | 
			
		||||
    private boolean allReady = false;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This constructor creates a new Game object.
 | 
			
		||||
@@ -48,185 +46,23 @@ public Game() {
 | 
			
		||||
        board = new Board();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the dice modifier.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the dice modifier
 | 
			
		||||
     */
 | 
			
		||||
    public int getDiceModifier() {
 | 
			
		||||
        return diceModifier;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the dice modifier.
 | 
			
		||||
     *
 | 
			
		||||
     * @param diceModifier the new dice modifier
 | 
			
		||||
     */
 | 
			
		||||
    public void setDiceModifier(int diceModifier) {
 | 
			
		||||
        this.diceModifier = diceModifier;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the dice eyes.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the dice eyes
 | 
			
		||||
     */
 | 
			
		||||
    public int getDiceEyes() {
 | 
			
		||||
        return diceEyes;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the dice eyes.
 | 
			
		||||
     *
 | 
			
		||||
     * @param diceEyes the new dice eyes
 | 
			
		||||
     */
 | 
			
		||||
    public void setDiceEyes(int diceEyes) {
 | 
			
		||||
        this.diceEyes = diceEyes;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the players.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the players
 | 
			
		||||
     */
 | 
			
		||||
    public Map<Color, Player> getPlayers() {
 | 
			
		||||
        return players;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the players.
 | 
			
		||||
     *
 | 
			
		||||
     * @param players the new players
 | 
			
		||||
     */
 | 
			
		||||
    public void setPlayers(Map<Color, Player> players) {
 | 
			
		||||
        this.players = players;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the game statistics.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the game statistics
 | 
			
		||||
     */
 | 
			
		||||
    public Statistic getGameStatistics() {
 | 
			
		||||
        return gameStatistics;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the game statistics.
 | 
			
		||||
     *
 | 
			
		||||
     * @param gameStatistics the new game statistics
 | 
			
		||||
     */
 | 
			
		||||
    public void setGameStatistics(Statistic gameStatistics) {
 | 
			
		||||
        this.gameStatistics = gameStatistics;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the draw pile.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the draw pile
 | 
			
		||||
     */
 | 
			
		||||
    public List<BonusCard> getDrawPile() {
 | 
			
		||||
        return drawPile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the draw pile.
 | 
			
		||||
     *
 | 
			
		||||
     * @param drawPile the new draw pile
 | 
			
		||||
     */
 | 
			
		||||
    public void setDrawPile(List<BonusCard> drawPile) {
 | 
			
		||||
        this.drawPile = drawPile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the discard pile.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the discard pile
 | 
			
		||||
     */
 | 
			
		||||
    public List<BonusCard> getDiscardPile() {
 | 
			
		||||
        return discardPile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the discard pile.
 | 
			
		||||
     *
 | 
			
		||||
     * @param discardPile the new discard pile
 | 
			
		||||
     */
 | 
			
		||||
    public void setDiscardPile(List<BonusCard> discardPile) {
 | 
			
		||||
        this.discardPile = discardPile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the board.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the board
 | 
			
		||||
     */
 | 
			
		||||
    public Board getBoard() {
 | 
			
		||||
        return board;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the board.
 | 
			
		||||
     *
 | 
			
		||||
     * @param board the new board
 | 
			
		||||
     */
 | 
			
		||||
    public void setBoard(Board board) {
 | 
			
		||||
        this.board = board;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the active color.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the active color
 | 
			
		||||
     */
 | 
			
		||||
    public Color getActiveColor() {
 | 
			
		||||
        return activeColor;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the active color.
 | 
			
		||||
     *
 | 
			
		||||
     * @param activeColor the new active color
 | 
			
		||||
     */
 | 
			
		||||
    public void setActiveColor(Color activeColor) {
 | 
			
		||||
        this.activeColor = activeColor;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the order of the players.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the order of the players
 | 
			
		||||
     */
 | 
			
		||||
    public List<Color> getOrder() {
 | 
			
		||||
        return order;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the order of the players.
 | 
			
		||||
     *
 | 
			
		||||
     * @param order the new order of the players
 | 
			
		||||
     */
 | 
			
		||||
    public void setOrder(List<Color> order) {
 | 
			
		||||
        this.order = order;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method adds a player to the game.
 | 
			
		||||
     *
 | 
			
		||||
     * @param color  the color of the player
 | 
			
		||||
     * @param id     the id of the player
 | 
			
		||||
     * @param player the player to be added
 | 
			
		||||
     */
 | 
			
		||||
    public void addPlayer(Color color, Player player) {
 | 
			
		||||
        players.put(color, player);
 | 
			
		||||
    public void addPlayer(int id, Player player) {
 | 
			
		||||
        players.put(id, player);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method removes a player from the game.
 | 
			
		||||
     *
 | 
			
		||||
     * @param color the color of the player
 | 
			
		||||
     * @param id the color of the player
 | 
			
		||||
     */
 | 
			
		||||
    public void removePlayer(Color color) {
 | 
			
		||||
        players.remove(color);
 | 
			
		||||
    public void removePlayer(int id) {
 | 
			
		||||
        players.remove(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -248,49 +84,135 @@ public void removeObserver(Observer observer) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the game has started.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the game has started
 | 
			
		||||
     * @param id
 | 
			
		||||
     * @param active
 | 
			
		||||
     */
 | 
			
		||||
    public Boolean getGameHasStarted() {
 | 
			
		||||
        return gameHasStarted;
 | 
			
		||||
    public void updatePlayerActiveState(int id, boolean active) {
 | 
			
		||||
        this.players.get(id).setActive(active);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the game has started.
 | 
			
		||||
     * This method will be used to return the player which has the given id parameter.
 | 
			
		||||
     *
 | 
			
		||||
     * @param gameHasStarted the new game has started
 | 
			
		||||
     * @param id as the unique id of a player as an Integer.
 | 
			
		||||
     * @return the player with the given id as a Player object.
 | 
			
		||||
     */
 | 
			
		||||
    public void setGameHasStarted(Boolean gameHasStarted) {
 | 
			
		||||
        this.gameHasStarted = gameHasStarted;
 | 
			
		||||
    public Player getPlayerById(int id) {
 | 
			
		||||
        return this.players.get(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the player has disconnected.
 | 
			
		||||
     * This method will be used to the get the player depending on the given color parameter.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the player has disconnected
 | 
			
		||||
     * @param color as the color of the player as a Color enumeration.
 | 
			
		||||
     * @return the player with the given color as a Player object.
 | 
			
		||||
     */
 | 
			
		||||
    public Boolean playerHasDisconnected() {
 | 
			
		||||
        return playerHasDisconnected;
 | 
			
		||||
    public Player getPlayerByColor(Color color) {
 | 
			
		||||
        for (Map.Entry<Integer, Player> entry : this.players.entrySet()) {
 | 
			
		||||
            if (entry.getValue().getColor() == color) {
 | 
			
		||||
                return entry.getValue();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the game interruption state.
 | 
			
		||||
     * This method will be used to return the number of active players of this game.
 | 
			
		||||
     *
 | 
			
		||||
     * @param gameIsInterrupted the new game interruption state
 | 
			
		||||
     * @return activePlayers as an Integer.
 | 
			
		||||
     */
 | 
			
		||||
    public void setGameIsInterrupted(Boolean gameIsInterrupted) {
 | 
			
		||||
        this.gameIsInterrupted = gameIsInterrupted;
 | 
			
		||||
        if (Boolean.FALSE.equals(gameIsInterrupted)) notifyObservers();
 | 
			
		||||
    public int getNumberOfActivePlayers() {
 | 
			
		||||
        int activePlayers = 0;
 | 
			
		||||
        for (Map.Entry<Integer, Player> entry : this.players.entrySet()) {
 | 
			
		||||
            if (entry.getValue().isActive()) {
 | 
			
		||||
                activePlayers++;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return activePlayers;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns whether the game is interrupted.
 | 
			
		||||
     *
 | 
			
		||||
     * @return true if the game is interrupted, false otherwise
 | 
			
		||||
     * This method notifies the observers.
 | 
			
		||||
     */
 | 
			
		||||
    public Boolean gameIsInterrupted() {
 | 
			
		||||
        return gameIsInterrupted;
 | 
			
		||||
    public void notifyObservers() {
 | 
			
		||||
        for (Observer observer : new ArrayList<>(observers)) {
 | 
			
		||||
            observer.update();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the dice modifier.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the dice modifier
 | 
			
		||||
     */
 | 
			
		||||
    public int getDiceModifier() {
 | 
			
		||||
        return diceModifier;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the dice eyes.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the dice eyes
 | 
			
		||||
     */
 | 
			
		||||
    public int getDiceEyes() {
 | 
			
		||||
        return diceEyes;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the players.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the players
 | 
			
		||||
     */
 | 
			
		||||
    public Map<Integer, Player> getPlayers() {
 | 
			
		||||
        return players;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the game statistics.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the game statistics
 | 
			
		||||
     */
 | 
			
		||||
    public Statistic getGameStatistics() {
 | 
			
		||||
        return gameStatistics;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the draw pile.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the draw pile
 | 
			
		||||
     */
 | 
			
		||||
    public List<BonusCard> getDrawPile() {
 | 
			
		||||
        return drawPile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the discard pile.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the discard pile
 | 
			
		||||
     */
 | 
			
		||||
    public List<BonusCard> getDiscardPile() {
 | 
			
		||||
        return discardPile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the board.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the board
 | 
			
		||||
     */
 | 
			
		||||
    public Board getBoard() {
 | 
			
		||||
        return board;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the active color.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the active color
 | 
			
		||||
     */
 | 
			
		||||
    public Color getActiveColor() {
 | 
			
		||||
        return activeColor;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -302,6 +224,78 @@ public Boolean getMovablePieces() {
 | 
			
		||||
        return movablePieces;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the dice modifier.
 | 
			
		||||
     *
 | 
			
		||||
     * @param diceModifier the new dice modifier
 | 
			
		||||
     */
 | 
			
		||||
    public void setDiceModifier(int diceModifier) {
 | 
			
		||||
        this.diceModifier = diceModifier;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the dice eyes.
 | 
			
		||||
     *
 | 
			
		||||
     * @param diceEyes the new dice eyes
 | 
			
		||||
     */
 | 
			
		||||
    public void setDiceEyes(int diceEyes) {
 | 
			
		||||
        this.diceEyes = diceEyes;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the players.
 | 
			
		||||
     *
 | 
			
		||||
     * @param players the new players
 | 
			
		||||
     */
 | 
			
		||||
    public void setPlayers(Map<Integer, Player> players) {
 | 
			
		||||
        this.players = players;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the game statistics.
 | 
			
		||||
     *
 | 
			
		||||
     * @param gameStatistics the new game statistics
 | 
			
		||||
     */
 | 
			
		||||
    public void setGameStatistics(Statistic gameStatistics) {
 | 
			
		||||
        this.gameStatistics = gameStatistics;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the draw pile.
 | 
			
		||||
     *
 | 
			
		||||
     * @param drawPile the new draw pile
 | 
			
		||||
     */
 | 
			
		||||
    public void setDrawPile(List<BonusCard> drawPile) {
 | 
			
		||||
        this.drawPile = drawPile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the discard pile.
 | 
			
		||||
     *
 | 
			
		||||
     * @param discardPile the new discard pile
 | 
			
		||||
     */
 | 
			
		||||
    public void setDiscardPile(List<BonusCard> discardPile) {
 | 
			
		||||
        this.discardPile = discardPile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the board.
 | 
			
		||||
     *
 | 
			
		||||
     * @param board the new board
 | 
			
		||||
     */
 | 
			
		||||
    public void setBoard(Board board) {
 | 
			
		||||
        this.board = board;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the active color.
 | 
			
		||||
     *
 | 
			
		||||
     * @param activeColor the new active color
 | 
			
		||||
     */
 | 
			
		||||
    public void setActiveColor(Color activeColor) {
 | 
			
		||||
        this.activeColor = activeColor;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the game interruption state.
 | 
			
		||||
     *
 | 
			
		||||
@@ -312,16 +306,6 @@ public void setMovablePieces(Boolean movablePieces) {
 | 
			
		||||
        if (Boolean.FALSE.equals(movablePieces)) notifyObservers();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the player has disconnected.
 | 
			
		||||
     *
 | 
			
		||||
     * @param playerHasDisconnected the new player has disconnected
 | 
			
		||||
     */
 | 
			
		||||
    public void setPlayerHasDisconnected(Boolean playerHasDisconnected) {
 | 
			
		||||
        this.playerHasDisconnected = playerHasDisconnected;
 | 
			
		||||
        if (Boolean.TRUE.equals(playerHasDisconnected)) notifyObservers();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns whether all players have ranked.
 | 
			
		||||
     *
 | 
			
		||||
@@ -341,24 +325,6 @@ public void setAllRanked(Boolean allRanked) {
 | 
			
		||||
        if (Boolean.TRUE.equals(allRanked)) notifyObservers();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the start player.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the start player
 | 
			
		||||
     */
 | 
			
		||||
    public Player getStartPlayer() {
 | 
			
		||||
        return startPlayer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the start player.
 | 
			
		||||
     *
 | 
			
		||||
     * @param startPlayer the new start player
 | 
			
		||||
     */
 | 
			
		||||
    public void setStartPlayer(Player startPlayer) {
 | 
			
		||||
        this.startPlayer = startPlayer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the all ready state.
 | 
			
		||||
     *
 | 
			
		||||
@@ -371,53 +337,10 @@ public Boolean allReady() {
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the all ready state.
 | 
			
		||||
     *
 | 
			
		||||
     * @param allReady the new all ready state
 | 
			
		||||
     * @param allReady the new all-ready state
 | 
			
		||||
     */
 | 
			
		||||
    public void setAllReady(Boolean allReady) {
 | 
			
		||||
        this.allReady = allReady;
 | 
			
		||||
        if (Boolean.TRUE.equals(allReady)) notifyObservers();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method notifies the observers.
 | 
			
		||||
     */
 | 
			
		||||
    public void notifyObservers() {
 | 
			
		||||
        for (Observer observer : new ArrayList<>(observers)) {
 | 
			
		||||
            observer.update();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the piece through its identifier.
 | 
			
		||||
     *
 | 
			
		||||
     * @param identifier the identifier of the piece
 | 
			
		||||
     * @return the piece
 | 
			
		||||
     */
 | 
			
		||||
    public Piece getPieceThroughIdentifier(String identifier) {
 | 
			
		||||
        String[] parts = identifier.split("-");
 | 
			
		||||
        Color color = Color.valueOf(parts[0]);
 | 
			
		||||
        int index = Integer.parseInt(parts[1]);
 | 
			
		||||
        return board.getPlayerData().get(color).getPieces()[index];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ArrayList<Player> getPlayerList() {
 | 
			
		||||
        return playerList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void addPlayerToList(Player player) {
 | 
			
		||||
        playerList.add(player);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void removePlayerFromList(Player player) {
 | 
			
		||||
        playerList.remove(player);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Player getPlayerFromList(String name) {
 | 
			
		||||
        for (Player player : playerList) {
 | 
			
		||||
            if (player.getName().equals(name)) {
 | 
			
		||||
                return player;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,22 +6,12 @@
 | 
			
		||||
 * This class will be used to handle general PlayerData
 | 
			
		||||
 */
 | 
			
		||||
public class Player {
 | 
			
		||||
 | 
			
		||||
    private String name;
 | 
			
		||||
    private Statistic playerStatistic;
 | 
			
		||||
    private ArrayList<BonusCard> handCards;
 | 
			
		||||
    private final int id;
 | 
			
		||||
    private Color color;
 | 
			
		||||
    private boolean isReady;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This constructor constructs a new Player object
 | 
			
		||||
     */
 | 
			
		||||
    public Player(int id) {
 | 
			
		||||
        this.id = id;
 | 
			
		||||
        playerStatistic = new Statistic();
 | 
			
		||||
        handCards = new ArrayList<>();
 | 
			
		||||
    }
 | 
			
		||||
    private boolean active = true;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This constructor constructs a new Player object
 | 
			
		||||
@@ -32,7 +22,13 @@ public Player(String name) {
 | 
			
		||||
        this.name = name;
 | 
			
		||||
        playerStatistic = new Statistic();
 | 
			
		||||
        handCards = new ArrayList<>();
 | 
			
		||||
        id = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor.
 | 
			
		||||
     */
 | 
			
		||||
    public Player() {
 | 
			
		||||
        this("");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -76,7 +72,7 @@ public ArrayList<BonusCard> getHandCards() {
 | 
			
		||||
     *
 | 
			
		||||
     * @param card the card to be added to the players hand
 | 
			
		||||
     */
 | 
			
		||||
    public void addHandCards(BonusCard card){
 | 
			
		||||
    public void addHandCards(BonusCard card) {
 | 
			
		||||
        handCards.add(card);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -94,15 +90,6 @@ public BonusCard removeHandCard(BonusCard card) {
 | 
			
		||||
        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
 | 
			
		||||
     *
 | 
			
		||||
@@ -130,6 +117,15 @@ public boolean 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
 | 
			
		||||
     *
 | 
			
		||||
@@ -138,4 +134,13 @@ public boolean isReady() {
 | 
			
		||||
    public void setReady(boolean 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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -20,14 +20,13 @@ public interface ClientInterpreter {
 | 
			
		||||
     */
 | 
			
		||||
    void received(DeselectTSK msg, int from);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Processes a received ForceStartGame message.
 | 
			
		||||
     *
 | 
			
		||||
     * @param msg  the ForceStartGame message to be processed
 | 
			
		||||
     * @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.
 | 
			
		||||
@@ -61,6 +60,14 @@ public interface ClientInterpreter {
 | 
			
		||||
     */
 | 
			
		||||
    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.
 | 
			
		||||
     *
 | 
			
		||||
@@ -70,12 +77,12 @@ public interface ClientInterpreter {
 | 
			
		||||
    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
 | 
			
		||||
     */
 | 
			
		||||
    void received(RequestDice msg, int from);
 | 
			
		||||
    void received(RequestDie msg, int from);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Processes a received RequestMove message.
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -7,11 +7,23 @@
 | 
			
		||||
 */
 | 
			
		||||
@Serializable
 | 
			
		||||
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.
 | 
			
		||||
     */
 | 
			
		||||
    public JoinServer() {
 | 
			
		||||
        super();
 | 
			
		||||
        name = null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -6,11 +6,11 @@
 | 
			
		||||
 * A message sent by a client to request a die roll.
 | 
			
		||||
 */
 | 
			
		||||
@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();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -21,7 +21,7 @@ public RequestDice() {
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "RequestDice{}";
 | 
			
		||||
        return "RequestDie{}";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -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.
 | 
			
		||||
 */
 | 
			
		||||
@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.
 | 
			
		||||
     */
 | 
			
		||||
    public ForceStartGame() {
 | 
			
		||||
    public StartGame() {
 | 
			
		||||
        super();
 | 
			
		||||
        forceStartGame = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -8,7 +8,7 @@
 | 
			
		||||
 * A message sent by the server to the client to inform about the dice roll.
 | 
			
		||||
 */
 | 
			
		||||
@Serializable
 | 
			
		||||
public class Dice extends ServerMessage {
 | 
			
		||||
public class Die extends ServerMessage {
 | 
			
		||||
    /**
 | 
			
		||||
     * The eye of the dice
 | 
			
		||||
     */
 | 
			
		||||
@@ -25,7 +25,7 @@ public class Dice extends ServerMessage {
 | 
			
		||||
     * @param diceEye        the eye of the dice
 | 
			
		||||
     * @param moveablePieces the pieces that can be moved
 | 
			
		||||
     */
 | 
			
		||||
    public Dice(int diceEye, List<String> moveablePieces) {
 | 
			
		||||
    public Die(int diceEye, List<String> moveablePieces) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.diceEye = diceEye;
 | 
			
		||||
        this.moveablePieces = moveablePieces;
 | 
			
		||||
@@ -34,7 +34,7 @@ public Dice(int diceEye, List<String> moveablePieces) {
 | 
			
		||||
    /**
 | 
			
		||||
     * Default constructor for serialization purposes.
 | 
			
		||||
     */
 | 
			
		||||
    private Dice() {
 | 
			
		||||
    private Die() {
 | 
			
		||||
        diceEye = 0;
 | 
			
		||||
        moveablePieces = null;
 | 
			
		||||
    }
 | 
			
		||||
@@ -45,8 +45,8 @@ private Dice() {
 | 
			
		||||
     * @param diceEye the eye of the dice
 | 
			
		||||
     * @return a new Dice object
 | 
			
		||||
     */
 | 
			
		||||
    public static Dice inactivePlayer(int diceEye) {
 | 
			
		||||
        return new Dice(diceEye, null);
 | 
			
		||||
    public static Die inactivePlayer(int diceEye) {
 | 
			
		||||
        return new Die(diceEye, null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -56,8 +56,8 @@ public static Dice inactivePlayer(int diceEye) {
 | 
			
		||||
     * @param moveablePieces the pieces that can be moved
 | 
			
		||||
     * @return a new Dice object
 | 
			
		||||
     */
 | 
			
		||||
    public static Dice activePlayer(int diceEye, List<String> moveablePieces) {
 | 
			
		||||
        return new Dice(diceEye, moveablePieces);
 | 
			
		||||
    public static Die activePlayer(int diceEye, List<String> moveablePieces) {
 | 
			
		||||
        return new Die(diceEye, moveablePieces);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -13,14 +13,20 @@ public class LobbyPlayerJoin extends ServerMessage {
 | 
			
		||||
     */
 | 
			
		||||
    private final String name;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The ID of the new Player
 | 
			
		||||
     */
 | 
			
		||||
    private final int id;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a new LobbyPlayerJoin instance with the specified player name.
 | 
			
		||||
     *
 | 
			
		||||
     * @param name the name of the player joining the lobby
 | 
			
		||||
     */
 | 
			
		||||
    public LobbyPlayerJoin(String name) {
 | 
			
		||||
    public LobbyPlayerJoin(int id, String name) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.name = name;
 | 
			
		||||
        this.id = id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -28,6 +34,7 @@ public LobbyPlayerJoin(String name) {
 | 
			
		||||
     */
 | 
			
		||||
    private LobbyPlayerJoin() {
 | 
			
		||||
        name = null;
 | 
			
		||||
        id = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -39,6 +46,15 @@ public String getName() {
 | 
			
		||||
        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.
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ public class LobbyPlayerLeave extends ServerMessage {
 | 
			
		||||
    /**
 | 
			
		||||
     * 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.
 | 
			
		||||
@@ -21,12 +21,12 @@ public class LobbyPlayerLeave extends ServerMessage {
 | 
			
		||||
    /**
 | 
			
		||||
     * 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
 | 
			
		||||
     */
 | 
			
		||||
    public LobbyPlayerLeave(String name, Color color) {
 | 
			
		||||
    public LobbyPlayerLeave(int id, Color color) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.name = name;
 | 
			
		||||
        this.id = id;
 | 
			
		||||
        this.color = color;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -34,7 +34,7 @@ public LobbyPlayerLeave(String name, Color color) {
 | 
			
		||||
     * Default constructor for serialization purposes.
 | 
			
		||||
     */
 | 
			
		||||
    private LobbyPlayerLeave() {
 | 
			
		||||
        name = null;
 | 
			
		||||
        id = 0;
 | 
			
		||||
        color = null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -43,8 +43,8 @@ private LobbyPlayerLeave() {
 | 
			
		||||
     *
 | 
			
		||||
     * @return the name of the player leaving the lobby
 | 
			
		||||
     */
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return name;
 | 
			
		||||
    public int getId() {
 | 
			
		||||
        return id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -34,11 +34,11 @@ public interface ServerInterpreter {
 | 
			
		||||
    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
 | 
			
		||||
     */
 | 
			
		||||
    void received(Dice msg);
 | 
			
		||||
    void received(Die msg);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Handles a DiceAgain message received from the server.
 | 
			
		||||
@@ -193,4 +193,11 @@ public interface ServerInterpreter {
 | 
			
		||||
     * @param msg the WaitPiece message received
 | 
			
		||||
     */
 | 
			
		||||
    void received(WaitPiece msg);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Handles a Spectator message received from the server.
 | 
			
		||||
     *
 | 
			
		||||
     * @param msg the Spectator message received.
 | 
			
		||||
     */
 | 
			
		||||
    void received(Spectator msg);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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 "";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -11,7 +11,7 @@ public class UpdateTSK extends ServerMessage {
 | 
			
		||||
    /**
 | 
			
		||||
     * The name associated with the update.
 | 
			
		||||
     */
 | 
			
		||||
    private final String name;
 | 
			
		||||
    private final int id;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 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.
 | 
			
		||||
     *
 | 
			
		||||
     * @param name  the name associated with the update
 | 
			
		||||
     * @param id  the name 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();
 | 
			
		||||
        this.name = name;
 | 
			
		||||
        this.id = id;
 | 
			
		||||
        this.color = color;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -34,7 +34,7 @@ public UpdateTSK(String name, Color color) {
 | 
			
		||||
     * Default constructor for serialization purposes.
 | 
			
		||||
     */
 | 
			
		||||
    private UpdateTSK() {
 | 
			
		||||
        this("", null);
 | 
			
		||||
        this(0, null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -42,8 +42,8 @@ private UpdateTSK() {
 | 
			
		||||
     *
 | 
			
		||||
     * @return the name
 | 
			
		||||
     */
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return name;
 | 
			
		||||
    public int getId() {
 | 
			
		||||
        return id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.server;
 | 
			
		||||
 | 
			
		||||
public class Ceremony extends ServerState {
 | 
			
		||||
    public Ceremony(ServerGameLogic logic) {
 | 
			
		||||
        super(logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.server;
 | 
			
		||||
 | 
			
		||||
public class ChoosePiece extends Turn {
 | 
			
		||||
    public ChoosePiece(ServerGameLogic logic) {
 | 
			
		||||
        super(logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,7 @@
 | 
			
		||||
package pp.mdga.server;
 | 
			
		||||
 | 
			
		||||
public class ChoosePieceState extends TurnState {
 | 
			
		||||
    public ChoosePieceState(ServerGameLogic logic) {
 | 
			
		||||
        super(logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package pp.mdga.server;
 | 
			
		||||
 | 
			
		||||
public class DetermineStartPlayer extends Game {
 | 
			
		||||
    public DetermineStartPlayer(ServerGameLogic logic) {
 | 
			
		||||
        super(logic);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user