package com.viv.mvcapp.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.viv.mvcapp.domain.GameState;


@Controller
public class GameController {
	
    @Autowired
    GameState gameState;

	@RequestMapping(value="/treasuregame", method= RequestMethod.GET)
	public ModelAndView startTreasureGame(ModelAndView mv) {
		mv.setViewName("PlayTreasureGame");
		
		return mv;
	}
	
	@RequestMapping(value="/TreasureGameController", method = RequestMethod.GET)
	public @ResponseBody GameState controlTreasureGame(ModelAndView mv, HttpServletRequest request, HttpSession session, @RequestParam("action") String action) {
//		switch (action) {
//        case "start":
        if ("start".equals(action)) {
       		gameState = new GameState(request.getParameter("numRows"));
//            break;
        } else if ("move".equals(action)) {
//        case "move":
        	int index = Integer.parseInt(request.getParameter("index"));
        	if (index == gameState.getTreasureLocation()) {
        		gameState.setEndTime();
        		gameState.setWon(true);
        	} else {
        		gameState.setWon(false);
        	}
//            break;
        }
//        default:
//    	   break;
//		}
		return gameState;
	}
	
	public GameState getGameState() {
		return gameState;
	}

	public void setGameState(GameState gameState) {
		this.gameState = gameState;
	}
}

@@ -1074,54 +1074,8 @@
 ) %7B%0A
-//%09%09switch (action) %7B%0A//        case %22start%22:%0A
     
@@ -1177,37 +1177,16 @@
 ows%22));%0A
-//            break;%0A
         
@@ -1225,31 +1225,8 @@
 ) %7B%0A
-//        case %22move%22:%0A
     
@@ -1480,26 +1480,24 @@
      %09%7D%0A
-//
         
     brea
@@ -1492,69 +1492,8 @@
     
-    break;%0A        %7D%0A//        default:%0A//    %09   break;%0A//%09%09
 %7D%0A%09%09

Remove commented out code