Exemplo n.º 1
0
        public async Task Start()
        {
            Console.Clear();

            while (true)
            {
                Console.WriteLine();
                Console.WriteLine("Start menu");
                Console.WriteLine("1.\tRegistration");
                Console.WriteLine("2.\tLogin");
                Console.WriteLine("3.\tStatistics");
                Console.WriteLine("4.\tExit");

                Console.Write("Enter the number: ");
                if (!int.TryParse(Console.ReadLine(), out var num))
                {
                    Console.WriteLine("The only numbers can be entered. Try again");
                    continue;
                }

                if (_stopwatch.ElapsedMilliseconds > 30000)
                {
                    _currentSession.CountLoginFailed = 0;
                    _stopwatch.Stop();
                }

                switch (num)
                {
                case 1:
                    await AuthRequests.Register(_client, _currentSession);

                    break;

                case 2:
                    if (_currentSession.CountLoginFailed < 3)
                    {
                        await AuthRequests.Login(_client, _currentSession, _stopwatch);
                    }
                    else
                    {
                        Console.WriteLine("You were temporarily blocked due to incorrect authorization!");
                    }
                    break;

                case 3:
                    await StatRequests.GetGeneralStat(_client);

                    break;

                case 4:
                    Console.WriteLine("Goodbye!");
                    return;

                default:
                    Console.WriteLine("Incorrect number. Try again");
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public async Task Start()
        {
            while (true)
            {
                int num;
                Console.WriteLine("\n1.\tPlay");
                Console.WriteLine("2.\tStatistics");
                Console.WriteLine("3.\tMy statistics");
                Console.WriteLine("4.\tLogout");

                while (true)
                {
                    Console.Write("Enter the number: ");
                    if (!int.TryParse(Console.ReadLine(), out num))
                    {
                        Console.WriteLine("The only numbers can be entered. Try again");
                    }
                    else if (num < 1 || num > 5)
                    {
                        Console.WriteLine("Incorrect number. Try again");
                    }
                    else
                    {
                        break;
                    }
                }
                Console.WriteLine();
                switch (num)
                {
                case 1:
                    await new PlayMenu(_client, _currentSession).Start();
                    break;

                case 2:
                    await StatRequests.GetGeneralStat(_client);

                    break;

                case 3:
                    StatRequests.GetIndividualStat(_client, _currentSession);
                    break;

                case 4:
                    return;
                }
            }
        }