Exemple #1
0
        private void ShowPotions()
        {
            var count = 1;

            PotionCatalog.Clear();

            Console.WriteLine("*** Potions List ***");
            Console.WriteLine($"#   Potion Name            S    OV   SV");
            foreach (var potion in PotionList.OrderBy(x => x.Name))
            {
                Console.WriteLine($"p{count}. {potion.Name, -20} {potion.Hp, 3} {potion.OriginalValue, 4:C0} {potion.ResellValue, 4:C0}");
                PotionCatalog.Add($"p{count}", potion);
            }
        }
Exemple #2
0
 private void LoadPotions()
 {
     PotionList.Add(new Potion("Healing Potion", 5, 5, 1));
 }
Exemple #3
0
        private void ExecutePuchase()
        {
            var pick = "";

            do
            {
                Console.WriteLine($"\nWhich item would you like to purchase?");
                Console.WriteLine($"Type E if you do not wish to purch anything at this time.");
                pick = Console.ReadLine();
            } while (pick.Length <= 0);

            var weapon = new Weapon();
            var armor  = new Armor();
            var potion = new Potion();

            switch (pick.Substring(0, 1).ToLower())
            {
            case "w":

                if (WeaponCatalog.TryGetValue(pick.Substring(0, 2), out weapon))
                {
                    if (Hero.Gold >= weapon.OriginalValue)
                    {
                        Hero.Gold -= weapon.OriginalValue;
                        Hero.WeaponsBag.Add(weapon);
                        WeaponList.Remove(weapon);
                        Console.WriteLine($"Hero just purchased {weapon.Name}!");
                    }
                    else
                    {
                        Console.WriteLine($"You do not have enough Gold to purchase {weapon.Name}");
                        Console.WriteLine($"{weapon.Name} costs {weapon.OriginalValue}, you only have {Hero.Gold -4:C0}");
                    }
                }
                else
                {
                    Console.WriteLine($"Item {pick} does not exist...");
                }

                break;

            case "a":

                if (ArmorCatalog.TryGetValue(pick.Substring(0, 2), out armor))
                {
                    if (Hero.Gold >= armor.OriginalValue)
                    {
                        Hero.Gold -= armor.OriginalValue;
                        Hero.ArmorsBag.Add(armor);
                        ArmorList.Remove(armor);
                        Console.WriteLine($"Hero just purchased {armor.Name}!");
                    }
                    else
                    {
                        Console.WriteLine($"You do not have enough Gold to purchase {armor.Name}");
                        Console.WriteLine($"{armor.Name} costs {armor.OriginalValue}, you only have {Hero.Gold -4:C0}");
                    }
                }
                else
                {
                    Console.WriteLine($"Item {pick} does not exist...");
                }

                break;

            case "p":

                if (PotionCatalog.TryGetValue(pick.Substring(0, 2), out potion))
                {
                    if (Hero.Gold >= potion.OriginalValue)
                    {
                        Hero.Gold -= potion.OriginalValue;
                        Hero.PotionBag.Add(potion);
                        PotionList.Remove(potion);
                        Console.WriteLine($"Hero just purchased {potion.Name}!");
                    }
                    else
                    {
                        Console.WriteLine($"You do not have enough Gold to purchase {potion.Name}");
                        Console.WriteLine($"{potion.Name} costs {potion.OriginalValue}, you only have {Hero.Gold - 4:C0}");
                    }
                }
                else
                {
                    Console.WriteLine($"Item {pick} does not exist...");
                }

                break;

            case "e":
                Console.Clear();
                this.ShopMenu();
                break;

            default:
                Console.WriteLine($"Item {pick} does not exist...");
                break;
            }
        }