Player/Inventory/Container/InventoryItem.cs
namespace Opium;

/// <summary>
/// An instance of an inventory item.
/// </summary>
public partial class InventoryItem
{
	/// <summary>
	/// The item resource
	/// </summary>
	[Property] public InventoryItemResource ItemResource { get; set; }

	/// <summary>
	/// How many of this item are we holding in this slot?
	/// </summary>
	[Property] public int Quantity { get; set; } = 1;

	/// <summary>
	/// Can we accept any more items of the same resource?
	/// </summary>
	public bool IsStackMax => ItemResource.StackSize != 0 && Quantity >= ItemResource.StackSize;

	/// <summary>
	/// Can we stack x more items?
	/// </summary>
	/// <param name="addedQuantity"></param>
	/// <returns></returns>
	public bool CanStack( int addedQuantity )
	{
		if ( (Quantity + addedQuantity) > ItemResource.StackSize )
		{
			return false;
		}

		return true;
	}

	public InventoryItem( InventoryItemResource resource )
	{
		ItemResource = resource;
	}
}