From f6fb54aeccb4aa58614dfc684bc7818a22eb6e16 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 11 Jan 2020 21:43:58 -0800 Subject: [PATCH] Move shedinja/egg evo chain short circuit Some routes use the evolutiontree directly instead of this method (with the same name); should probably consolidate but meh This causes Shedinja to yield the correct evolution chain when called directly (because nothing naturally evolves to shedinja; it's created out of thin air as a clone) Take the egg short circuit with it to keep things simple --- .../Legality/Evolutions/EvolutionChain.cs | 17 ----------------- .../Legality/Evolutions/EvolutionTree.cs | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs b/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs index 750e70ccf..052f0ab83 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs @@ -235,23 +235,6 @@ internal static List GetValidPreEvolutions(PKM pkm, int maxspecieso { if (lvl < 0) lvl = pkm.CurrentLevel; - if (pkm.IsEgg && !skipChecks) - { - return new List(1) - { - new EvoCriteria(pkm.Species, pkm.AltForm) { Level = lvl, MinLevel = lvl }, - }; - } - - // Shedinja's evolution case can be a little tricky; hard-code handling. - if (pkm.Species == (int)Species.Shedinja && lvl >= 20 && (!pkm.HasOriginalMetLocation || pkm.Met_Level + 1 <= lvl)) - { - return new List(2) - { - new EvoCriteria((int)Species.Shedinja, 0) { Level = lvl, MinLevel = 20 }, - new EvoCriteria((int)Species.Nincada, 0) { Level = lvl, MinLevel = 1 }, - }; - } if (maxspeciesorigin == -1 && pkm.InhabitedGeneration(2) && pkm.Format <= 2 && pkm.GenNumber == 1) maxspeciesorigin = MaxSpeciesID_2; diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs b/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs index 3aecfcb0b..1dc9c5a16 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs @@ -206,6 +206,24 @@ public List GetValidPreEvolutions(PKM pkm, int maxLevel, int maxSpe { if (maxSpeciesOrigin <= 0) maxSpeciesOrigin = Legal.GetMaxSpeciesOrigin(pkm); + if (pkm.IsEgg && !skipChecks) + { + return new List(1) + { + new EvoCriteria(pkm.Species, pkm.AltForm) { Level = maxLevel, MinLevel = maxLevel }, + }; + } + + // Shedinja's evolution case can be a little tricky; hard-code handling. + if (pkm.Species == (int)Species.Shedinja && maxLevel >= 20 && (!pkm.HasOriginalMetLocation || pkm.Met_Level + 1 <= maxLevel)) + { + return new List(2) + { + new EvoCriteria((int)Species.Shedinja, 0) { Level = maxLevel, MinLevel = 20 }, + new EvoCriteria((int)Species.Nincada, 0) { Level = maxLevel, MinLevel = 1 }, + }; + } + return GetExplicitLineage(pkm, maxLevel, skipChecks, maxSpeciesOrigin, minLevel); }