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

namespace YachtDice.Modifiers.Effects
{
    [CreateAssetMenu(fileName = "AddCurrencyEffect", menuName = "YachtDice/Modifiers/Effects/Add Currency")]
    public class AddCurrencyEffect : Effect
    {
        [SerializeField] private int amount;

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

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