Package server.common

Examples of server.common.Message


        }
        return null;
    }

    public Message SavePlay(int type, String pl_id, String ga_id, String ga_infos) throws GameException {
        Message response = savePlay(type, pl_id, ga_id, ga_infos);
        switch (response.getHeader()) {
            case Message.SAVE_GAME_SUCCESS:
                return response;
            case Message.SAVE_GAME_ERROR:
                throw new GameException(GameException.typeErr.LOAD_GAME_ERROR);
            case Message.GAME_IDENT_ERROR:
View Full Code Here


    }

    // *** GAME *** //
    @Override
    public Message checkGame(String pl_id, String ga_id, String ga_infos) throws GameException {
        Message response = scrabbleValidator(pl_id, ga_id, ga_infos);
        switch (response.getHeader()) {
            case Message.PLACE_WORD_SUCCESS:
                return response;
            case Message.PLACE_WORD_ERROR:
                return response;
            case Message.GAME_IDENT_ERROR:
View Full Code Here

    }

    // Save, Delete or Destroy plays
    @Override
    public Message deleteAnonym(String pl_id) throws GameException {
        Message response = destroyAnonym(pl_id);
        switch (response.getHeader()) {
            case Message.DELETE_ANONYM_SUCCESS:
                return response;
            case Message.DELETE_ANONYM_ERROR:
                throw new GameException(GameException.typeErr.DELETE_ANONYM_ERROR);
        }
View Full Code Here

        return null;
    }

    @Override
    public Message exchangeTile(String pl_id, String position) throws GameException {
        Message response = tileExchange(pl_id, position);
        switch (response.getHeader()) {
            case Message.TILE_EXCHANGE_SUCCES:
                return response;
            case Message.TILE_EXCHANGE_ERROR:
                throw new GameException(GameException.typeErr.TILE_EXCHANGE_ERROR);
        }
View Full Code Here

        return null;
    }

    @Override
    public Message switchTile(String pl_id, String position) throws GameException {
        Message response = tileSwitch(pl_id, position);
        switch (response.getHeader()) {
            case Message.TILE_SWITCH_SUCCES:
                return response;
            case Message.TILE_SWITCH_ERROR:
                throw new GameException(GameException.typeErr.TILE_EXCHANGE_ERROR);
        }
View Full Code Here

     * already exists, return False and do nothing.
     */
    @Override
    protected Message createAccount(String pl_name, String pl_pwd) {
        if (players.playerExists(pl_name)) {
            return new Message(Message.NEW_ACCOUNT_ERROR, "");
        }
        Player newPlayer = new Player(pl_name, pl_pwd);
        players.addPlayer(newPlayer);
        plays.addPlayer(newPlayer.getPlayerID());
        // Return the new player ID
        return new Message(Message.NEW_ACCOUNT_SUCCESS, newPlayer.getPlayerID());
    }
View Full Code Here

    protected Message loginProcess(String pl_name, String pl_pwd) {
        if (players.playerExists(pl_name)) {
            Player pl = players.checkPassword(pl_name, pl_pwd);
            if (pl != null) {
                plays.addPlayer(pl.getPlayerID());
                return new Message(Message.LOGIN_SUCCESS, pl.getPlayerID());
            } else {
                return new Message(Message.LOGIN_ERROR, "");
            }
        }
        return new Message(Message.PLAYER_NOT_EXISTS, "");
    }
View Full Code Here

    @Override
    protected Message logoutProcess(String pl_id) {
        if (plays.playerIsLogged(pl_id)) {
            plays.removePlayer(pl_id);
            return new Message(Message.LOGOUT_SUCCESS, "");
        }
        return new Message(Message.LOGOUT_ERROR, "");
    }
View Full Code Here

    protected Message createNewGame(String pl_id) {
        if (plays.playerIsLogged(pl_id)) {
            // Initialization of the Play on the server side and add it to the GameRAM dict.
            Play newPlay = new Play(pl_id);
            plays.addNewPlay(pl_id, newPlay);
            return new Message(Message.NEW_GAME_SUCCESS, newPlay.getPlayID() + "##" + newPlay.getFormatRack()); // Only return the rack to the client.
        }
        return new Message(Message.PLAYER_NOT_LOGGED, "");
    }
View Full Code Here

            plays.addPlayer(pl_id);
            // Initialization of the Play on the server side and add it to the GameRAM dict.
            Play newPlay = new Play(pl_id);
            plays.addNewPlay(pl_id, newPlay);
            System.out.println("Rack : " + newPlay.getFormatRack());
            return new Message(Message.NEW_GAME_ANONYM_SUCCESS, newPlay.getPlayID() + "##" + newPlay.getFormatRack()); // Only return the rack to the client.
        }
        // The current anonymous player is already logged.
        return new Message(Message.NEW_GAME_ANONYM_ERROR, "");
    }
View Full Code Here

TOP

Related Classes of server.common.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.