using System.Diagnostics;
using PkmnLibSharp.FFI;
using PkmnLibSharp.Utils;
using Interface = PkmnLibSharp.FFI.StaticData.Libraries.LibrarySettings;
namespace PkmnLibSharp.StaticData.Libraries
{
///
/// This library holds several misc settings for the library.
///
public class LibrarySettings : ExternPointer
{
public class CacheData
{
public LevelInt? MaxLevel { get; internal set; }
public uint? ShinyRate { get; internal set; }
}
///
/// The highest level a Pokemon can be.
///
/// The chance of a Pokemon being shiny, as the denominator of a fraction, where the nominator
/// is 1. For example, if this is 1000, then the chance of a Pokemon being shiny is 1/1000.
///
public LibrarySettings(LevelInt maxLevel, uint shinyRate)
{
Debug.Assert(maxLevel >= 1);
Debug.Assert(shinyRate >= 1);
InitializePointer(Interface.library_settings_new(maxLevel, shinyRate), true);
}
internal LibrarySettings(IdentifiablePointer ptr, bool isOwner) : base(ptr, isOwner)
{
}
///
/// The highest level a Pokemon can be.
///
public LevelInt MaxLevel => Cache.MaxLevel ??= Interface.library_settings_maximum_level(Ptr);
///
/// The chance of a Pokemon being shiny, as the denominator of a fraction, where the nominator
/// is 1. For example, if this is 1000, then the chance of a Pokemon being shiny is 1/1000.
///
public uint ShinyRate => Cache.ShinyRate ??= Interface.library_settings_shiny_rate(Ptr);
protected override CacheData CreateCache() => new();
protected override void Destructor() => Interface.library_settings_drop(Ptr);
~LibrarySettings()
{
Dispose();
}
}
}