using System; namespace PkmnLib.Static; /// /// 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. /// public interface INature { /// /// The name of the nature. /// string Name { get; } /// /// The stat that should receive the increased modifier. /// Statistic IncreasedStat { get; } /// /// The stat that should receive the decreased modifier. /// Statistic DecreasedStat { get; } /// /// The amount that the increased stat gets modified by. /// float IncreasedModifier { get; } /// /// The amount that the decreased stat gets modified by. /// float DecreasedModifier { get; } /// /// 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. /// /// The stat to calculate the modifier for. /// The calculated modifier. float GetStatModifier(Statistic stat); /// /// Checks if two natures are equal. /// /// The other nature to compare to. /// True if the natures are equal, false otherwise. bool Equals(INature other); } /// public class Nature( string name, Statistic increaseStat, Statistic decreaseStat, float increaseModifier, float decreaseModifier) : INature { /// public string Name { get; } = name; /// public Statistic IncreasedStat { get; } = increaseStat; /// public Statistic DecreasedStat { get; } = decreaseStat; /// public float IncreasedModifier { get; } = increaseModifier; /// public float DecreasedModifier { get; } = decreaseModifier; /// public float GetStatModifier(Statistic stat) { if (stat == IncreasedStat && stat != DecreasedStat) return IncreasedModifier; if (stat == DecreasedStat && stat != IncreasedStat) return DecreasedModifier; return 1.0f; } /// public bool Equals(INature? other) { return other is not null && StringComparer.InvariantCultureIgnoreCase.Equals(Name, other.Name); } }