using PkmnLib.Plugin.Gen7.Scripts.Pokemon;

namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "magnet_rise")]
public class MagnetRise : Script, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        if (move.User.Volatile.Contains(ScriptUtils.ResolveName<IngrainEffect>()) ||
            move.User.ActiveAbility?.Name == "levitate")
        {
            move.GetHitData(target, hit).Fail();
            return;
        }
        move.User.Volatile.Add(new MagnetRiseEffect());
    }
}