コード例 #1
0
        public Player Authorize()
        {
            Player player = null;

            do
            {
                Console.Clear();
                Console.WriteLine("Do you already have a profile?");
                Console.WriteLine("1.Log in");
                Console.WriteLine("2.Create account");
                switch (Console.ReadKey().Key)
                {
                case ConsoleKey.D1:
                    FillLoginPassword();
                    player = _handler.LogIn(_login, _password);
                    if (_handler.CheckAccessStatus(player) == AccessStatus.Expired)
                    {
                        FillLoginPassword();
                        player = _creator.CreateAccount(_login, _password);
                    }
                    break;

                case ConsoleKey.D2:
                    FillLoginPassword();
                    if ((player = _creator.CreateAccount(_login, _password)) == null)
                    {
                        Console.WriteLine("This account already exist, try again");
                        Console.ReadKey();
                    }
                    break;

                default:
                    break;
                }
            } while (player == null);
            return(player);
        }