public ContentResult End() { Debug.WriteLine("End called"); JObject reqBody = ParseRequestBody(Request); // Find the matching game by the ID received and delete it string gameID = (string)reqBody["game"]["id"]; BattleSnakeGame gameToDelete = null; foreach (BattleSnakeGame game in Program.battleSnakeGames) { if (game.GetGameID() == gameID) { gameToDelete = game; break; } } if (gameToDelete != null) { Program.battleSnakeGames.Remove(gameToDelete); } else { // TODO: We have a fail } // Doesn't really matter as the server ignores the request ContentResult result = new ContentResult(); result.StatusCode = 200; return(result); }
public ContentResult Start() { Debug.WriteLine("Start called"); JObject reqBody = ParseRequestBody(Request); // Create a new game BattleSnakeGame newGame = new BattleSnakeGame(reqBody); Program.battleSnakeGames.Add(newGame); ContentResult result = new ContentResult(); result.StatusCode = 200; result.ContentType = "application/json"; result.Content = newGame.GetPlayerSnake().GetSnakePersonalisationJSON(); return(result); }