private void SecondPlayerStep()
        {
            var validatorMinMax = new ValidatorMinMax(Min, Max);


            Console.Clear();
            Console.WriteLine($"Wait {Player2.Name}");
            Console.ReadLine();

            int player2Number;

            do
            {
                Console.WriteLine($"Try to guess the number. This number located between {Min} and {Max}. It's your {++attemp}/{attempCount} attemp");
                player2Number = ReadInteger.FromConsole(validatorMinMax);
                if (player2Number > player1Number)
                {
                    Console.WriteLine($"{player2Number} is biger than conceived");
                }

                if (player2Number < player1Number)
                {
                    Console.WriteLine($"{player2Number} is less than conceived");
                }

                if (player1Number == player2Number)
                {
                    win = true;
                }
            } while ((player1Number != player2Number) && (attemp < attempCount));
        }
Exemplo n.º 2
0
        public User GetPlayer()
        {
            var user = UserRepo.Get(null);

            while (!LogIn)
            {
                Console.WriteLine("1 - Login with existing user");
                Console.WriteLine("2 - Create new user");
                Console.WriteLine("3 - Play as a guest");
                var validatorUserEnter = new ValidatorEnterUser();
                var UserChoose         = (LogInMenuEnum)ReadInteger.FromConsole(validatorUserEnter);
                Console.Clear();
                switch (UserChoose)
                {
                case LogInMenuEnum.LogIn:
                    while (!LogIn)
                    {
                        TryLogIn();
                        if (Login == "exit" || Password == "exit")
                        {
                            break;
                        }
                    }
                    if (Login == "exit" || Password == "exit")
                    {
                        break;
                    }
                    user       = UserRepo.Get(Login);
                    user.LogIn = true;
                    UserRepo.Save(user);
                    Console.WriteLine($"Congratilation, {user.Name}! LogIn is succsesful");
                    break;

                case LogInMenuEnum.Create:
                    Registration();
                    user = new User(Name, Login, Password);
                    UserRepo.Save(user);
                    Console.WriteLine($"Congratilation, {Name}! Registration is succsesful");
                    Console.ReadLine();
                    Console.Clear();
                    goto case LogInMenuEnum.LogIn;

                case LogInMenuEnum.Guest:
                    Console.WriteLine("You enter as a guest");
                    LogIn = true;
                    break;
                }
            }
            Console.ReadLine();
            Console.Clear();
            LogIn = false;
            return((User)user);
        }
        private void FirstPlayerStep()
        {
            Console.WriteLine($"{Player1.Name} Enter the Min board");
            Min = ReadInteger.FromConsole();

            var validatorMin = new ValidatorMin(Min);

            Console.WriteLine($"{Player1.Name} Enter the Max board");
            Max = ReadInteger.FromConsole(validatorMin);

            var validatorMinMax = new ValidatorMinMax(Min, Max);

            Console.WriteLine($"{Player1.Name} Enter the Number");
            player1Number = ReadInteger.FromConsole(validatorMinMax);

            attempCount = AttempCalculator(Min, Max);
        }