* 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();