public bool Sell(ItemID commodityID, int count, Player seller, Inventory inventory) { if (catalog.Find(x => x.item.id == commodityID).Sell(count, seller, inventory)) { OnCommodityChange?.Invoke(); return true; } else { return false; } }
public bool Purchase(int count, Player customer, Inventory inventory) { lock(this) { int cost = price * count; if (stock >=count && customer.SpendMoney(cost)) { stock -= count; return inventory.Stack(item.Instantiate(count) as Item); } else { return false; } } }
public bool Sell(int count, Player seller ,Inventory inventory) { lock(this) { if (inventory.Sum(x=>(x.id == item.id)?x.itemCount:0) >= count && stock + count <= maxStock) { inventory.Consume(item.Instantiate(count) as Item); stock += count; seller.GetMoney(price * count); return true; } else { return false; } } }