diff --git a/PKHeX.Core/Legality/Areas/EncounterArea8.cs b/PKHeX.Core/Legality/Areas/EncounterArea8.cs index ecec581ea..addd31880 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea8.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea8.cs @@ -30,8 +30,15 @@ public override bool IsMatchLocation(int location) public override IEnumerable GetMatchingSlots(PKM pkm, IReadOnlyList chain) { // wild area gets boosted up to level 60 post-game - bool isBoosted = pkm.Met_Level == 60 && (IsWildArea8(Location) || IsWildArea8Armor(Location)); + var met = pkm.Met_Level; + bool isBoosted = met == 60 && (IsWildArea8(Location) || IsWildArea8Armor(Location)); + if (isBoosted) + return GetBoostedMatches(chain); + return GetUnboostedMatches(chain, met); + } + private IEnumerable GetUnboostedMatches(IReadOnlyList chain, int met) + { foreach (var slot in Slots) { foreach (var evo in chain) @@ -39,7 +46,7 @@ public override IEnumerable GetMatchingSlots(PKM pkm, IReadOnlyLi if (slot.Species != evo.Species) continue; - if (!slot.IsLevelWithinRange(pkm.Met_Level) && !isBoosted) + if (!slot.IsLevelWithinRange(met)) break; if (slot.Form != evo.Form && !Legal.WildChangeFormAfter.Contains(evo.Species)) @@ -51,6 +58,26 @@ public override IEnumerable GetMatchingSlots(PKM pkm, IReadOnlyLi } } + private IEnumerable GetBoostedMatches(IReadOnlyList chain) + { + foreach (var slot in Slots) + { + foreach (var evo in chain) + { + if (slot.Species != evo.Species) + continue; + + // Ignore met level comparison; we already know it is permissible to boost to level 60. + + if (slot.Form != evo.Form && !Legal.WildChangeFormAfter.Contains(evo.Species)) + break; + + yield return slot; + break; + } + } + } + public static bool IsWildArea8(int loc) => 122 <= loc && loc <= 154; // Rolling Fields -> Lake of Outrage public static bool IsWildArea8Armor(int loc) => 164 <= loc && loc <= 194; // Fields of Honor -> Honeycalm Island