PkmnLibRSharp/PkmnLibRSharp/StaticData/Libraries/LibrarySettings.cs

40 lines
1.7 KiB
C#
Raw Normal View History

2023-04-15 07:58:21 +00:00
using System.Diagnostics;
2022-10-08 11:42:30 +00:00
using PkmnLibSharp.FFI;
2022-10-01 13:39:33 +00:00
using PkmnLibSharp.Utils;
using Interface = PkmnLibSharp.FFI.StaticData.Libraries.LibrarySettings;
namespace PkmnLibSharp.StaticData.Libraries
{
2023-04-15 07:58:21 +00:00
/// <summary>
/// This library holds several misc settings for the library.
/// </summary>
public class LibrarySettings : HandleType
2022-10-01 13:39:33 +00:00
{
protected LibrarySettings(FFIHandle handle) : base(handle) {}
2022-10-01 13:39:33 +00:00
2023-04-15 07:58:21 +00:00
/// <inheritdoc cref="LibrarySettings"/>
/// <param name="maxLevel">The highest level a Pokemon can be.</param>
/// <param name="shinyRate">
/// 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.
/// </param>
public static LibrarySettings Create(LevelInt maxLevel, uint shinyRate)
2022-10-01 13:39:33 +00:00
{
var handle = Interface.library_settings_new(maxLevel, shinyRate).Result();
return Resolver.Instance.ResolveLibrarySettings(handle.Resolve());
2022-10-01 13:39:33 +00:00
}
private LevelInt? _maxLevel;
2023-04-15 07:58:21 +00:00
/// <summary>
/// The highest level a Pokemon can be.
/// </summary>
public LevelInt MaxLevel => _maxLevel ??= Interface.library_settings_maximum_level(Handle);
2022-10-01 13:39:33 +00:00
private uint? _shinyRate;
2023-04-15 07:58:21 +00:00
/// <summary>
/// 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.
/// </summary>
public uint ShinyRate => _shinyRate ??= Interface.library_settings_shiny_rate(Handle);
2022-10-01 13:39:33 +00:00
}
}