Beispiel #1
0
        public async Task StartAsync()
        {
            _logger.LogInformation("class MainMenu. StartAsync()");

            while (true)
            {
                MenuLibrary.Clear();

                _logger.LogInformation("Choosing the command");

                var options = new string[] { "Authorization", "Leaderboard", "Exit" };
                var command = MenuLibrary.InputMenuItemNumber("Main Menu", options);

                _logger.LogInformation("Chose the command");

                switch (command)
                {
                case 1:
                    await _authMenu.StartAsync();

                    break;

                case 2:
                    await _leaderMenu.StartAsync();

                    break;

                case 3:
                    return;
                }
            }
        }
        public async Task StartAsync()
        {
            _logger.LogInformation("class StatisticsMenu. StartAsync()");

            while (true)
            {
                _logger.LogInformation("Choosing the Statistics");

                MenuLibrary.Clear();

                var options = new string[] { "Leaderboard", "Player statistics", "Back" };
                var command = MenuLibrary.InputMenuItemNumber("Statistics Menu", options);

                _logger.LogInformation("Chose the command");

                switch (command)
                {
                case 1:
                    await _leaderboardMenu.StartAsync();

                    break;

                case 2:
                    await _playerStatisticsMenu.StartAsync();

                    break;

                case 3:
                    return;
                }
            }
        }
Beispiel #3
0
        public async Task StartAsync()
        {
            _logger.LogInformation("class UserMenu. StartAsync()");

            while (true)
            {
                _logger.LogInformation("Choosing the option");

                MenuLibrary.Clear();

                var options = new string[] { "Game", "Statistics", "Logout" };
                var command = MenuLibrary.InputMenuItemNumber("User Menu", options);

                _logger.LogInformation("Chose the command");

                switch (command)
                {
                case 1:
                    await _gameStartMenu.StartAsync();

                    break;

                case 2:
                    await _statisticsMenu.StartAsync();

                    break;

                case 3:
                    return;
                }
            }
        }
Beispiel #4
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();
                }
            }
        }
Beispiel #5
0
        public async Task StartAsync()
        {
            _logger.LogInformation("class AuthorizationMenu. StartAsync()");
            while (true)
            {
                _logger.LogInformation("Choosing the Authorization Method");

                MenuLibrary.Clear();

                var options = new string[] { "Login", "Registration", "Back" };
                var command = MenuLibrary.InputMenuItemNumber("Authorization Menu", options);

                _logger.LogInformation("Chose the command");

                switch (command)
                {
                case 1:
                    await ExecuteLoginAsync();

                    break;

                case 2:
                    await ExecuteRegistrationAsync();

                    break;

                case 3:
                    return;
                }
            }
        }
 public void PrintHeader()
 {
     MenuLibrary.Clear();
     MenuLibrary.WriteLineColor("\nGame\n", ConsoleColor.Yellow);
     MenuLibrary.WriteColor("Results: ", ConsoleColor.White);
     MenuLibrary.WriteColor($"{_sessionResults.WinCount} : ", ConsoleColor.Green);
     MenuLibrary.WriteColor($"{_sessionResults.DrawCount} : ", ConsoleColor.Yellow);
     MenuLibrary.WriteLineColor($"{_sessionResults.LossesCount}", ConsoleColor.Red);
 }
