From be38a602675a22a5f121e9c19139b9d249d57d6f Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 6 Dec 2019 18:16:11 -0800 Subject: [PATCH] Fix handling for get evolutions method only used for Zukan7b, but add in handling so that it works for <=gen6 games, and supports form alterations too! update style to match GetPreEvolutions could probably update this to yield tuples (species, form) but LGPE/SWSH only needs species. If there's the need for tuples later, should be ez tweak. --- .../Legality/Evolutions/EvolutionTree.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs b/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs index 30647f3b0..4f8e7fbb9 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs @@ -91,7 +91,7 @@ private EvolutionTree(IReadOnlyList data, GameVersion game, PersonalTabl Entries = GetEntries(data); // Starting in Generation 7, forms have separate evolution data. - int format = Game.GetGeneration(); + int format = Game - Gen1 + 1; var oldStyle = format < 7; var connections = oldStyle ? CreateTreeOld() : CreateTree(); @@ -214,7 +214,7 @@ public List GetValidPreEvolutions(PKM pkm, int maxLevel, int maxSpe } /// - /// Gets all species the - can evolve to & from. + /// Gets all species the - can evolve to & from, yielded in order of increasing evolution stage. /// /// Species ID /// Form ID @@ -235,6 +235,8 @@ private IEnumerable GetPreEvolutions(int species, int form) foreach (var method in node) { var s = method.Species; + if (s == 0) + continue; var f = method.Form; yield return s; var preEvolutions = GetPreEvolutions(s, f); @@ -245,13 +247,18 @@ private IEnumerable GetPreEvolutions(int species, int form) private IEnumerable GetEvolutions(int species, int form) { - int index = GetLookupKey(species, form); - var node = Lineage[index]; - foreach (var method in node) + int format = Game - Gen1 + 1; + int index = format < 7 ? species : Personal.GetFormeIndex(species, form); + var evos = Entries[index]; + foreach (var method in evos) { var s = method.Species; + if (s == 0) + continue; + var f = method.GetDestinationForm(form); yield return s; - foreach (var next in GetEvolutions(s, form)) + var nextEvolutions = GetEvolutions(s, f); + foreach (var next in nextEvolutions) yield return next; } }