Further work on static side

This commit is contained in:
2024-07-20 16:12:39 +02:00
parent 3845f91601
commit 1b501dee7e
29 changed files with 670 additions and 155 deletions

View File

@@ -3,38 +3,40 @@ using PkmnLib.Static.Utils;
namespace PkmnLib.Static.Species;
/// <summary>
/// The storage of the moves a Pokemon can learn.
/// The storage of the moves a Pokémon can learn.
/// </summary>
public interface ILearnableMoves
{
/// <summary>
/// Adds a new level move the Pokemon can learn.
/// Adds a new level move the Pokémon can learn.
/// </summary>
/// <param name="level">The level the Pokemon learns the move at.</param>
/// <param name="move">The move the Pokemon learns.</param>
/// <param name="level">The level the Pokémon learns the move at.</param>
/// <param name="move">The move the Pokémon learns.</param>
/// <returns>Whether the move was added successfully.</returns>
void AddLevelMove(LevelInt level, StringKey move);
/// <summary>
/// Gets all moves a Pokemon can learn when leveling up to a specific level.
/// Gets all moves a Pokémon can learn when leveling up to a specific level.
/// </summary>
/// <param name="level">The level the Pokemon is learning moves at.</param>
/// <returns>The moves the Pokemon learns at that level.</returns>
/// <param name="level">The level the Pokémon is learning moves at.</param>
/// <returns>The moves the Pokémon learns at that level.</returns>
IReadOnlyList<StringKey> GetLearnedByLevel(LevelInt level);
/// <summary>
/// Gets the distinct moves a Pokemon can learn through leveling up.
/// Gets the distinct moves a Pokémon can learn through leveling up.
/// </summary>
/// <returns>The moves the Pokemon can learn through leveling up.</returns>
/// <returns>The moves the Pokémon can learn through leveling up.</returns>
IReadOnlyList<StringKey> GetDistinctLevelMoves();
}
/// <inheritdoc />
public class LearnableMovesImpl : ILearnableMoves
{
private readonly Dictionary<LevelInt, List<StringKey>> _learnedByLevel = new();
private readonly HashSet<StringKey> _distinctLevelMoves = new();
/// <inheritdoc />
public void AddLevelMove(LevelInt level, StringKey move)
{
if (!_learnedByLevel.TryGetValue(level, out var value))
@@ -44,6 +46,7 @@ public class LearnableMovesImpl : ILearnableMoves
_distinctLevelMoves.Add(move);
}
/// <inheritdoc />
public IReadOnlyList<StringKey> GetLearnedByLevel(LevelInt level)
{
if (!_learnedByLevel.TryGetValue(level, out var value))
@@ -51,8 +54,9 @@ public class LearnableMovesImpl : ILearnableMoves
return value;
}
/// <inheritdoc />
public IReadOnlyList<StringKey> GetDistinctLevelMoves()
{
return _distinctLevelMoves.ToList();
}
}
}