Package nz.ac.massey.softwarec.group3.actions

Examples of nz.ac.massey.softwarec.group3.actions.PerformActionTest


            }
            if (players.get(whosTurn).isMrX()) {
                mrX.move();
                mrXMoves.add(move);
                if (mrXMoves.isEmpty() || mrXMoves.size() == 5 || mrXMoves.size() == 10 || mrXMoves.size() == 15 || mrXMoves.size() == 21) {
                    final ReverseAJAXCall call = new ReverseAJAXCall();
                    call.createFilteredFunctionCall("/Software_Engineering_C/Resources/JavaServerPages/ingame.jsp", "Game", creatorEmail, "slideOutAlert", "Mr. X will show himself in 3 turns!");
                }
                if (mrXMoves.size() == 1 || mrXMoves.size() == 6 || mrXMoves.size() == 11 || mrXMoves.size() == 16  || mrXMoves.size() == 22) {
                    final ReverseAJAXCall call = new ReverseAJAXCall();
                    call.createFilteredFunctionCall("/Software_Engineering_C/Resources/JavaServerPages/ingame.jsp", "Game", creatorEmail, "slideOutAlert", "Mr. X will show himself in 2 turns!");
                }
                if (mrXMoves.size() == 2 || mrXMoves.size() == 7 || mrXMoves.size() == 12 || mrXMoves.size() == 17  || mrXMoves.size() == 23) {
                    final ReverseAJAXCall call = new ReverseAJAXCall();
                    call.createFilteredFunctionCall("/Software_Engineering_C/Resources/JavaServerPages/ingame.jsp", "Game", creatorEmail, "slideOutAlert", "Mr. X will show himself in 1 turn!");
                }
                if (mrXMoves.size() == 3 || mrXMoves.size() == 8 || mrXMoves.size() == 13 || mrXMoves.size() == 18 || mrXMoves.size() == 24) {
                    final ReverseAJAXCall call = new ReverseAJAXCall();
                    call.createFilteredFunctionCall("/Software_Engineering_C/Resources/JavaServerPages/ingame.jsp", "Game", creatorEmail, "slideOutAlert", "Mr. X has been spotted!");
                }
                if (mrXMoves.size() == 4 || mrXMoves.size() == 9 || mrXMoves.size() == 14  || mrXMoves.size() == 20) {
                    final ReverseAJAXCall call = new ReverseAJAXCall();
                    call.createFilteredFunctionCall("/Software_Engineering_C/Resources/JavaServerPages/ingame.jsp", "Game", creatorEmail, "slideOutAlert", "Mr. X will show himself in 4 turns!");
                }
                if (mrXMoves.size() == 19) {
                    final ReverseAJAXCall call = new ReverseAJAXCall();
                    call.createFilteredFunctionCall("/Software_Engineering_C/Resources/JavaServerPages/ingame.jsp", "Game", creatorEmail, "slideOutAlert", "Mr. X will show himself in 5 turns!");
                }
            }
            determineWhosTurnItIsNext();
        }
    }
View Full Code Here


    /**
     * Method to use reverse ajax to update
     * @param updateParams
     */
    private void tellGameToUpdate(final String updateParams) {
        final ReverseAJAXCall call = new ReverseAJAXCall();
        call.createFilteredFunctionCall("/Software_Engineering_C/Resources/JavaServerPages/ingame.jsp", "Game", creatorEmail, "updateGame", updateParams);
    }
View Full Code Here

     * Method to broadcast to all players that the game has ended
     * @param winner
     */
    private void broadcastGameEnded(final String winner) {
        finished = true;
        final ReverseAJAXCall call = new ReverseAJAXCall();
        call.createFilteredFunctionCall("/Software_Engineering_C/Resources/JavaServerPages/ingame.jsp", "Game", creatorEmail, "endGame", winner);
    }
View Full Code Here

    /**
     * Method to tell the lobby that there is a game
     */
    public void tellLobby() {
        final ReverseAJAXCall call = new ReverseAJAXCall();
        call.createFunctionCall("/Software_Engineering_C/Resources/JavaServerPages/lobby.jsp", "addGame", null);
    }
View Full Code Here

     * Adds all game and user information to a JSON string gameJSON, which will be returned to the client.
     * @param game - The Game for which to get the data.
     * @return String gameJSON - JSON string representing the game.
     */
    public static String getGameData(final Game game) {
        final SessionTracker sessionTracker = SessionListener.getSessionTracker();
        final StringBuilder gameJSON = new StringBuilder();
        gameJSON.append("{\"game\" : ");
        gameJSON.append("{\"players\" : [");
        for (Player player : game.getPlayers()) {
            gameJSON.append("{\"email\" : \"").append(player.getPlayerEmail()).append("\",");
            gameJSON.append("\"name\" : \"").append(sessionTracker.getUserNameFromEmail(player.getPlayerEmail())).append("\",");
            gameJSON.append("\"location\" : ").append(player.getCurrentLocation().getStationNumber()).append(",");
            gameJSON.append("\"taxiTickets\" : ").append(player.getTaxiTokens()).append(",");
            gameJSON.append("\"busTickets\" : ").append(player.getBusTokens()).append(",");
            gameJSON.append("\"undergroundTickets\" : ").append(player.getUndergroundTokens()).append(",");
            gameJSON.append("\"mrXTickets\" : ").append(player.getMrXTokens()).append(",");
View Full Code Here

    /**
     * Gets information for lobby and adds to a JSON string lobbyJSON, which will be returned to the client.
     * @return String lobbyJSON - JSON string representing the lobby user data.
     */
    public static String getLobbyData() {
        final SessionTracker sessionTracker = SessionListener.getSessionTracker();
        final List<String> currentlyOnlineUsersEmails = sessionTracker.getListOfUsersWhoAreCurrentlyOnline();
        final StringBuilder lobbyJSON = new StringBuilder();
        lobbyJSON.append("{\"players\": [");
        for (String userEmail : currentlyOnlineUsersEmails) {
            lobbyJSON.append("{\"name\" : \"").append(sessionTracker.getUserNameFromEmail(userEmail)).append("\"},");
        }
        lobbyJSON.deleteCharAt(lobbyJSON.length()-1);
        lobbyJSON.append("] }");
        return lobbyJSON.toString();
    }
View Full Code Here

    /**
     * Gets all of the current game information and adds it to a JSON string gamesJSON, which will be returned to the client.
     * @return Sting gamesJSON - JSON string representing the lobby games data.
     */
    public static String getGamesData() {
        final SessionTracker sessionTracker = SessionListener.getSessionTracker();
        final List<Game> currentlyAvailableGames = sessionTracker.getGameTracker().getAvailableGames();
        final StringBuilder gamesJSON = new StringBuilder();
        gamesJSON.append("{\"games\": [");
        for (Game game : currentlyAvailableGames) {
            if (!game.isPlaying()) {
                gamesJSON.append("{\"players\": [");
                for (Player player : game.getPlayers()) {
                    gamesJSON.append("{\"name\": \"").append(sessionTracker.getUserNameFromEmail(player.getPlayerEmail())).append("\"},");
                }
                gamesJSON.deleteCharAt(gamesJSON.length()-1);
                gamesJSON.append("] , \"creatorName\": \"").append(game.getCreatorName()).append("\",");
                gamesJSON.append("\"creatorEmail\": \"").append(game.getCreatorEmail()).append("\",");
                gamesJSON.append("\"gameID\": \"").append(game.getGameID()).append("\"},");
View Full Code Here

     * 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.actions.PerformActionTest

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.