private JSONObject endGame(int gameCount) { Random randomNum = new Random(); GameInfo gameInfo; JSONObject jObj = new JSONObject(); JSONObject action = new JSONObject(); int game; String status; game = getRandomGame(gameCount); gameInfo = gameRecord.get(game); gameInfo.incrementCount(); if (gameInfo.getCount() < 9) { return moveUser(gameCount); } if (gameInfo.getPoints() > 40 || gameInfo.getPoints() < -40) { status = "WIN"; } else { status = "LOSS"; } try { jObj.put("game", game); action.put("actionType", "gameEnd"); action.put("gameStatus", status); action.put("actionNumber", gameInfo.getCount()); action.put("points", gameInfo.getPoints()); jObj.put("action", action); jObj.put("user", gameInfo.getUser()); userIds[gameInfo.getId()] = false; gameRecord.remove(game); } catch (JSONException e) { System.out.println("could not put"); } return jObj; }