public void removeFromInventory(Entity entity) { entityContainer.removeEntitybyName(entity.name); // Updating inventory's current weight Iweight iweight = (Iweight)entity; currentWeight -= iweight.getWeightValue(); }
public void buyShop(Iprice iprice) { // Check if item is in shop Entity itemToBuy = (Entity)iprice; bool isInShop = entityContainer.checkIfInList(itemToBuy.name); // Add to inventory if (isInShop == true) { //Console.WriteLine(itemToBuy.name + " is in shop."); // Check if enough money if (inventory.money >= iprice.getPriceValue() && inventory.checkWeightLimit((Iweight)itemToBuy) == true) { Console.WriteLine(itemToBuy.name + " bought from shop for " + iprice.getPriceValue() + " gold coins."); inventory.add(itemToBuy); // Remove from shop entityContainer.removeEntitybyName(itemToBuy.name); inventory.money -= iprice.getPriceValue(); } else { Console.WriteLine("You don't have enough money to buy" + itemToBuy.name); return; } } else { Console.WriteLine(itemToBuy.name + " not in shop."); } }