コード例 #1
0
        public async Task <GameDataDTO> GetGameData()
        {
            Game game = await _gameHandler.GetActiveGame(HttpContext);

            if (game == null)
            {
                return(new GameDataDTO {
                    GameExists = false
                });
            }

            return(new GameDataDTO()
            {
                AIGuesses = game.Guesses.Where(a => a.GuessMaker == GuessMaker.AI).ToList().Select(a => new GuessDTO
                {
                    Value = a.Value,
                    GuessOutcome = new GuessOutcomeDTO(a.GuessOutcome)
                }),
                UserGuesses = game.Guesses.Where(a => a.GuessMaker == GuessMaker.User).ToList().Select(a => new GuessDTO
                {
                    Value = a.Value,
                    GuessOutcome = new GuessOutcomeDTO(a.GuessOutcome)
                }),
                GameExists = true,
                NumberWhichAIMustGuess = game.NumberWhichAIMustGuess
            });
        }