Initial work on implementing Pokemon
This commit is contained in:
@@ -24,7 +24,38 @@ public interface IReadOnlyGrowthRateLibrary
|
||||
/// Whether the library is empty.
|
||||
/// </summary>
|
||||
bool IsEmpty { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the experience for a given growth key name and a certain level.
|
||||
/// </summary>
|
||||
uint CalculateExperience(StringKey key, LevelInt level);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the level for a given growth key name and a certain experience.
|
||||
/// </summary>
|
||||
LevelInt CalculateLevel(StringKey key, uint experience);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IReadOnlyGrowthRateLibrary"/>
|
||||
public class GrowthRateLibrary : DataLibrary<IGrowthRate>, IReadOnlyGrowthRateLibrary;
|
||||
public class GrowthRateLibrary : DataLibrary<IGrowthRate>, IReadOnlyGrowthRateLibrary
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public uint CalculateExperience(StringKey key, LevelInt level)
|
||||
{
|
||||
if (!TryGet(key, out var growthRate))
|
||||
{
|
||||
throw new KeyNotFoundException($"Growth rate {key} not found.");
|
||||
}
|
||||
return growthRate.CalculateExperience(level);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public LevelInt CalculateLevel(StringKey key, uint experience)
|
||||
{
|
||||
if (!TryGet(key, out var growthRate))
|
||||
{
|
||||
throw new KeyNotFoundException($"Growth rate {key} not found.");
|
||||
}
|
||||
return growthRate.CalculateLevel(experience);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user