Example #1
0
        private Game InitializeGame()
        {
            UI.Console.WriteLine(ConsoleColor.DarkCyan, "Shuffling and dealing the deck...");
            WebApi.Dtos.Game gameDto = http.GetNewGame();

            Game game = mapper.MapToModel(gameDto);

            return(game);
        }
Example #2
0
        public WebApi.Dtos.Game GetNewGame()
        {
            HttpResponseMessage response = client.GetAsync("game/new").Result;

            string result = HandleResponse(response);

            WebApi.Dtos.Game game = JsonConvert.DeserializeObject <WebApi.Dtos.Game>(result);

            return(game);
        }
Example #3
0
        private Game ProcessTurnBot(Game game)
        {
            UI.Console.WriteLine(ConsoleColor.DarkCyan, game.DescriptionLastTurn);
            UI.Console.WriteLine(new string('-', 77));
            UI.Console.WriteLine("Bot: thinking...");
            WebApi.Dtos.Game gameDto = http.PostBotTurn(mapper.MapToDto(game));
            UI.Console.WriteLine(ConsoleColor.DarkCyan, gameDto.DescriptionLastTurn);
            UI.Console.WriteLine(new string('-', 77));

            return(mapper.MapToModel(gameDto));
        }
Example #4
0
        public WebApi.Dtos.Game PostBotTurn(WebApi.Dtos.Game gameDto)
        {
            var content = JsonConvert.SerializeObject(gameDto);

            HttpResponseMessage response = client.PostAsync("game/playturn", new StringContent(content, Encoding.UTF8, "application/json")).Result;

            string result = HandleResponse(response);

            WebApi.Dtos.Game reponse = JsonConvert.DeserializeObject <WebApi.Dtos.Game>(result);

            return(reponse);
        }