Ejemplo n.º 1
0
        private void Login()
        {
            if (Players?.Count == 0)
            {
                Console.WriteLine("There is no registered players in platform.");
                return;
            }
            while (true)
            {
                Console.Write("Enter your login -> ");
                string login = Console.ReadLine();
                foreach (var player in Players)
                {
                    if (player.Email == login)
                    {
                        ActivePlayer = player;
                        break;
                    }
                }
                if (ActivePlayer != null)
                {
                    break;
                }
                Console.WriteLine($"There is no such player with login {login}");
            }
            Console.Write("Enter your password -> ");
            while (!ActivePlayer.IsPasswordValid(Console.ReadLine()))
            {
                Console.Write("Invalid password. Try again -> ");
            }

            Console.WriteLine($"Welcome, {ActivePlayer.FirstName} {ActivePlayer.LastName}!");
        }