namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "spite")]
public class Spite : Script, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        var lastMoveChoiceByTarget = target.BattleData?.LastMoveChoice;
        if (lastMoveChoiceByTarget == null || lastMoveChoiceByTarget.HasFailed)
        {
            move.GetHitData(target, hit).Fail();
            return;
        }
        if (!lastMoveChoiceByTarget.ChosenMove.ReduceUses(4))
        {
            move.GetHitData(target, hit).Fail();
        }
    }
}