Exemplo n.º 1
0
        public void SellItem()
        {
            HeroBox.Clear();
            Console.WriteLine("");
            Console.WriteLine("Please make sure you have some item to sell");

            HeroBag();

            var input = "";

            Console.Write("Enter the code of the item you would like to sell.");

            input = Console.ReadLine();
            if (HeroBox.ContainsKey(input))
            {
                if (input.Substring(0, 1) == "A")
                {
                    var armor = (Armor)HeroBox[input];

                    Hero.Gold += armor.ResellValue;
                    Hero.ArmorsBag.Remove(armor);
                    this.Armors.Add(armor);
                    Console.WriteLine("");
                    Console.WriteLine($"You get {armor.ResellValue} gold from {armor.Name}");
                    Hero.ShowInventory();
                    Menu();
                }
                else if (input.Substring(0, 1) == "W")
                {
                    var weapon = (Weapon)HeroBox[input];

                    Hero.Gold += weapon.ResellValue;
                    Hero.WeaponsBag.Remove(weapon);
                    this.Weapons.Add(weapon);
                    Console.WriteLine("");
                    Console.WriteLine($"You get {weapon.ResellValue} gold from {weapon.Name}");
                    Hero.ShowInventory();
                    Menu();
                }
                else if (input.Substring(0, 1) == "P")
                {
                    var potion = (Potion)HeroBox[input];

                    Hero.Gold += potion.ResellValue;
                    Hero.PotionsBag.Remove(potion);
                    this.Potions.Add(potion);
                    Console.WriteLine("");
                    Console.WriteLine($"You get {potion.ResellValue} gold from {potion.Name}");
                    Hero.ShowInventory();
                    Menu();
                }
            }
            else if (!NameItemList.ContainsKey(input))
            {
                Console.WriteLine("You don't have that items or item number is wrong");
                Menu();
            }
        }
Exemplo n.º 2
0
        public void BuyItem()
        {
            var selection = "";

            Console.WriteLine("Enter the keyword of item you want to buy");
            selection = Console.ReadLine();

            if (NameItemList.ContainsKey(selection))
            {
                Pay(selection);
            }
            else if (!NameItemList.ContainsKey(selection))
            {
                Console.WriteLine("Your keyword item or number is wrong !!!");
                Menu();
            }
        }
Exemplo n.º 3
0
        public void ShowInventory()
        {
            NameItemList.Clear();
            Console.WriteLine("");
            Console.WriteLine("Here's all the stuff I have for sale.");

            Console.WriteLine("");
            Console.WriteLine("Weapons List");
            var countWeapon = 1;

            foreach (var W in this.Weapons.OrderBy(x => x.Name))
            {
                Console.WriteLine($"W{countWeapon}: {W.Name} have {W.Strength} Strength sell for {W.OriginalValue} gold");
                NameItemList.Add($"W{countWeapon}", W);
                countWeapon++;
            }

            Console.WriteLine("");
            Console.WriteLine("Armors List");
            var countArmor = 1;

            foreach (var A in this.Armors.OrderBy(x => x.Name))
            {
                Console.WriteLine($"A{countArmor}: {A.Name} have {A.Defense} Defense sell for {A.OriginalValue} gold");
                NameItemList.Add($"A{countArmor}", A);
                countArmor++;
            }

            Console.WriteLine("");
            Console.WriteLine("Potions List");
            var countPotion = 1;

            foreach (var P in Potions.OrderBy(x => x.Name))
            {
                Console.WriteLine($"P{countPotion}: {P.Name} contain {P.HP} hp for {P.OriginalValue} gold");
                NameItemList.Add($"P{countPotion}", P);
                countPotion++;
            }
            Console.WriteLine("");
            BuyItem();
        }