using PkmnLib.Plugin.Gen7.Scripts.MoveVolatile;

namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "electrify")]
public class Electrify : Script, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        var choiceQueue = target.BattleData?.Battle.ChoiceQueue;
        if (choiceQueue == null)
            return;

        if (choiceQueue.FirstOrDefault(x => x is IMoveChoice moveChoice && moveChoice.User == target) is not IMoveChoice
            choice)
        {
            move.GetHitData(target, hit).Fail();
            return;
        }

        choice.Volatile.Add(new ElectrifyEffect());
    }
}