/// <summary> /// Add an Item in the agent inventory /// </summary> public UsableItem AddItemInInventory(AgentInventory inventory, CraftingChoice choice) { UsableItem itemToAdd = GetUsableItemByCraftingChoice(choice); inventory.AddItem(itemToAdd); return(itemToAdd); }
public bool PurchaseItems(EconomyWallet shopAgentWallet, UsableItemDetails itemDetails, EconomyWallet adventurerAgentWallet, AgentInventory inventory) { var price = _stockPrices[itemDetails.itemName]; int GetStock() { return(_shopItems[itemDetails.itemName].Count); } if (adventurerAgentWallet.Money <= price) { Debug.Log("Not enough money : wallet " + adventurerAgentWallet.Money + "- price " + price); return(false); } if (GetStock() <= 0) { Debug.Log("Not enough stock"); return(false); } inventory.AddItem(_shopItems[itemDetails.itemName][0]); _shopItems[itemDetails.itemName].RemoveAt(0); _stockPrices[itemDetails.itemName] = price; if (GetStock() <= 0) { _stockPrices.Remove(itemDetails.itemName); _shopItems.Remove(itemDetails.itemName); _previousPrices[itemDetails.itemName] = price; } adventurerAgentWallet.SpendMoney(price); shopAgentWallet.EarnMoney(price); return(true); }