using UnityEngine;
using YachtDice.Shop;

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

        [field: Header("Economy")]
        [field: SerializeField] public int ShopPrice { get; private set; }

        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
    }
}
