using Sirenix.OdinInspector;
using UnityEngine;
using VOID.Generic.Dict;
using VOID.Generic.Objects.Unit;

namespace VOID.Generic.Status.Effect
{
    [TypeRegistryItem("Change Basic Resource - Amount")]
    public class PointChangeBasicResourceEffect : BasicEffect
    {
        public int pointModificator => _pointModificator;
        public BasicResourceType basicResourceType => _basicResourceType;
        [SerializeField, Required] private int _pointModificator;
        [SerializeField, Required] private BasicResourceType _basicResourceType;
        
        public override void OnApply()
        {
            if (forObject is not UnitObject forUnit) return;

            forUnit.unitDataCalculator.Queue(_basicResourceType);
        }

        public override void OnEnd()
        {
            if (forObject is not UnitObject forUnit) return;

            forUnit.unitDataCalculator.Queue(_basicResourceType);
        }

        public override void OnTurnSelfEnd() {}
        public override void OnTurnSelfStart() {}
        public override void OnCancel() => OnEnd();
        
        public sealed override string GetSimpleDescription() => $"{(_pointModificator >= 0f ? "+" : "-")}{Mathf.Abs(_pointModificator)} {_basicResourceType}";
    }
}