using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Plugin.Gen7.Scripts.Status;

namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "nightmare")]
public class Nightmare : Script, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        if (!target.HasStatus(ScriptUtils.ResolveName<Sleep>()))
        {
            move.GetHitData(target, hit).Fail();
            return;
        }
        target.Volatile.Add(new NightmareEffect(target));
    }
}