using System;
using Sirenix.OdinInspector;
using VOID.ScriptableObjects;

namespace VOID.Generic.Objects.Item
{
    [Serializable]
    [TypeInfoBox("Most values can be changed only in main prefab!")]
    public class ItemObjectData : ObjectComponent<ItemObject>
    {
        [Title("Uniqueness")]
        [EnableIn(PrefabKind.Regular)] public string uniqueId = Guid.NewGuid().ToString();

        [Title("Display in UI")]
        public string finalName => parent.basicData.name + (stackable ? $" ({stackSize})" : "");
        public float finalWeight => stackable ? stackSize * weight : weight;
        public int finalValue => stackable ? stackSize * value : value;

        [Title("Possible actions")]
        [EnableIn(PrefabKind.Regular)] public bool canBePicked = true;
        [EnableIn(PrefabKind.Regular)] public bool canBeMoved = true;

        [Title("Item base stats")]
        [EnableIn(PrefabKind.Regular)] public ItemQuality quality;
        [EnableIn(PrefabKind.Regular), MinValue(0)] public float weight = 1;
        [EnableIn(PrefabKind.Regular), MinValue(0)] public int value = 0;

        [Title("Stacking")]
        [InfoBox("Stackable only available if both items have identical uniqueId.")]
        [EnableIn(PrefabKind.Regular)] public bool stackable = false;
        [ShowIf("stackable"), MinValue(1), MaxValue(nameof(stackSizeMax))] public int stackSize = 1;
        [EnableIn(PrefabKind.Regular), ShowIf("stackable"), MinValue(1)] public int stackSizeMax = 1;
    }
}
