added the client logic to receive the LobbyAccept and LobbyDeny message
This commit is contained in:
		@@ -112,11 +112,8 @@ private void tryHost() {
 | 
			
		||||
                } catch (InterruptedException ignored) {
 | 
			
		||||
                }
 | 
			
		||||
                hostDialog.connectServerAsClient();
 | 
			
		||||
                try {
 | 
			
		||||
                    Thread.sleep(1000);
 | 
			
		||||
                } catch (InterruptedException ignored) {
 | 
			
		||||
                }
 | 
			
		||||
                app.getModelSynchronize().setHost(port);
 | 
			
		||||
                app.getGameLogic().selectHost("");
 | 
			
		||||
                //app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
@@ -144,11 +141,7 @@ private void tryJoin() {
 | 
			
		||||
                app.getModelSynchronize().setName(startDialog.getName());
 | 
			
		||||
                joinDialog.setHostname(ip);
 | 
			
		||||
                joinDialog.connectToServer();
 | 
			
		||||
                try {
 | 
			
		||||
                    Thread.sleep(1000);
 | 
			
		||||
                } catch (InterruptedException ignored) {
 | 
			
		||||
                }
 | 
			
		||||
                app.getModelSynchronize().setJoin(ip, port);
 | 
			
		||||
                app.getGameLogic().selectJoin("");
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
        } catch (IllegalArgumentException e) {
 | 
			
		||||
 
 | 
			
		||||
@@ -37,155 +37,155 @@ public String toString(){
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ActivePlayerMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(AnyPieceMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(BriefingMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(CeremonyMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DieMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DiceAgainMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DiceNowMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(EndOfTurnMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyAcceptMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyDenyMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyPlayerJoinedMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyPlayerLeaveMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(MoveMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(NoTurnMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PauseGameMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PlayCardMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PossibleCardMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PossiblePieceMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RankingResponseMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RankingRollAgainMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ReconnectBriefingMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ResumeGameMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ServerStartGameMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ShutdownMessage msg) {LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);}
 | 
			
		||||
    public void received(ShutdownMessage msg) {LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());}
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(StartPieceMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(UpdateReadyMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(UpdateTSKMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(SpectatorMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(SelectPieceMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(WaitPieceMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(IncorrectRequestMessage msg) {
 | 
			
		||||
       LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
 | 
			
		||||
       LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectPiece(Piece piece) {
 | 
			
		||||
 
 | 
			
		||||
@@ -254,6 +254,26 @@ public void received(ServerStartGameMessage msg){
 | 
			
		||||
        currentState.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to call the received method of the current state
 | 
			
		||||
     *
 | 
			
		||||
     * @param msg the LobbyAccept message received
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyAcceptMessage msg){
 | 
			
		||||
        currentState.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to call the received method of the current state
 | 
			
		||||
     *
 | 
			
		||||
     * @param msg the LobbyDeny message received
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyDenyMessage msg){
 | 
			
		||||
        currentState.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to get the current state
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -1,34 +1,70 @@
 | 
			
		||||
package pp.mdga.client.dialogState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.Resources;
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.DialogsState;
 | 
			
		||||
import pp.mdga.message.server.LobbyAcceptMessage;
 | 
			
		||||
import pp.mdga.message.server.LobbyDenyMessage;
 | 
			
		||||
import pp.mdga.notification.InfoNotification;
 | 
			
		||||
import pp.mdga.notification.LobbyDialogNotification;
 | 
			
		||||
 | 
			
		||||
public class NetworkDialogState extends DialogStates {
 | 
			
		||||
 | 
			
		||||
    private final DialogsState parent;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor for the NetworkDialogState
 | 
			
		||||
     * @param parent the parent state
 | 
			
		||||
     * @param logic the logic
 | 
			
		||||
     */
 | 
			
		||||
    public NetworkDialogState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
        this.parent = (DialogsState) parent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Enter the state
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        LOGGER.log(System.Logger.Level.INFO, "Entered {0}", this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Exit the state
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Select the leave option
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectLeave() {
 | 
			
		||||
        parent.setState(parent.getStartDialog());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectJoin(String IP) {
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is called when the server accepts the client into the lobby
 | 
			
		||||
     *
 | 
			
		||||
     * @param msg the LobbyAcceptMessage
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyAcceptMessage msg) {
 | 
			
		||||
        parent.setState(parent.getLobby());
 | 
			
		||||
        logic.addNotification(new LobbyDialogNotification());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is called when the server denies the client into the lobby
 | 
			
		||||
     *
 | 
			
		||||
     * @param msg the LobbyDenyMessage
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyDenyMessage msg) {
 | 
			
		||||
        logic.addNotification(new InfoNotification(Resources.stringLookup("lobby.deny.join")));
 | 
			
		||||
        parent.setState(parent.getStartDialog());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,21 +8,35 @@ public class StartDialogState extends DialogStates {
 | 
			
		||||
 | 
			
		||||
    private final DialogsState parent;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor for the StartDialogState
 | 
			
		||||
     * @param parent the parent state
 | 
			
		||||
     * @param logic the logic
 | 
			
		||||
     */
 | 
			
		||||
    public StartDialogState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
        this.parent = (DialogsState) parent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Enter the state
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Exit the state
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Select the join option
 | 
			
		||||
     *
 | 
			
		||||
     * @param name the name
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectJoin(String name) {
 | 
			
		||||
        parent.setOwnPlayerName(name);
 | 
			
		||||
@@ -30,6 +44,11 @@ public void selectJoin(String name) {
 | 
			
		||||
        logic.setHost(false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Select the host option
 | 
			
		||||
     *
 | 
			
		||||
     * @param name the name
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectHost(String name) {
 | 
			
		||||
        parent.setOwnPlayerName(name);
 | 
			
		||||
@@ -37,12 +56,20 @@ public void selectHost(String name) {
 | 
			
		||||
        logic.setHost(true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the name
 | 
			
		||||
     *
 | 
			
		||||
     * @param name the name
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setName(String name) {
 | 
			
		||||
        parent.setState(parent.getNetworkDialog());
 | 
			
		||||
        parent.setOwnPlayerName(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Select the leave option
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectLeave() {
 | 
			
		||||
        parent.exit();
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@ public void accept(ServerInterpreter interpreter) {
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "";
 | 
			
		||||
        return "Lobby Accept";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@ public void accept(ServerInterpreter interpreter) {
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "";
 | 
			
		||||
        return "LobbyDeny";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +1,8 @@
 | 
			
		||||
incorrect.request.0=
 | 
			
		||||
incorrect.request.1=
 | 
			
		||||
incorrect.request.2=
 | 
			
		||||
incorrect.request.3=
 | 
			
		||||
incorrect.request.4=
 | 
			
		||||
incorrect.request.5=
 | 
			
		||||
incorrect.request.6=
 | 
			
		||||
incorrect.request.7=
 | 
			
		||||
incorrect.request.8=
 | 
			
		||||
incorrect.request.9=
 | 
			
		||||
incorrect.request.10=
 | 
			
		||||
incorrect.request.11=
 | 
			
		||||
incorrect.request.12=
 | 
			
		||||
incorrect.request.13=
 | 
			
		||||
incorrect.request.14=
 | 
			
		||||
lobby.deny.join=The lobby is already full.
 | 
			
		||||
 | 
			
		||||
incorrect.request.0=The selected TSK is already occupied.
 | 
			
		||||
incorrect.request.1=No TSK is available for selection.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,4 @@
 | 
			
		||||
lobby.deny.join=Die Lobby ist bereits voll.
 | 
			
		||||
 | 
			
		||||
incorrect.request.1=Die ausgewählte TSK ist bereits belegt.
 | 
			
		||||
incorrect.request.2=Es gibt keine freie TSK mehr, welche ausgewählt werden kann.
 | 
			
		||||
incorrect.request.3=
 | 
			
		||||
incorrect.request.4=
 | 
			
		||||
incorrect.request.5=
 | 
			
		||||
incorrect.request.6=
 | 
			
		||||
incorrect.request.7=
 | 
			
		||||
incorrect.request.8=
 | 
			
		||||
incorrect.request.9=
 | 
			
		||||
incorrect.request.10=
 | 
			
		||||
incorrect.request.11=
 | 
			
		||||
incorrect.request.12=
 | 
			
		||||
incorrect.request.13=
 | 
			
		||||
incorrect.request.14=
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user