Exemple #1
0
        public override void Show()
        {
            base.Show();
            Console.WriteLine("Enter the name of your Tamagotchi!\n");

            string aName = Console.ReadLine();

            Console.WriteLine("Do you wish to continue? This will kill your current animal if you have one...\nPress any key to continue or Esc to go back");
            if (Console.ReadKey().Key == ConsoleKey.Escape)
            {
                last.Show();
            }
            else
            {
                Task <AnimalDTO> newAnimal = MainApp.api.CreateNewAnimalAsync(aName);
                newAnimal.Wait();
                if (newAnimal.Result == null)
                {
                    throw new InvalidOperationException();
                }

                System.Threading.Thread.Sleep(1000);
                PetHomeMenu next = new PetHomeMenu(last);
                next.Show();
            }
        }
Exemple #2
0
        public override void Show()
        {
            base.Show();
            Console.WriteLine("Please enter your current password");
            string      pass      = Console.ReadLine();
            Task <bool> isCorrect = MainApp.api.CheckPasswordAsync(pass);

            isCorrect.Wait();
            while (!isCorrect.Result)
            {
                Console.WriteLine("Incorrect Password! Try Again");
                pass      = Console.ReadLine();
                isCorrect = MainApp.api.CheckPasswordAsync(pass);
                isCorrect.Wait();
            }

            Console.WriteLine("-New Password-");
            string newPass = Format.GetAndCheckPassword();

            Console.WriteLine("Confirm new Password");
            string confirm = Console.ReadLine();

            while (newPass != confirm)
            {
                Console.WriteLine("Passwords do not match! Try Again.\nEnter Password");
                newPass = Format.GetAndCheckPassword();
                Console.WriteLine("Confirm new Password");
                confirm = Console.ReadLine();
            }

            try
            {
                Task <bool> newPassword = MainApp.api.SetPasswordAsync(newPass);
                newPassword.Wait();
                if (!newPassword.Result)
                {
                    throw new InvalidOperationException();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("There was an error changing the password... Please try again later.\nException: {0}\nInner Exception: {1}", e.Message, e.InnerException.Message);
            }
            last.Show();
        }
        public override void Show()
        {
            base.Show();
            if (MainApp.currentPlayer == null)
            {
                Console.WriteLine("Please enter your username:"******"Please enter your password");
                string           pass = Console.ReadLine();
                Task <PlayerDTO> p    = MainApp.api.LoginAsync(uName, pass);
                p.Wait();
                MainApp.currentPlayer = p.Result;
                //MainApp.currentPlayer = MainApp.db.Login("Mitzi123", "HaHato0l1234123"); //For testing
                if (MainApp.currentPlayer == null)
                {
                    //new ErrorScreen("Incorrect Username or Pass Error", this).Show();
                    Console.WriteLine("Incorrect username or password\nPress any key to try again.");
                    Console.ReadKey();
                    this.Show();
                }
                else
                {
                    next = new UserPageMenu();
                    Console.WriteLine("Login Succesfull!\nPress any key to continue...");
                    Console.ReadKey();
                    next.Show();
                }
            }
            else
            {
                Console.WriteLine("Would like to sign out and re-Login? Y/N");

                bool validChoice = false;
                while (!validChoice)
                {
                    char choice = Console.ReadKey().KeyChar;
                    switch (choice)
                    {
                    case 'y':
                    case 'Y':
                        Task <bool> t = MainApp.api.LogOutAsync();
                        t.Wait();
                        if (t.Result)
                        {
                            MainApp.currentPlayer = null;
                        }
                        else
                        {
                            Console.WriteLine("There was a Problem logging out");
                        }
                        validChoice = true;
                        this.Show();
                        break;

                    case 'n':
                    case 'N':
                        validChoice = true;
                        next        = new UserPageMenu();
                        next.Show();

                        break;

                    default:
                        Console.WriteLine("\nInvalid input! Enter 'Y' for yes, or 'N' for No.");

                        break;
                    }
                }
            }
        }