Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        private EvolutionLineage[] CreateTree()
        {
            var lineage = new EvolutionLineage[Entries.Count];

            for (int i = 0; i < Entries.Count; i++)
            {
                lineage[i] = new EvolutionLineage();
            }
            if (Game == GameVersion.Gen6)
            {
                Array.Resize(ref lineage, MaxSpeciesTree + 1);
            }

            // Populate Lineages
            for (int i = 1; i < lineage.Length; i++)
            {
                CreateBranch(lineage, i);
            }
            return(lineage);
        }
Ejemplo n.º 3
0
        public EvolutionTree(byte[][] data, GameVersion game, PersonalTable personal, int maxSpeciesTree)
        {
            Game           = game;
            Personal       = personal;
            MaxSpeciesTree = maxSpeciesTree;
            switch (game)
            {
            case GameVersion.RBY:
                Entries = EvolutionSet1.GetArray(data[0], maxSpeciesTree);
                break;

            case GameVersion.GSC:
                Entries = EvolutionSet2.GetArray(data[0], maxSpeciesTree);
                break;

            case GameVersion.RS:
                Entries = EvolutionSet3.GetArray(data[0]);
                break;

            case GameVersion.DP:
                Entries = EvolutionSet4.GetArray(data[0]);
                break;

            case GameVersion.BW:
                Entries = EvolutionSet5.GetArray(data[0]);
                break;

            case GameVersion.ORAS:
                Entries.AddRange(data.Select(d => new EvolutionSet6(d)));
                break;

            case GameVersion.SM:
                Entries.AddRange(data.Select(d => new EvolutionSet7(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, MaxSpeciesTree + 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();
        }