using PkmnLib.Plugin.Gen7.Scripts.Pokemon;

namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "heal_bell")]
public class HealBell : Script, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        var party = move.User.BattleData?.Battle.Parties.FirstOrDefault(p => p.Party.Contains(target));
        if (party == null)
            return;

        foreach (var pokemon in party.Party.WhereNotNull())
        {
            pokemon.ClearStatus();
            var confusion = ScriptUtils.ResolveName<Confusion>();
            if (pokemon.Volatile.Contains(confusion))
                pokemon.Volatile.Remove(confusion);
        }
    }
}