public override void doAction() { if (entityContainer.entities.Count == 0) { Console.WriteLine("The " + entityContainerOwner.name + " is empty."); } else { Console.WriteLine(""); Console.WriteLine("The " + entityContainerOwner.name + " includes:"); foreach (Entity entity in entityContainer.entities) { if (!(entity is Iweight) && !(entity is Iprice)) { Console.WriteLine(" >> " + entity.name); } else { Iweight iweight = (Iweight)entity; Iprice iprice = (Iprice)entity; Console.WriteLine(" >> " + entity.name + " price :" + iprice.getPriceValue() + " weight:" + iweight.getWeightValue()); } } } }
public void sellShop(Iprice iprice) { // Check if item is in shop Entity itemToSell = (Entity)iprice; bool isInInventory = inventory.entityContainer.checkIfInList(itemToSell.name); if (isInInventory == true) { Console.WriteLine(itemToSell.name + " sold to shop for " + iprice.getPriceValue() + " gold coins."); // remove from inventory inventory.removeFromInventory(itemToSell); // Add to shop entityContainer.AddEntity(itemToSell); // Give to money to the player inventory.money += iprice.getPriceValue(); } }
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."); } }
public Buy(GameManager _gameManager, Iprice _iprice) { gameManager = _gameManager; iprice = _iprice; }