namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "burn_up")]
public class BurnUp : Script, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        var battleData = move.User.BattleData;
        if (battleData == null)
            return;
        var typeLibrary = battleData.Battle.Library.StaticLibrary.Types;
        if (!typeLibrary.TryGetTypeIdentifier("fire", out var fireType))
            return;
        if (!move.User.Types.Contains(fireType))
        {
            move.GetHitData(target, hit).Fail();
            return;
        }

        if (move.User.HasStatus("frozen"))
            move.User.ClearStatus();
        move.User.RemoveType(fireType);
    }
}