public void Sell() { if (UserItemCatalog.Count == 0) { Console.WriteLine(""); Console.WriteLine("You have no items to sell"); Console.ReadKey(); Shop.Menu(); } var selection = ""; while (string.IsNullOrEmpty(selection)) { Console.WriteLine(""); Console.Write("What would you like to sell? "); selection = Console.ReadLine(); } if (!UserItemCatalog.ContainsKey(selection)) { Console.WriteLine(""); Console.WriteLine("Please provide a valid selection."); Sell(); } //I need to know what type of object the user has selected so I will look //at the first letter of the key (a, w, p) switch (selection.Substring(0, 1)) { case "a": var armor = (Armor)UserItemCatalog[selection]; ArmorsBag.Remove(armor); Gold += armor.ResellValue; Shop.ArmorsList.Add(armor); break; case "w": var weapon = (Weapon)UserItemCatalog[selection]; WeaponsBag.Remove(weapon); Gold += weapon.ResellValue; Shop.WeaponsList.Add(weapon); break; case "p": var potion = (Potion)UserItemCatalog[selection]; PotionsBag.Remove(potion); Gold += potion.ResellValue; Shop.PotionsList.Add(potion); break; default: Shop.Menu(); break; } }
public void EquipArmor() { UserItemCatalog.Clear(); Console.WriteLine(""); Console.WriteLine("*****Armor*****"); var count = 1; foreach (var armor in this.ArmorsBag) { Console.WriteLine($"{count}: {armor.Name} with {armor.Defense} defense"); UserItemCatalog.Add($"{count}", armor); count++; } if (UserItemCatalog.Count == 0) { Console.WriteLine("You have no armor to equip"); Console.ReadKey(); Shop.Menu(); } var selection = ""; while (string.IsNullOrEmpty(selection)) { Console.WriteLine(""); Console.Write("Make a selection: "); selection = Console.ReadLine(); } var intselection = Convert.ToInt32(selection); if (intselection < 1 || intselection > UserItemCatalog.Count) { Console.WriteLine("Please make a valid selection"); EquipArmor(); Console.ReadKey(); } else { var armor = (Armor)UserItemCatalog[selection]; ArmorsBag.Remove(armor); EquippedArmor = armor; Defense += armor.Defense; Game.Main(); } }
public void EquipArmor() { if (EquippedArmor != null) { Console.WriteLine("You don't have any armor"); Console.ReadKey(); ShowInventory(); } MakeYouStrong.Clear(); Console.WriteLine(""); Console.WriteLine("*****Armor*****"); var countArmor = 1; foreach (var a in this.ArmorsBag) { Console.WriteLine($"{countArmor}: {a.Name} with {a.Defense} strength"); MakeYouStrong.Add($"{countArmor}", a); countArmor++; Console.WriteLine("Do you like to equip this armor ? Press 1. to equip"); } if (MakeYouStrong.Count == 0) { Console.WriteLine("You don't have any armor to equip"); ShowInventory(); } else { var selection = Console.ReadLine(); var armor = (Armor)MakeYouStrong[selection]; ArmorsBag.Remove(armor); EquippedArmor = armor; Defense += armor.Defense; Console.WriteLine(""); Console.WriteLine("You are successful to equip this armor"); } }
public void EquipArmor(Armor armor) { if (EquippedArmor == null) { this.EquippedArmor = armor; ArmorsBag.Remove(armor); Defense += armor.Defense; Speed -= armor.Defense; Console.WriteLine($"You Are Now Wearing {armor.Name} For + {armor.OriginalValue} Defense"); Console.WriteLine(); ShowInventory(); } else { Console.WriteLine("You already have a weapon equipped."); Console.WriteLine(); Console.WriteLine("What would you like to do?"); Console.WriteLine("1. Back to Inventory."); Console.WriteLine("2. Continue Adventure."); Console.WriteLine("3. Back To Town."); var input = Console.ReadLine(); if (input == "1") { this.ShowInventory(); } else if (input == "2") { var explore = new Explore(this, Game); explore.Start(); } else if (input == "3") { this.Game.Main(); } } }