示例#1
0
        private void equipItem(Equipment item)
        {
            Console.WriteLine();
            Equipment oldItem = eb.GetEquipedByIdAndType(Id, item.Type);

            if (oldItem != null)
            {
                oldItem.Is_equiped = false;
                eb.Update(oldItem);
            }

            item.Is_equiped = true;
            eb.Update(item);

            if (item.Type == "Weapon")
            {
                this.Weapon = item.Id;
            }
            else if (item.Type == "Armor")
            {
                this.Armor = item.Id;
            }

            hb.Update(this);
        }
示例#2
0
        public Hero payingForUpgrade(int weaponNumber, Hero hero, List <Equipment> weaponsInInventory)
        {
            Console.WriteLine("Do you wish to upgrade this weapon for " + weaponsInInventory[weaponNumber].Price + " gold?");
            Console.WriteLine("(Y)es or (N)o");
            Console.WriteLine("(Q)uit to show");

            string command = Console.ReadLine().ToLower();

            if (command == "n")
            {
                Console.Clear();
                hero = showForgeOptions(hero);
            }
            else if (command == "y" && (int)hero.Money >= (int)weaponsInInventory[weaponNumber].Price / 2)
            {
                Console.Clear();
                hero.Money -= (int)weaponsInInventory[weaponNumber].Price / 2;
                weaponsInInventory[weaponNumber].Points += 1 + (int)Math.Ceiling((double)weaponsInInventory[weaponNumber].Points / 3);
                weaponsInInventory[weaponNumber].Name    = weaponsInInventory[weaponNumber].Name.Trim() + "*";
                weaponsInInventory[weaponNumber].Price  *= 2;
                Console.WriteLine("You upgraded your weapon!");
                Console.WriteLine("Current money balance: " + hero.Money);
                Console.WriteLine();


                eb.Update(weaponsInInventory[weaponNumber]);
                hb.Update(hero);

                hero = showForgeOptions(hero);
            }
            else if (command == "y" && hero.Money < weaponsInInventory[weaponNumber].Price / 2)
            {
                Console.Clear();
                Console.WriteLine("You don't have enough money for this action!");
                Console.WriteLine();
                hero = showForgeOptions(hero);
            }
            else if (command == "q")
            {
                return(hero);
            }

            return(hero);
        }