src/main/java/com/webcheckers/ui/PostHomeRoute.java
/**
     * WebCheckers post home route (game creation / redirection)
     *
     * @param request
     *   the HTTP request
     * @param response
     *   the HTTP response
     *
     * @return
     *   the rendered HTML for PostHomeRoute (nothing)
     */
WebCheckers post home route (game creation / redirection)
@param request
the HTTP request
@param response
the HTTP response

@return
the rendered HTML for PostHomeRoute (nothing)
WebCheckers post home route ( game creation / redirection ) @param request the HTTP request @param response the HTTP response @return the rendered HTML for PostHomeRoute ( nothing )
@Override
    public Object handle(Request request, Response response) {
        final Session httpSession = request.session();
        Map<String, Object> vm = new HashMap<>();
        final String otherPlayer = request.queryParams(OTHER);
        Player whitePlayer = Application.playerLobby.getPlayers().get(otherPlayer);
        Game game = Application.gameCenter.getGameByPlayer(whitePlayer);
        if (game != null){
            vm.put(VMAttributes.TITLE, TITLE_STR);
            vm.put(VMAttributes.CURRENT_USER, httpSession.attribute(SessionAttributes.PLAYER));
            vm.put(VMAttributes.SIGNED, Application.playerLobby.get_logged_names());
            vm.put(VMAttributes.PLAYING, Application.playerLobby.get_playing());
            vm.put(VMAttributes.SPECTATING, Application.playerLobby.get_spectating());
            httpSession.attribute(SessionAttributes.ERROR, Message.error(String.format(ERR, otherPlayer)));
            response.redirect(HOME_URL);
            return null;
        }
        Player currentPlayer = httpSession.attribute(SessionAttributes.PLAYER);
        Game newGame = new Game(currentPlayer, whitePlayer);
        Application.gameCenter.addGame(newGame);
        httpSession.attribute("ID", newGame.gameid);
        httpSession.attribute(SessionAttributes.GAME, newGame);
        vm.put(VMAttributes.TITLE, TITLE);
        vm.put(VMAttributes.MESSAGE, WELCOME_MSG);
        vm.put(VMAttributes.CURRENT_USER, currentPlayer);
        vm.put(VMAttributes.RED_PLAYER, currentPlayer);
        vm.put(VMAttributes.WHITE_PLAYER, whitePlayer);
        vm.put(VMAttributes.VIEW_MODE, Game.ViewMode.PLAY);
        vm.put(VMAttributes.BOARD, newGame.getBoardView());
        vm.put(VMAttributes.ACTIVE_COLOR, newGame.getActiveColor());
        response.redirect(GAME_URL);
        return null;
    }
@ Override public Object handle ( Request request , Response response ) { final Session httpSession = request . session ( ) ; Map < String , Object > vm = new HashMap < > ( ) ; final String otherPlayer = request . queryParams ( OTHER ) ; Player whitePlayer = Application . playerLobby . getPlayers ( ) . get ( otherPlayer ) ; Game game = Application . gameCenter . getGameByPlayer ( whitePlayer ) ; if ( game != null ) { vm . put ( VMAttributes . TITLE , TITLE_STR ) ; vm . put ( VMAttributes . CURRENT_USER , httpSession . attribute ( SessionAttributes . PLAYER ) ) ; vm . put ( VMAttributes . SIGNED , Application . playerLobby . get_logged_names ( ) ) ; vm . put ( VMAttributes . PLAYING , Application . playerLobby . get_playing ( ) ) ; vm . put ( VMAttributes . SPECTATING , Application . playerLobby . get_spectating ( ) ) ; httpSession . attribute ( SessionAttributes . ERROR , Message . error ( String . format ( ERR , otherPlayer ) ) ) ; response . redirect ( HOME_URL ) ; return null ; } Player currentPlayer = httpSession . attribute ( SessionAttributes . PLAYER ) ; Game newGame = new Game ( currentPlayer , whitePlayer ) ; Application . gameCenter . addGame ( newGame ) ; httpSession . attribute ( "ID" , newGame . gameid ) ; httpSession . attribute ( SessionAttributes . GAME , newGame ) ; vm . put ( VMAttributes . TITLE , TITLE ) ; vm . put ( VMAttributes . MESSAGE , WELCOME_MSG ) ; vm . put ( VMAttributes . CURRENT_USER , currentPlayer ) ; vm . put ( VMAttributes . RED_PLAYER , currentPlayer ) ; vm . put ( VMAttributes . WHITE_PLAYER , whitePlayer ) ; vm . put ( VMAttributes . VIEW_MODE , Game . ViewMode . PLAY ) ; vm . put ( VMAttributes . BOARD , newGame . getBoardView ( ) ) ; vm . put ( VMAttributes . ACTIVE_COLOR , newGame . getActiveColor ( ) ) ; response . redirect ( GAME_URL ) ; return null ; }
WebCheckers post home route (game creation / redirection)
 @param request
   the HTTP request
 @param response
   the HTTP response
WebCheckers post home route ( game creation / redirection ) @param request the HTTP request @param response the HTTP response
//If we have a null game, we redirect to home //The following occurs (new game is created) //Redirect to the game url