protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("application/json");
		PrintWriter outp = response.getWriter();

		String gameID = request.getParameter("game");
		String play = request.getParameter("play");
		// is the file locked for the correct colour
		if(play.matches(isLocked(gameID))){
			// Create game
			GameInterfaceConnect game = new ChessGameConnect(request.getParameterMap(), null);
			String gs = game.getGameState();
			if (request.getParameter("move") != null && game.isValid(request.getParameter("move"))) {
				game.makeMove(request.getParameter("move"));
				gs = game.getGameState();
				gs = gs.substring(0, gs.length() - 1) + ",\"game\":\""+ gameID + "\",\"play\":\""+ play  +"\",\"valid\":\"true\"}";
				// update game file
				updateGame(gameID, gs);
				unlock(gameID);
			}else{
				gs = gs.substring(0, gs.length() - 1) + ",\"game\":\""+ gameID + "\",\"play\":\""+ play  +"\",\"valid\":\"false\"}";
				// update game file
				updateGame(gameID, gs);
			}
			outp.write(gs);
		}else{
			int t = 0, count = 60*60;
			while(!play.matches(isLocked(gameID)) && t < count)
				try {
					Thread.sleep(1000);
					t++;
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			if(t >= count)
				outp.write("{\"timeout\":true}");
			else
				outp.write(readStatus(gameID));
		}
	}