Initial work on implementing Pokemon

This commit is contained in:
2024-07-28 14:00:26 +02:00
parent 3d5fb1a818
commit 554e1cf2cd
15 changed files with 603 additions and 30 deletions

View File

@@ -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);
}
}