Пример #1
0
        public static List <EvolutionSet> GetArray(byte[] data)
        {
            EvolutionSet[] evos = new EvolutionSet[Legal.MaxSpeciesID_3 + 1];
            evos[0] = new EvolutionSet3 {
                PossibleEvolutions = new EvolutionMethod[0]
            };
            for (int i = 0; i <= Legal.MaxSpeciesIndex_3; i++)
            {
                int g4species = SpeciesConverter.GetG4Species(i);
                if (g4species == 0)
                {
                    continue;
                }

                int offset = i * 40;
                var m_list = new List <EvolutionMethod>();
                for (int j = 0; j < 5; j++)
                {
                    EvolutionMethod m = GetMethod(data, offset);
                    if (m != null)
                    {
                        m_list.Add(m);
                    }
                    else
                    {
                        break;
                    }
                    offset += 8;
                }
                evos[g4species] = new EvolutionSet3 {
                    PossibleEvolutions = m_list.ToArray()
                };
            }
            return(evos.ToList());
        }
Пример #2
0
        public static IReadOnlyList <EvolutionSet> GetArray(byte[] data)
        {
            var evos = new EvolutionSet[Legal.MaxSpeciesID_3 + 1];

            evos[0] = Blank;
            for (int i = 1; i <= Legal.MaxSpeciesIndex_3; i++)
            {
                int g4species = SpeciesConverter.GetG4Species(i);
                if (g4species == 0)
                {
                    continue;
                }

                const int maxCount = 5;
                const int size     = 8;

                int offset = i * (maxCount * size);
                int count  = 0;
                for (; count < maxCount; count++)
                {
                    if (data[offset + (count * size)] == 0)
                    {
                        break;
                    }
                }
                if (count == 0)
                {
                    evos[g4species] = Blank;
                    continue;
                }

                var set = new EvolutionMethod[count];
                for (int j = 0; j < set.Length; j++)
                {
                    set[j] = GetMethod(data, offset + (j * size));
                }
                evos[g4species] = new EvolutionSet3 {
                    PossibleEvolutions = set
                };
            }
            return(evos);
        }
        private IReadOnlyList <EvolutionMethod[]> GetEntries(IReadOnlyList <byte[]> data)
        {
            switch (Game)
            {
            case GameVersion.Gen1:
            case GameVersion.Gen2: return(EvolutionSet1.GetArray(data[0], MaxSpeciesTree));

            case GameVersion.Gen3: return(EvolutionSet3.GetArray(data[0]));

            case GameVersion.Gen4: return(EvolutionSet4.GetArray(data[0]));

            case GameVersion.Gen5: return(EvolutionSet5.GetArray(data[0]));

            case GameVersion.Gen6: return(EvolutionSet6.GetArray(data));

            case GameVersion.Gen7: return(EvolutionSet7.GetArray(data));

            default: throw new Exception();
            }
        }
Пример #4
0
        private IReadOnlyList <EvolutionSet> GetEntries(IReadOnlyList <byte[]> data)
        {
            switch (Game)
            {
            case GameVersion.Gen1: return(EvolutionSet1.GetArray(data[0], MaxSpeciesTree));

            case GameVersion.Gen2: return(EvolutionSet2.GetArray(data[0], MaxSpeciesTree));

            case GameVersion.Gen3: return(EvolutionSet3.GetArray(data[0]));

            case GameVersion.Gen4: return(EvolutionSet4.GetArray(data[0]));

            case GameVersion.Gen5: return(EvolutionSet5.GetArray(data[0]));

            case GameVersion.Gen6: return(new List <EvolutionSet>(data.Select(d => new EvolutionSet6(d))));

            case GameVersion.Gen7: return(new List <EvolutionSet>(data.Select(d => new EvolutionSet7(d))));

            default: throw new Exception();
            }
        }
Пример #5
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();
        }