diff --git a/PKHeX.Core/Legality/Learnset/Learnset.cs b/PKHeX.Core/Legality/Learnset/Learnset.cs index 4f021f5ba..88b29fe43 100644 --- a/PKHeX.Core/Legality/Learnset/Learnset.cs +++ b/PKHeX.Core/Legality/Learnset/Learnset.cs @@ -66,13 +66,23 @@ public int GetMinMoveLevel(int level) return Math.Max(end - 4, 1); } + + private Dictionary Learn; + private Dictionary GetDictionary() + { + var dict = new Dictionary(); + for (int i = 0; i < Moves.Length; i++) + if (!dict.ContainsKey(Moves[i])) + dict.Add(Moves[i], Levels[i]); + return dict; + } + /// Returns the level that a Pokémon can learn the specified move. /// Move ID /// Level the move is learned at. If the result is below 0, it cannot be learned by levelup. public int GetLevelLearnMove(int move) { - int index = Array.IndexOf(Moves, move); - return index < 0 ? index : Levels[index]; + return (Learn ?? (Learn = GetDictionary())).TryGetValue(move, out var level) ? level : -1; } } }