Example #1
0
        public JsonResult Guess(string game_key, string code)
        {
            var game         = new Game.Game();
            var response     = game.TryANewGuess(game_key, code);
            var returnObject = new
            {
                colors      = response.Colors,
                code_length = response.Code_length,
                game_key    = response.Game_key,
                num_guesses = response.Num_guesses,
                result      = new
                {
                    exact = response.Result?.Exact,
                    near  = response.Result?.Near
                },
                past_results          = response.Past_results?.Select(x => new { exact = x.Exact, near = x.Near }).ToList(),
                opponent_past_results = response.Opponent_Past_results?.Select(x => new { exact = x.Exact, near = x.Near }).ToList(),
                solved      = response.Solved,
                error       = response.Error,
                multiplayer = response.Multiplayer,
                winner      = response.Winner
            };

            return(Json(returnObject, JsonRequestBehavior.DenyGet));
        }