public EvolutionTree(byte[][] data, GameVersion game, PersonalTable personal, int maxSpecies) { Game = game; Personal = personal; MaxSpecies = maxSpecies; switch (game) { case GameVersion.SM: Entries.AddRange(data.Select(d => new EvolutionSet7(d))); break; case GameVersion.ORAS: Entries.AddRange(data.Select(d => new EvolutionSet6(d))); break; } // Create Lineages Lineage = new EvolutionLineage[Entries.Count]; for (int i = 0; i < Entries.Count; i++) { Lineage[i] = new EvolutionLineage(); } if (Game == GameVersion.ORAS) { Array.Resize(ref Lineage, maxSpecies + 1); } // Populate Lineages for (int i = 1; i < Lineage.Length; i++) { // Iterate over all possible evolutions var s = Entries[i]; foreach (EvolutionMethod evo in s.PossibleEvolutions) { int index = getIndex(evo); if (index < 0) { continue; } var sourceEvo = evo.Copy(i); Lineage[index].Insert(sourceEvo); // If current entries has a pre-evolution, propagate to evolution as well if (Lineage[i].Chain.Count > 0) { Lineage[index].Insert(Lineage[i].Chain[0]); } if (index >= i) { continue; } // If destination species evolves into something (ie a 'baby' Pokemon like Cleffa) // Add it to the corresponding parent chains foreach (EvolutionMethod mid in Entries[index].PossibleEvolutions) { int newIndex = getIndex(mid); if (newIndex < 0) { continue; } Lineage[newIndex].Insert(sourceEvo); } } } fixEvoTreeManually(); }
public EvolutionTree(byte[][] data, GameVersion game, PersonalTable personal, int maxSpecies) { Game = game; Personal = personal; MaxSpecies = maxSpecies; switch (game) { case GameVersion.SM: Entries.AddRange(data.Select(d => new EvolutionSet7(d))); break; case GameVersion.ORAS: Entries.AddRange(data.Select(d => new EvolutionSet6(d))); break; } // Create Lineages Lineage = new EvolutionLineage[Entries.Count]; for (int i = 0; i < Entries.Count; i++) Lineage[i] = new EvolutionLineage(); // Populate Lineages for (int i = 1; i < Lineage.Length; i++) { // Iterate over all possible evolutions var s = Entries[i]; foreach (EvolutionMethod evo in s.PossibleEvolutions) { int index = getIndex(evo); if (index < 0) continue; var sourceEvo = evo.Copy(i); Lineage[index].Insert(sourceEvo); // If current entries has a pre-evolution, propagate to evolution as well if (Lineage[i].Chain.Count > 0) Lineage[index].Insert(Lineage[i].Chain[0]); if (index >= i) continue; // If destination species evolves into something (ie a 'baby' Pokemon like Cleffa) // Add it to the corresponding parent chains foreach (EvolutionMethod mid in Entries[index].PossibleEvolutions) { int newIndex = getIndex(mid); if (newIndex < 0) continue; Lineage[newIndex].Insert(sourceEvo); } } } fixEvoTreeManually(); }