using Cysharp.Threading.Tasks;
using UnityEngine;
using YachtDice.Modifiers.Core;
using YachtDice.Modifiers.Definition;
using YachtDice.Modifiers.Runtime;

namespace YachtDice.Modifiers.Effects
{
    [CreateAssetMenu(fileName = "ConsumeChargeEffect", menuName = "YachtDice/Modifiers/Effects/Consume Charge")]
    public class ConsumeChargeEffect : Effect
    {
        [SerializeField] private int charges = 1;

        public override UniTask Apply(ModifierContext context, ModifierInstance instance)
        {
            instance.ConsumeCharge(charges);
            return UniTask.CompletedTask;
        }

#if UNITY_EDITOR
        public static ConsumeChargeEffect CreateForTest(int charges = 1,
            ModifierPhase phase = ModifierPhase.SideEffect, int priority = 100)
        {
            var so = CreateInstance<ConsumeChargeEffect>();
            so.charges = charges;
            so.SetPhaseForTest(phase);
            so.SetPriorityForTest(priority);
            return so;
        }
#endif
    }
}
