private async Task GetResults()
        {
            _logger.LogInformation("class PlayerStatisticsMenu. GetResults()");

            var response = await _statisticClient.GetUserResultsAsync();

            _logger.LogInformation("REQUEST: Sent the request to get the statistics");

            if (response.StatusCode == HttpStatusCode.OK)
            {
                _logger.LogInformation("RESPONSE: Get the Statistics (200)");

                var content = await response.Content.ReadAsStringAsync();

                var results = JsonSerializer.Deserialize <ResultsDto>(content);

                MenuLibrary.WriteLineColor("\nYour results:\n", ConsoleColor.Yellow);

                MenuLibrary.WriteColor("Wins: ", ConsoleColor.Yellow);
                MenuLibrary.WriteLineColor(results.WinCount.ToString(), ConsoleColor.White);

                MenuLibrary.WriteColor("Draws: ", ConsoleColor.Yellow);
                MenuLibrary.WriteLineColor(results.DrawCount.ToString(), ConsoleColor.White);

                MenuLibrary.WriteColor("Losses: ", ConsoleColor.Yellow);
                MenuLibrary.WriteLineColor(results.LossCount.ToString(), ConsoleColor.White);

                MenuLibrary.PressAnyKey();
            }
            else
            {
                _logger.LogInformation("RESPONSE: Unknown response");
                throw new HttpListenerException();
            }
        }
        private async Task GetTotalTime()
        {
            _logger.LogInformation("class PlayerStatisticsMenu. GetTotalTime()");

            var response = await _statisticClient.GetUserGameTimeAsync();

            _logger.LogInformation("REQUEST: Sent the request to get the statistics");

            if (response.StatusCode == HttpStatusCode.OK)
            {
                _logger.LogInformation("RESPONSE: Get the Statistics (200)");

                var time = await response.Content.ReadAsStringAsync();

                time = JsonSerializer.Deserialize <string>(time);

                MenuLibrary.WriteColor("\nTotal time in the game: ", ConsoleColor.Yellow);
                MenuLibrary.WriteLineColor(time, ConsoleColor.White);

                MenuLibrary.PressAnyKey();
            }
            else
            {
                _logger.LogInformation("RESPONSE: Unknown response");
                throw new HttpListenerException();
            }
        }
Exemple #3
0
        private static async Task <int> Main()
        {
            var provider = GetServiceProvider();

            while (true)
            {
                try
                {
                    MenuLibrary.Clear();
                    MenuLibrary.WriteLineColor("The Rock Paper Scissors Game. Designed by Karyna Bilotska and Daniil Panasenko\n", ConsoleColor.DarkGreen);

                    MenuLibrary.PressAnyKey();

                    GetHttpClient();

                    var mainMemu = provider.GetRequiredService <MainMenu>();
                    await mainMemu.StartAsync();

                    return(0);
                }
                catch (Exception)
                {
                    ResponseLibrary.UnknownResponse();
                    MenuLibrary.PressAnyKey();
                }
            }
        }
        private void ShowRate(List <UserResultDto> results)
        {
            MenuLibrary.WriteLineColor("", ConsoleColor.White);
            int place = 1;

            foreach (var result in results)
            {
                MenuLibrary.WriteColor($"{place}. {result.Login}: ", ConsoleColor.White);
                MenuLibrary.WriteLineColor(result.Result, ConsoleColor.Yellow);
                place++;
            }
            MenuLibrary.PressAnyKey();
        }
Exemple #5
0
        private void ShowRate(List <ResultByTimeDto> results)
        {
            MenuLibrary.WriteLineColor("", ConsoleColor.White);
            int place = 1;

            foreach (var result in results)
            {
                MenuLibrary.WriteColor($"{place}. {result.Time} -> ", ConsoleColor.White);
                MenuLibrary.WriteColor(result.WinCount.ToString(), ConsoleColor.Green);
                MenuLibrary.WriteColor(" : ", ConsoleColor.White);
                MenuLibrary.WriteLineColor(result.LossCount.ToString(), ConsoleColor.Red);
                place++;
            }
            MenuLibrary.PressAnyKey();
        }
        public void PrintResult(RoundResultDto result)
        {
            string       resultString = "";
            ConsoleColor color        = ConsoleColor.White;

            switch (result.Result)
            {
            case 1:
                _sessionResults.WinCount++;
                resultString = "Win";
                color        = ConsoleColor.Green;
                break;

            case 0:
                _sessionResults.DrawCount++;
                resultString = "Draw";
                color        = ConsoleColor.Yellow;
                break;

            case -1:
                _sessionResults.LossesCount++;
                resultString = "Lose";
                color        = ConsoleColor.Red;
                break;
            }

            PrintHeader();

            MenuLibrary.WriteColor($"\nYour move: ", ConsoleColor.White);
            MenuLibrary.WriteLineColor($"{_currentMove}", ConsoleColor.DarkCyan);

            MenuLibrary.WriteColor($"Opponent move: ", ConsoleColor.White);
            MenuLibrary.WriteLineColor($"{result.OpponentMove}", ConsoleColor.DarkCyan);

            MenuLibrary.WriteColor($"\nResult: ", ConsoleColor.White);
            MenuLibrary.WriteLineColor(resultString, color);

            MenuLibrary.PressAnyKey();
        }