From d61e646ca9ecb39defc8ab3248ef86df6af0a3ac Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 18 Feb 2021 17:26:06 -0800 Subject: [PATCH] Minor tweaks --- .../ByGeneration/EncounterGenerator6.cs | 4 ++-- .../Legality/Evolutions/EncounterOrigin.cs | 19 +++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator6.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator6.cs index 0b663206e..7b1d96923 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator6.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator6.cs @@ -41,9 +41,9 @@ public static IEnumerable GetEncounters(PKM pkm) if (partial != null) yield return partial; - } - yield break; + yield break; + } } if (pkm.WasBredEgg) diff --git a/PKHeX.Core/Legality/Evolutions/EncounterOrigin.cs b/PKHeX.Core/Legality/Evolutions/EncounterOrigin.cs index fe118e0d7..e6b3833ff 100644 --- a/PKHeX.Core/Legality/Evolutions/EncounterOrigin.cs +++ b/PKHeX.Core/Legality/Evolutions/EncounterOrigin.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using static PKHeX.Core.Species; namespace PKHeX.Core @@ -77,20 +76,16 @@ private static IReadOnlyList GetOriginChain(PKM pkm, int maxSpecies var tempMax = pkm.CurrentLevel; var chain = EvolutionChain.GetValidPreEvolutions(pkm, maxSpecies, tempMax, minLevel); - for (int i = chain.Count - 1; i >= 0; i--) + foreach (var evo in chain) { - var evo = chain[i]; - if (evo.MinLevel > maxLevel) - { - chain.RemoveAt(i); - if (chain.Any(z => z.Level >= maxLevel)) - continue; - chain.Clear(); - break; - } - + // Check for invalid evolutions, or cases where they may be under-leveled encounters of an evolution. if (evo.Level > maxLevel) evo.Level = maxLevel; + if (evo.MinLevel <= maxLevel) + continue; + evo.MinLevel = maxLevel; + if (evo.RequiresLvlUp) + maxLevel--; } return chain; }