using PkmnLib.Plugin.Gen7.Scripts.Side;

namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "light_screen")]
public class LightScreen : Script, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        var battleData = move.User.BattleData;
        if (battleData == null)
            return;

        var args = new CustomTriggers.LightScreenNumberOfTurnsArgs(move, 5);
        move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.LightScreenNumberOfTurns, args));
        var turns = args.Duration;

        battleData.BattleSide.VolatileScripts.StackOrAdd(ScriptUtils.ResolveName<LightScreenEffect>(),
            () => new LightScreenEffect(turns));
    }
}