Esempio n. 1
0
        public async Task <bool> GetCreateAsync(string controller, string secondary, string login)
        {
            var response = await auth.client.GetAsync(controller + secondary + login);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var content = await response.Content.ReadAsStringAsync();

                var guid = content.Trim('"');
                auth.Guid = guid;
                Console.WriteLine("Private id for your parner => ");
                Console.WriteLine(guid);
                Console.WriteLine("\nPress any key to continue...");
                TimerClass timer = new TimerClass(25000);
                timer.SetTimer();
                timer.StartTimer();
                while (true)
                {
                    if (timer.inGoing == "Exit")
                    {
                        return(false);
                    }
                    response = await auth.client.GetAsync($"{controller}/{login}/{guid}");

                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        break;
                    }
                    await Task.Delay(2000);
                }

                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        public async Task Play(string controller, string secondary)
        {
            string logo = "Choose a figure => ";

            string[] options        = new string[] { "Rock", "Scissors", "Paper", "Exit" };
            Menu     randomGameMenu = new Menu(logo, options);

            Commands command   = Commands.Exit;
            bool     isRunning = true;

            while (isRunning)
            {
                var timer = new TimerClass(20000);
                timer.SetTimer();
                timer.StartTimer();
                if (timer.inGoing == "Exit")
                {
                    command = Commands.Exit;
                    await gameProcess.PostFigureAsync(controller, secondary, command, timer);

                    return;
                }

                int result = randomGameMenu.Run();

                switch (result)
                {
                case 0:
                    gameProcess.auth.Stat.RockCount++;
                    command = Commands.Stone;
                    break;

                case 1:
                    gameProcess.auth.Stat.ScissorsCount++;
                    command = Commands.Scissors;
                    break;

                case 2:
                    gameProcess.auth.Stat.PaperCount++;
                    command = Commands.Paper;
                    break;

                default:
                    command = Commands.Exit;
                    break;
                }
                isRunning = await gameProcess.PostFigureAsync(controller, secondary, command, timer);
            }
        }