src/main/java/com/webcheckers/ui/PostSubmitTurnRoute.java
/**
     * Handles submit a turn request. Either rejects or accepts a move
     * @param request http request
     * @param response http response
     * @return jsonmessage Object
     */
Handles submit a turn request. Either rejects or accepts a move
@param request http request
@param response http response
@return jsonmessage Object
Handles submit a turn request . Either rejects or accepts a move @param request http request @param response http response @return jsonmessage Object
@Override
    public Object handle(Request request, Response response){
        final Session httpSession = request.session();
        Game game = Application.gameCenter.getGameByPlayer(httpSession.attribute("Player"));
        Gson gson = new Gson();
        if (game != null){
            game.isGameOver();
            Move move = game.getTurn().getPrevMove();
            Message message;
            if (game.endTurn()) {
               message = Message.info("true");
               String move_json = gson.toJson(message);
               response.body(move_json);
             return move_json;
            } else {
                message = Message.error("Jump moves possible.");
            }
            String move_json = gson.toJson(message);
            response.body(move_json);
            return move_json;
        }
        else{
            Message message = Message.info("true");
            String jsonMessage = gson.toJson(message);
            response.body(jsonMessage);
            get(GAME_URL, new GetGameRoute(templateEngine)); 
            return jsonMessage;        }
    }
@ Override public Object handle ( Request request , Response response ) { final Session httpSession = request . session ( ) ; Game game = Application . gameCenter . getGameByPlayer ( httpSession . attribute ( "Player" ) ) ; Gson gson = new Gson ( ) ; if ( game != null ) { game . isGameOver ( ) ; Move move = game . getTurn ( ) . getPrevMove ( ) ; Message message ; if ( game . endTurn ( ) ) { message = Message . info ( "true" ) ; String move_json = gson . toJson ( message ) ; response . body ( move_json ) ; return move_json ; } else { message = Message . error ( "Jump moves possible." ) ; } String move_json = gson . toJson ( message ) ; response . body ( move_json ) ; return move_json ; } else { Message message = Message . info ( "true" ) ; String jsonMessage = gson . toJson ( message ) ; response . body ( jsonMessage ) ; get ( GAME_URL , new GetGameRoute ( templateEngine ) ) ; return jsonMessage ; } }
Handles submit a turn request.
Handles submit a turn request .
//Home route (default)