示例#1
0
        static void UserUI(User user)
        {
            while (true)
            {
                Console.WriteLine($"Select: \n 1.Pick Character \n 2.Create Character \n 3.Log Out");
                switch (Console.ReadLine())
                {
                case "1":
                    user.ListCharacters();
                    Character picked = PickCharacter(user);
                    if (picked.GetHealth() > 0)
                    {
                        Console.WriteLine("Event 1");
                        Console.WriteLine("Bandits attack you from nowhere. They seem vey dangerous");
                        picked = GamePlayEvent2(picked, 20);
                    }
                    else
                    {
                        Console.WriteLine("CHaracter is DEAD!");
                        break;
                    }

                    if (picked.GetHealth() > 0)
                    {
                        Console.WriteLine("Event 2");
                        Console.WriteLine("You go back to the village");
                        Console.WriteLine("You bump the Guard he attacks");
                        picked = GamePlayEvent2(picked, 30);
                    }
                    else
                    {
                        Console.WriteLine($"Game Over ");
                        break;
                    }
                    if (picked.GetHealth() > 0)
                    {
                        Console.WriteLine("Event 3");
                        Console.WriteLine("As you were walking around a land SHARK starts to chase you");
                        picked = GamePlayEvent2(picked, 50);
                    }
                    else
                    {
                        Console.WriteLine($"Game Over ");
                        break;
                    }
                    if (picked.GetHealth() > 0)
                    {
                        Console.WriteLine("Event 4");
                        Console.WriteLine("You accidentally step on a rat. His friends are not happy. They attack...");
                        picked = GamePlayEvent2(picked, 10);
                    }
                    else
                    {
                        Console.WriteLine($"Game Over ");
                        break;
                    }
                    if (picked.GetHealth() > 0)
                    {
                        Console.WriteLine("Event 5");
                        Console.WriteLine("You find a huge rock. It comes alive somehow and tries to smash you..");
                        picked = GamePlayEvent2(picked, 30);
                    }
                    else
                    {
                        Console.WriteLine($"Game Over ");
                        break;
                    }
                    if (picked.GetHealth() > 0)
                    {
                        Console.BackgroundColor = ConsoleColor.Yellow;
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("CONGRATULATIONS YOU HAVE COMPLETED ALL THE CHALLENGES");
                        Console.BackgroundColor = ConsoleColor.White;
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("Go again?  (press Y to go again)");
                        switch (Console.ReadLine())
                        {
                        case "y":
                        case "Y":
                            continue;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        Console.WriteLine("GAME OVER");
                    }

                    break;

                case "2":
                    Character createNew = createNewChar();
                    Console.WriteLine($"Created {createNew.GetInfo()}");
                    user.CreateCharacter(createNew);
                    continue;

                case "3":
                    Console.WriteLine("LogOut");
                    break;

                default:
                    continue;
                }
                break;
            }
        }