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

namespace YachtDice.Modifiers.Effects
{
    [CreateAssetMenu(fileName = "AddFlatScoreEffect", menuName = "YachtDice/Modifiers/Effects/Add Flat Score")]
    public class AddFlatScoreEffect : Effect
    {
        [SerializeField] private int value;

        public override UniTask Apply(ModifierContext context, ModifierInstance instance)
        {
            context.FlatBonus += value * instance.Stacks;
            return UniTask.CompletedTask;
        }

#if UNITY_EDITOR
        public static AddFlatScoreEffect CreateForTest(int value, ModifierPhase phase = ModifierPhase.Additive, int priority = 0)
        {
            var so = CreateInstance<AddFlatScoreEffect>();
            so.value = value;
            so.SetPhaseForTest(phase);
            so.SetPriorityForTest(priority);
            return so;
        }
#endif
    }
}
