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

namespace YachtDice.Modifiers.Effects
{
    [CreateAssetMenu(fileName = "MultiplyScoreEffect", menuName = "YachtDice/Modifiers/Effects/Multiply Score")]
    public class MultiplyScoreEffect : Effect
    {
        [SerializeField] private float multiplier = 1f;

        public override UniTask Apply(ModifierContext context, ModifierInstance instance)
        {
            context.Multiplier *= Mathf.Pow(multiplier, instance.Stacks);
            return UniTask.CompletedTask;
        }

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