Пример #1
0
        //Display Hero Inventory
        private void Inventory()
        {
            Hero.ShowInventory();

            Console.WriteLine("1-Equip Weapon");
            Console.WriteLine("2-UnEquip Weapon");
            Console.WriteLine("3-Equip Armor");
            Console.WriteLine("4-UnEquip Armor");
            Console.WriteLine("5-Equip Shield");
            Console.WriteLine("6-UnEquip Shield");

            Console.WriteLine("----------------------------------------------------------------------------------------------");
            Console.Write("Select the menu : ");

            var KeyInput = Console.ReadLine();

            //Equip Weapon
            if (KeyInput == "1")
            {
                var unEquippedWeapons = Hero.GetWeapons().Where(p => p != Hero.EquippedWeapon).ToList();

                for (var i = 0; i < unEquippedWeapons.Count(); i++)
                {
                    Console.WriteLine($"{i + 1} - {unEquippedWeapons[i].Name}");
                }

                Console.Write("Selet the weapon ID : ");
                var index = Hero.GetUserInputNumber() - 1;
                Hero.EquipWeapon(index);
            }

            //Unequip Weapon
            else if (KeyInput == "2")
            {
                Hero.UnEquipWeapon();
            }

            //Equip Armor
            else if (KeyInput == "3")
            {
                var unEquippedArmors = Hero.GetArmors().Where(p => p != Hero.EquippedArmor).ToList();
                for (var i = 0; i < unEquippedArmors.Count(); i++)
                {
                    Console.WriteLine($"{i + 1} - {unEquippedArmors[i].Name}");
                }
                Console.Write("Selet the armor ID : ");
                var index = Hero.GetUserInputNumber() - 1;
                Hero.EquipArmor(index);
            }

            //Unequip Armor
            else if (KeyInput == "4")
            {
                Hero.UnEquipArmor();
            }

            //Equip Shield
            else if (KeyInput == "5")
            {
                var unEquippedShield = Hero.GetShield().Where(p => p != Hero.EquippedShield).ToList();

                for (var i = 0; i < unEquippedShield.Count(); i++)
                {
                    Console.WriteLine($"{i + 1} - {unEquippedShield[i].Name}");
                }

                Console.Write("Selet the shield ID : ");
                var index = Hero.GetUserInputNumber() - 1;
                Hero.EquipShield(index);
            }

            //Unequip Shield
            else if (KeyInput == "6")
            {
                Hero.UnEquipShield();
            }

            Console.WriteLine("Press any key to return to main menu.");
            Console.ReadKey();
        }