diff --git a/PKHeX/Legality/Structures/DexLevel.cs b/PKHeX/Legality/Structures/DexLevel.cs index cea495af3..4ff880449 100644 --- a/PKHeX/Legality/Structures/DexLevel.cs +++ b/PKHeX/Legality/Structures/DexLevel.cs @@ -4,12 +4,13 @@ public class DexLevel { public int Species; public int Level; + public int MinLevel; public int Form = -1; public int Flag = -1; public DexLevel Copy(int lvl) { - return new DexLevel {Species = Species, Level = lvl, Form = Form, Flag = -1}; + return new DexLevel {Species = Species, Level = lvl, MinLevel = MinLevel, Form = Form, Flag = -1}; } public bool Matches(int species, int form) { diff --git a/PKHeX/Legality/Structures/EvolutionTree.cs b/PKHeX/Legality/Structures/EvolutionTree.cs index 1371a2525..cd3848602 100644 --- a/PKHeX/Legality/Structures/EvolutionTree.cs +++ b/PKHeX/Legality/Structures/EvolutionTree.cs @@ -153,7 +153,7 @@ private int getIndex(EvolutionMethod evo) return Personal.getFormeIndex(evolvesToSpecies, evolvesToForm); } - public IEnumerable getValidPreEvolutions(PKM pkm, int lvl, bool skipChecks = false) + public IEnumerable getValidPreEvolutions(PKM pkm, int lvl,bool skipChecks = false) { int index = getIndex(pkm); int maxSpeciesOrigin = Legal.getMaxSpeciesOrigin(pkm); @@ -354,7 +354,7 @@ public bool Valid(PKM pkm, int lvl, bool skipChecks) return false; } } - + public DexLevel GetDexLevel(int species, int lvl) { @@ -416,6 +416,22 @@ public IEnumerable getExplicitLineage(PKM pkm, int lvl, bool skipCheck continue; oneValid = true; + if (evo.Level == 0 && !evo.RequiresLevelUp) //Evolutions like elemental stones + dl.Last().MinLevel = 1; + else if(evo.Level ==0) //Evolutions like frienship, picho -> pikachu, eeve -> umbreon, etc + { + dl.Last().MinLevel = 2; + if (dl.Count() > 1 && dl.First().MinLevel == 1) + dl.First().MinLevel = 2; + } + else + { + dl.Last().MinLevel = evo.Level; + if (dl.Count() > 1 && dl.First().MinLevel == 1) + dl.First().MinLevel = evo.Level; //Pokemon like Nidoqueen, its minimun level is Nidorina minimun level + if (dl.Count() > 1 && dl.First().MinLevel == 2) + dl.First().MinLevel = evo.Level + 1; //Pokemon like Crobat, its minimun level is Golbat minimun level + 1 + } int species = evo.Species; // Gen7 Personal Formes -- unmap the forme personal entry ID to the actual species ID since species are consecutive @@ -436,6 +452,8 @@ public IEnumerable getExplicitLineage(PKM pkm, int lvl, bool skipCheck if (dl.Any(d => d.Species <= maxSpeciesOrigin) && dl.Last().Species > maxSpeciesOrigin) dl.RemoveAt(dl.Count - 1); + //Last species is the wild/hatched species, the minimu is 1 because it has not evolved from previous species + dl.Last().MinLevel = 1; return dl; } }