PkmnLibRSharp/PkmnLibRSharp/StaticData/Nature.cs

64 lines
2.2 KiB
C#

using PkmnLibSharp.Utils;
using Interface = PkmnLibSharp.FFI.StaticData.Nature;
namespace PkmnLibSharp.StaticData
{
/// <summary>
/// A nature is an attribute on a Pokemon that modifies the effective base stats on a Pokemon. They
/// can have an increased statistic and a decreased statistic, or be neutral.
/// </summary>
public class Nature : HandleType
{
/// <inheritdoc cref="Nature"/>
protected Nature(FFIHandle handle) : base(handle)
{
}
/// <summary>
/// Instantiates a new nature.
/// </summary>
public static Nature Create(Statistic increasedStat, Statistic decreasedStat, float increaseModifier = 1.1f,
float decreaseModifier = 0.9f)
{
var handle = Interface.nature_new(increasedStat, decreasedStat, increaseModifier, decreaseModifier);
return Resolver.Instance.ResolveNature(handle.Resolve());
}
/// <summary>
/// Instantiates a new nature that does not modify any stats.
/// </summary>
public static Nature NeutralNature()
{
return Create(Statistic.HP, Statistic.HP, 1f, 1f);
}
private Statistic? _increasedStat;
/// <summary>
/// The stat that should receive the increased modifier.
/// </summary>
public Statistic IncreasedStat
{
get { return _increasedStat ??= Interface.nature_increased_stat(Handle); }
}
private Statistic? _decreasedStat;
/// <summary>
/// The stat that should receive the decreased modifier.
/// </summary>
public Statistic DecreasedStat
{
get { return _decreasedStat ??= Interface.nature_decreased_stat(Handle); }
}
/// <summary>
/// Calculates the modifier for a given stat. If it's the increased stat, returns the increased
/// modifier, if it's the decreased stat, returns the decreased modifier. Otherwise returns 1.0
/// </summary>
public float GetStatModifier(Statistic statistic)
{
return Interface.nature_get_stat_modifier(Handle, statistic);
}
}
}