using Set.Data;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

namespace UI
{
    public class ChampionBaseUI : MonoBehaviour
    {
        [SerializeField]
        private Text _championNameText;

        [SerializeField]
        private Toggle _championToggle;

        private ChampionsEnum _championType;
        private bool _defaultSelected = false;

        public ChampionsEnum ChampionType => _championType;
        public bool IsSelected => _championToggle != null ? _championToggle.isOn : false;

        public void Initialize(
            ChampionsEnum championType,
            string championDisplayName,
            bool defaultSelected = false
        )
        {
            _championType = championType;
            _championNameText.text = championDisplayName;
            _defaultSelected = defaultSelected;

            // Set default selection state
            if (_championToggle != null)
                _championToggle.isOn = defaultSelected;
        }

        public void SetSelected(bool selected)
        {
            if (_championToggle != null)
                _championToggle.isOn = selected;
        }

        public void ResetToDefault()
        {
            if (_championToggle != null)
                _championToggle.isOn = _defaultSelected;
        }

        public void SetInteractable(bool interactable)
        {
            if (_championToggle != null)
                _championToggle.interactable = interactable;
        }
    }
}
