Package nz.ac.massey.softwarec.group3.game

Examples of nz.ac.massey.softwarec.group3.game.Player


     * Gets the game players information and adds it to a JSON string gamePlayersJSON, which will be returned to the client.
     * @param game - The Game to get player information for.
     * @return String gamePlayersJSON - JSON string representing the players in a game.
     */
    public static String getGamePlayersData(final Game game) {
        final SessionTracker sessionTracker = SessionListener.getSessionTracker();
        final List<Player> gamePlayers = game.getPlayers();
        final StringBuilder gamePlayersJSON = new StringBuilder();
        gamePlayersJSON.append("{\"players\": [");
        for (Player player : gamePlayers) {
            gamePlayersJSON.append("{\"name\" : \"").append(sessionTracker.getUserNameFromEmail(player.getPlayerEmail())).append("\",");
            gamePlayersJSON.append("\"ready\" : ").append(player.isReady()).append("},");
        }
        gamePlayersJSON.deleteCharAt(gamePlayersJSON.length()-1);
        gamePlayersJSON.append("] }");
        return gamePlayersJSON.toString();
View Full Code Here

TOP

Related Classes of nz.ac.massey.softwarec.group3.game.Player

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.