using PkmnLib.Plugin.Gen7.Scripts.Pokemon;

namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "beak_blast")]
public class BeakBlast : Script, IScriptOnBeforeTurnStart, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void OnBeforeTurnStart(ITurnChoice choice)
    {
        var battleData = choice.User.BattleData;
        if (battleData == null)
            return;
        choice.User.Volatile.Add(new BeakBlastEffect());
        battleData.Battle.EventHook.Invoke(new DialogEvent("beak_blast_charge", new Dictionary<string, object>
        {
            { "user", choice.User },
        }));
    }

    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        move.User.Volatile.Remove(ScriptUtils.ResolveName<BeakBlastEffect>());
    }
}