using PkmnLib.Plugin.Gen7.Scripts.Pokemon;

namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "bind")]
public class Bind : Script, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        var args = new CustomTriggers.ModifyBindArgs(move);
        move.User.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyBind, args));

        var bindTurns = args.Duration;
        var bindDamage = args.DamagePercent;

        var bindEffect = new BindEffect(target, bindTurns, bindDamage);
        target.Volatile.Add(bindEffect);
    }
}