using System;
using System.Diagnostics.CodeAnalysis;
using Godot;
namespace ColdMint.scripts.item;
///
/// Item stack in an inventory slot
///
public interface IItemStack
{
///
/// ID of items inside current stack
///
string Id { get; }
///
/// Max number of current stack
///
int MaxQuantity { get; }
///
/// Quantity of current stack
///
int Quantity { get; }
///
/// Icon of current item
///
Texture2D Icon { get; }
///
/// Display name of current item
///
string Name { get; }
///
/// Description of current item, which may show in inventory
///
string? Description { get; }
///
/// Determine whether a specified item can be accommodated
/// 判断能否容纳指定物品
///
///
public bool CanAddItem(IItem_New item);
///
/// Hold a given item
///
/// Item to hold by current stack
/// Whether successful
public bool AddItem(IItem_New item);
///
/// 判断能从指定物品堆中接收的物品数量
///
///
/// 向该物品堆中放入物品的物品堆
/// Item stack to add to the current stack
///
///
public int CanTakeFrom(IItemStack itemStack);
///
/// 将指定物品堆中尽可能多的物品移动至当前物品堆中,被移入当前堆的物品应从原物品堆中移除。
///
///
/// 被移入当前堆的物品堆
///
///
/// 操作结束后原物品堆是否为空
///
public bool TakeFrom(IItemStack itemStack);
///
/// Get item instance at the top of current stack without removing it from stack
/// 获取当前物品堆顶部的物品实例而不取出该物品
///
///
///
public IItem_New? GetItem();
///
/// Pop the item instance at the top of current item stack and return it
/// 取出当前物品堆顶部的物品实例并返回该物品
///
///
///
public IItem_New? PickItem();
///
/// Remove the specified number of items and return them as a new item stack
/// 取出当前堆中指定数量的物品,并作为新的物品堆返回
///
///
///
/// Quantity to be taken out, inputs below zero represent all items
/// 要取出的数量,小于0的输入代表全部物品
///
///
/// The item stack that is taken out, can be null if out nothing, should not be the current item stack itself
/// 取出的物品堆,没有取出物品时可为null,不应是当前物品堆自身
///
public IItemStack? PickItems(int value);
///
///
/// Removes the specified number of items from current item stack,removed items should be removed from the game
/// If you don't want remove them from game, consider and
///
///
/// 在当前物品堆移除指定数量的物品,被移除的物品应当从游戏中移除。
/// 如果您并不打算将它们从游戏中移除,请考虑使用 和
///
///
///
/// Quantity to be removed, inputs below zero represent all items
/// 要删除的数量,小于0的输入代表全部物品
///
///
/// The remaining number, if the number of items in the current item stack is less than the specified number. Otherwise,0
/// 若物品槽内物品少于指定的数量,返回相差的数量。否则返回0
///
public int RemoveItem(int number);
///
/// Clear current stack, which means should dispose all items inside current stack here
///
public void ClearStack();
///
/// Create a new ItemStack with the given item as the first item
///
public static IItemStack FromItem(IItem_New item) => ItemTypeManager.MaxStackQuantityOf(item.Id) switch
{
1 => new SingleItemStack(item),
> 1 => throw new NotImplementedException(),
var other => throw new ArgumentException($"item {item} of type '{item.Id}' has unexpected max stack quantity {other}")
};
}