public Inventory Remove(Potion w) { if (Potions.Contains(w)) { Potions.Remove(w); } return(this); }
public void Pay(string selection) { if (selection.Substring(0, 1) == "W") { var weapon = (Weapon)NameItemList[selection]; if (Hero.Gold >= weapon.OriginalValue) { Hero.Gold -= weapon.OriginalValue; Weapons.Remove(weapon); Hero.WeaponsBag.Add(weapon); Console.WriteLine($"You spent {weapon.OriginalValue} gold for a {weapon.Name}"); Menu(); } else { Console.WriteLine($"NO gold , No sell"); Menu(); } } else if (selection.Substring(0, 1) == "A") { var armor = (Armor)NameItemList[selection]; if (Hero.Gold >= armor.OriginalValue) { Hero.Gold -= armor.OriginalValue; Armors.Remove(armor); Hero.ArmorsBag.Add(armor); Console.WriteLine($"You spent {armor.OriginalValue} gold for a {armor.Name}"); Menu(); } else { Console.WriteLine($"NO gold , No sell"); Menu(); } } else if (selection.Substring(0, 1) == "P") { var potion = (Potion)NameItemList[selection]; if (Hero.Gold >= potion.OriginalValue) { Hero.Gold -= potion.OriginalValue; Potions.Remove(potion); Hero.PotionsBag.Add(potion); Console.WriteLine($"You spent {potion.OriginalValue} gold for a {potion.Name}"); Menu(); } else { Console.WriteLine($"NO gold , No sell"); Menu(); } } }
/// <summary> /// Drink Potion is a method that is specific to heros. I did not inherit it from Character. Therefore I don't need the override keyword. /// Also, I don't want to rewrite this method for every single class that inherits from hero, so I am making one to rule them all here. /// </summary> public void DrinkPotion(PotionName PotionName) { Potion p = Potions.Where(p => p.Name == PotionName).FirstOrDefault(); p.Drink(Name); // Potions give you a health boost. So make sure to increase your health bar! HealthBar += p.HealthBoostAmount; // Potions are a one time use, so remove it from your list of potions Potions.Remove(p); }
public void RemoveItem(Potion potion) => Potions.Remove(potion);
public void deleteRecipe(Recipe r) { Recipes.Remove(r); Potions.Remove(getPotionByName(r.RPotionName)); }
public void deletePotion(Potion p) { Potions.Remove(p); }