예제 #1
0
        // User selects enchant
        private void EnchantmentOption()
        {
            ObjectMenu <WeaponEnchantment> menu =
                new ObjectMenu <WeaponEnchantment>(shop.Enchantments, Status);
            WeaponEnchantment enchantment = menu.Run();

            if (enchantment != null)
            {
                if (enchantment.Cost <= player.Gold)
                {
                    ObjectMenu <Weapon> weaponMenu = new ObjectMenu <Weapon>(player.Inventory.Weapons, "Select weapon to enchant");
                    Weapon weapon = weaponMenu.Run();
                    if (weapon != null)
                    {
                        player.RemoveGold(enchantment.Cost);
                        weapon.AddEnchantment(enchantment);
                    }
                }
                else
                {
                    Console.WriteLine(INSUFFCIENT_FUNDS_PROMPT);
                }
            }

            this.Run(); // Run this menu again
        }
예제 #2
0
        // User selects potions
        private void PotionOption()
        {
            ObjectMenu <Potion> menu = new ObjectMenu <Potion>(player.Inventory.Potions, Status);
            Potion potion            = menu.Run();

            if (potion != null)
            {
                player.Inventory.RemoveItem(potion);
                player.AddGold(potion.Cost);
            }
            this.Run();
        }
예제 #3
0
        // User selects armours
        private void ArmourOption()
        {
            ObjectMenu <Armour> menu = new ObjectMenu <Armour>(player.Inventory.Armours, Status);
            Armour armour            = menu.Run();

            if (armour != player.EquippedArmour)
            {
                player.Inventory.RemoveItem(armour);
                player.AddGold(armour.Cost);
            }
            else
            {
                Console.WriteLine(EQUIPPED_ITEM_ERROR); // user has the item equipped
            }
            this.Run();                                 // run the menu again
        }
예제 #4
0
        // User selects weapons
        private void WeaponOption()
        {
            ObjectMenu <Weapon> menu = new ObjectMenu <Weapon>(player.Inventory.Weapons, Status);
            Weapon weapon            = menu.Run();

            if (weapon != player.EquippedWeapon)
            {
                player.Inventory.RemoveItem(weapon);
                player.AddGold(weapon.Cost);
            }
            else
            {
                Console.WriteLine(EQUIPPED_ITEM_ERROR); // If the item is equipped
            }
            this.Run();                                 // Run the menu again
        }
예제 #5
0
        // User selects Potions
        private void PotionOption()
        {
            ObjectMenu <Potion> menu = new ObjectMenu <Potion>(shop.Potions, Status);
            Potion potion            = menu.Run();

            if (potion != null)
            {
                if (potion.Cost <= player.Gold)
                {
                    player.RemoveGold(potion.Cost);
                    player.Inventory.AddItem(potion.Clone());
                }
                else
                {
                    Console.WriteLine(INSUFFCIENT_FUNDS_PROMPT);
                }
            }
            this.Run(); // Run the menu again
        }
예제 #6
0
        // User selects Armours
        private void ArmourOption()
        {
            ObjectMenu <Armour> menu = new ObjectMenu <Armour>(shop.Armours, Status);
            Armour armour            = menu.Run();

            if (armour != null)
            {
                if (armour.Cost <= player.Gold)
                {
                    player.RemoveGold(armour.Cost);
                    player.Inventory.AddItem(armour.Clone());
                }
                else
                {
                    Console.WriteLine(INSUFFCIENT_FUNDS_PROMPT);
                }
            }
            this.Run(); // Run the menu again
        }
예제 #7
0
        // User selects use potion
        public void UsePotion()
        {
            Potion potion = new ObjectMenu <Potion>(player.Inventory.Potions, "Select Potion").Run();

            if (potion != null)
            {
                Character character = new ObjectMenu <Character>(new List <Character> {
                    player, enemy
                }, "Select character to effect").Run();
                if (character != null)
                {
                    potion.Use(character);
                    player.Inventory.RemoveItem(potion);
                    Console.WriteLine(player.Name + " used " + potion + " on " + character.Name);
                }
            }
            else
            {
                this.Run(); // If the user goes back
            }
        }
예제 #8
0
        // Generic Item picker returns the item user selects
        private E ChooseItem <E>(List <E> list, string prompt) where E : Item
        {
            ObjectMenu <E> m = new ObjectMenu <E>(list, prompt);

            return(m.Run());
        }