Beispiel #7
0
        public async Task StartAsync()
        {
            _logger.LogInformation("class IntervalResultsMenu. StartAsync()");

            while (true)
            {
                _logger.LogInformation("Choosing Time Interval");

                TimeInterval timeInterval = TimeInterval.Day;

                MenuLibrary.Clear();

                var options = new string[] { "By days", "By hours", "By minutes", "Back" };
                var command = MenuLibrary.InputMenuItemNumber("Leaderboard Menu", options);

                _logger.LogInformation("Chose the command");

                switch (command)
                {
                case 1:
                    timeInterval = TimeInterval.Day;
                    break;

                case 2:
                    timeInterval = TimeInterval.Hour;
                    break;

                case 3:
                    timeInterval = TimeInterval.Minute;
                    break;

                case 4:
                    return;
                }

                var content = await GetResultByIntervalAsync(timeInterval);

                if (content == null)
                {
                    continue;
                }

                var results = JsonSerializer.Deserialize <List <ResultByTimeDto> >(content);
                ShowRate(results);
            }
        }
        public async Task StartAsync()
        {
            _logger.LogInformation("class LeaderboardMenu. StartAsync()");

            while (true)
            {
                _logger.LogInformation("Choosing Statistics Type");

                StatisticsType statisticsType = StatisticsType.WinStatistics;

                MenuLibrary.Clear();

                var options = new string[] { "Win statistics", "Time statistics", "Wins statistics(in persents)", "Back" };
                var command = MenuLibrary.InputMenuItemNumber("Leaderboard Menu", options);

                _logger.LogInformation("Chose the command");

                switch (command)
                {
                case 1:
                    statisticsType = StatisticsType.WinStatistics;
                    break;

                case 2:
                    statisticsType = StatisticsType.TimeStatistics;
                    break;

                case 3:
                    statisticsType = StatisticsType.WinPercentStatistics;
                    break;

                case 4:
                    return;
                }

                var content = await GetStatistcsAsync(statisticsType);

                if (content == null)
                {
                    continue;
                }

                var results = JsonSerializer.Deserialize <List <UserResultDto> >(content);
                ShowRate(results);
            }
        }
        public async Task StartAsync()
        {
            _logger.LogInformation("class PlayerStatisticsMenu. StartAsync()");

            while (true)
            {
                _logger.LogInformation("Choosing the Statistics Type");

                MenuLibrary.Clear();

                var options = new string[] { "Total results", "Total playing time", "Moves statistics", "Results by the time", "Back" };
                var command = MenuLibrary.InputMenuItemNumber("Player statistics Menu", options);

                _logger.LogInformation("Chose the command");

                switch (command)
                {
                case 1:
                    await GetResults();

                    break;

                case 2:
                    await GetTotalTime();

                    break;

                case 3:
                    await GetMovesStatistics();

                    break;

                case 4:
                    await _intervalResultsMenu.StartAsync();

                    break;

                case 5:
                    return;
                }
            }
        }
        public async Task StartAsync()
        {
            _logger.LogInformation("class GameStartMenu. StartAsync()");

            while (true)
            {
                _logger.LogInformation("Choosing the game type");

                MenuLibrary.Clear();

                var options = new string[] { "Public game", "Private game", "Train game", "Back" };
                var command = MenuLibrary.InputMenuItemNumber("Game Menu", options);

                _logger.LogInformation("Chose the command");

                RoomType roomType;
                string   roomId = null;

                switch (command)
                {
                case 1:
                    roomType = RoomType.Public;
                    break;

                case 2:
                    roomType = RoomType.Private;
                    roomId   = ChoosePrivateRoom();
                    break;

                case 3:
                    roomType = RoomType.Train;
                    break;

                case 4:
                default:
                    return;
                }

                await GameStartAsync(roomType, roomId);
            }
        }
Beispiel #11
0
        private async Task ExecuteRegistrationAsync()
        {
            _logger.LogInformation("class AuthorizationMenu. ExecuteRegistrationAsync()");

            MenuLibrary.Clear();
            while (true)
            {
                MenuLibrary.WriteLineColor("\nRegistration\n", ConsoleColor.Yellow);

                string login    = MenuLibrary.InputStringValue("login");
                string password = MenuLibrary.InputStringValue("password");

                _logger.LogInformation("Entered the login and the password");

                var response = await _userClient.RegistrationAsync(login, password);

                _logger.LogInformation("REQUEST: Sent the register request to the server");

                if (await ResponseHandlerAsync(response, "registration"))
                {
                    return;
                }
            }
        }