コード例 #1
0
        public static void Start()
        {
            Console.Title = "Fantasy RPG";
            List <Merchant> equipment = Armor.StarterArmor();
            List <Merchant> weapon    = Weapons.AddWeapon();
            List <Merchant> armor     = Armor.AddArmor();
            List <Merchant> items     = Items.AddItems();
            List <Merchant> food      = Inn.AddFood();
            Hero            hero      = CreateHero(equipment, armor);

            bool activeGame = false;

            do
            {
                Console.WriteLine("\n**************************************\n" +
                                  "* 1. Go Adventuring\n" +
                                  "* 2. Show details about your character\n" +
                                  "* 3. Rest at the Inn\n" +
                                  "* 4. Visit shop\n" +
                                  "* 5. Exit\n" +
                                  "**************************************\n");
                Console.Write(">> ");
                Console.ForegroundColor = ConsoleColor.Cyan;
                string menuChoice = Console.ReadLine();
                Console.ResetColor();

                switch (menuChoice)
                {
                case "1":     // hero enters battle phase , returns boolean which if player dies ends game
                    activeGame = HeroMethods.Battle(hero);
                    break;

                case "2":     //prints Hero stats and current equipment from ToString in Hero
                    Console.WriteLine(hero);
                    break;

                case "3":     //Allows hero to rest at in exchange for gold, this heals the player to full health
                    Inn.VisitInn(hero, food);
                    break;

                case "4":     //Enters shop, where all equipment is located, when purchased items are auto equipped.
                    Merchant.ItemShop(hero, items, armor, weapon, equipment);
                    break;

                case "5":     // quits game
                    activeGame = true;
                    break;
                }
                if (hero.lvl >= 10)
                {
                    Console.WriteLine("You are a true hero! You win!");
                    activeGame = true;
                }
            } while (!activeGame);
        }
 private void HandleArmorEffects(GameStatEffect[] gameStatEffects)
 {
     armor.AddArmor(armor.ArmorAbsorption);
 }