From 8c4b7e90603f8078eeffebf75647fd21a129afd4 Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 19 Oct 2020 11:54:59 -0700 Subject: [PATCH] Prefer form match for suggested encounters Closes #3038 --- .../Encounters/Generator/EncounterSlotGenerator.cs | 5 ++++- .../Encounters/Generator/EncounterStaticGenerator.cs | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterSlotGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterSlotGenerator.cs index ca3dee143..c7da18942 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterSlotGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterSlotGenerator.cs @@ -122,7 +122,10 @@ private static bool IsHiddenAbilitySlot(this EncounterSlot slot) internal static EncounterSlot? GetCaptureLocation(PKM pkm) { var chain = EvolutionChain.GetValidPreEvolutions(pkm, maxLevel: 100, skipChecks: true); - return GetPossible(pkm, chain).OrderBy(z => z.LevelMin).FirstOrDefault(); + return GetPossible(pkm, chain) + .OrderBy(z => !chain.Any(s => s.Species == z.Species && s.Form == z.Form)) + .ThenBy(z => z.LevelMin) + .FirstOrDefault(); } private static IEnumerable GetEncounterTable(PKM pkm, GameVersion gameSource = GameVersion.Any) diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterStaticGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterStaticGenerator.cs index 02e5318a3..dfc035828 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterStaticGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterStaticGenerator.cs @@ -118,8 +118,11 @@ internal static EncounterStatic7 GetVCStaticTransferEncounter(PKM pkm, IEncounte case 2: return EncounterStatic7.GetVC2(species, pkm.Met_Level); default: - var dl = EvolutionChain.GetValidPreEvolutions(pkm, maxLevel: 100, skipChecks: true); - return GetPossible(pkm, dl).FirstOrDefault(); + var chain = EvolutionChain.GetValidPreEvolutions(pkm, maxLevel: 100, skipChecks: true); + return GetPossible(pkm, chain) + .OrderBy(z => !chain.Any(s => s.Species == z.Species && s.Form == z.Form)) + .ThenBy(z => z.LevelMin) + .FirstOrDefault(); } }