using System; using System.Diagnostics; using JetBrains.Annotations; using PkmnLibSharp.FFI; using PkmnLibSharp.Utils; using Interface = PkmnLibSharp.FFI.StaticData.Libraries.GrowthRateLibrary; namespace PkmnLibSharp.StaticData.Libraries { public class GrowthRateLibrary : ExternPointer { public GrowthRateLibrary(ulong capacity) : base(Interface.growth_rate_library_new(capacity), true) { } internal GrowthRateLibrary(IdentifiablePointer ptr, bool isOwner) : base(ptr, isOwner) { } [MustUseReturnValue] public LevelInt CalculateLevel(string growthRate, uint experience) => Interface.growth_rate_library_calculate_level(Ptr, growthRate.ToPtr(), experience); [MustUseReturnValue] public uint CalculateExperience(string growthRate, LevelInt level) { Debug.Assert(level >= 1); return Interface.growth_rate_library_calculate_experience(Ptr, growthRate.ToPtr(), level); } public void AddGrowthRate(string name, GrowthRate growthRate) => Interface.growth_rate_library_add_growth_rate(Ptr, name.ToPtr(), growthRate.TakeOwnershipAndInvalidate()); protected override object CreateCache() => new(); protected override void Destructor() => Interface.growth_rate_library_drop(Ptr); ~GrowthRateLibrary() { Dispose(); } } }