Add helper method to get all learnable moves up to a specific level

This commit is contained in:
Deukhoofd 2024-11-01 13:26:03 +01:00
parent f86ef53d51
commit eb9a30bd41
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 16 additions and 0 deletions

View File

@ -34,6 +34,11 @@ public interface ILearnableMoves
/// <returns>The moves the Pokémon can learn through leveling up.</returns>
IReadOnlyList<StringKey> GetDistinctLevelMoves();
/// <summary>
/// Gets a list of all moves a Pokémon can learn up to a specific level.
/// </summary>
IReadOnlyList<StringKey> GetLearnableMovesUpToLevel(LevelInt level);
/// <summary>
/// Gets all moves a Pokémon can learn by breeding.
/// </summary>
@ -81,6 +86,17 @@ public class LearnableMovesImpl : ILearnableMoves
return _distinctLevelMoves.ToList();
}
/// <inheritdoc />
public IReadOnlyList<StringKey> GetLearnableMovesUpToLevel(LevelInt level)
{
var moves = new HashSet<StringKey>();
foreach (var kvp in _learnedByLevel.TakeWhile(kvp => kvp.Key <= level))
{
moves.UnionWith(kvp.Value);
}
return moves.ToList();
}
/// <inheritdoc />
public IReadOnlyList<StringKey> GetEggMoves() => _eggMoves;
}