using UnityEngine;
using YachtDice.Shop;

namespace YachtDice.Dice
{
    /// <summary>
    /// Абстрактное определение типа дайса.
    /// Наследники описывают конкретные виды (стандартный d6, специальные и т.д.).
    /// </summary>
    public abstract class DieDefinitionSO : ScriptableObject, IShopItem
    {
        [Header("Identity")]
        [SerializeField] private string id;
        [SerializeField] private string displayName;
        [SerializeField, TextArea] private string description;
        [SerializeField] private Sprite icon;

        [Header("Economy")]
        [SerializeField] private int shopPrice;

        public string Id => id;
        public string DisplayName => displayName;
        public string Description => description;
        public Sprite Icon => icon;
        public int ShopPrice => shopPrice;
        public bool IsRepurchasable => false;

        /// <summary>Количество граней.</summary>
        public abstract int FaceCount { get; }

        /// <summary>Возвращает массив всех возможных значений граней.</summary>
        public abstract int[] GetFaceValues();

#if UNITY_EDITOR
        public static T CreateForTest<T>(string id, string displayName = null,
            int shopPrice = 0, string description = null) where T : DieDefinitionSO
        {
            var so = CreateInstance<T>();
            so.id = id;
            so.displayName = displayName ?? id;
            so.description = description ?? id;
            so.shopPrice = shopPrice;
            return so;
        }
#endif
    }
}
