From eb9a30bd41631e7d66fa011d9dac5bf49fb1a882 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 1 Nov 2024 13:26:03 +0100 Subject: [PATCH] Add helper method to get all learnable moves up to a specific level --- PkmnLib.Static/Species/LearnableMoves.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/PkmnLib.Static/Species/LearnableMoves.cs b/PkmnLib.Static/Species/LearnableMoves.cs index d78148b..ecd70a4 100644 --- a/PkmnLib.Static/Species/LearnableMoves.cs +++ b/PkmnLib.Static/Species/LearnableMoves.cs @@ -33,6 +33,11 @@ public interface ILearnableMoves /// /// The moves the Pokémon can learn through leveling up. IReadOnlyList GetDistinctLevelMoves(); + + /// + /// Gets a list of all moves a Pokémon can learn up to a specific level. + /// + IReadOnlyList GetLearnableMovesUpToLevel(LevelInt level); /// /// Gets all moves a Pokémon can learn by breeding. @@ -81,6 +86,17 @@ public class LearnableMovesImpl : ILearnableMoves return _distinctLevelMoves.ToList(); } + /// + public IReadOnlyList GetLearnableMovesUpToLevel(LevelInt level) + { + var moves = new HashSet(); + foreach (var kvp in _learnedByLevel.TakeWhile(kvp => kvp.Key <= level)) + { + moves.UnionWith(kvp.Value); + } + return moves.ToList(); + } + /// public IReadOnlyList GetEggMoves() => _eggMoves; } \ No newline at end of file