Пример #1
0
        private PersonalTable(byte[] data, GameVersion format)
        {
            int size = 0;

            switch (format)
            {
            case GameVersion.RBY: size = PersonalInfoG1.SIZE; break;

            case GameVersion.GS:
            case GameVersion.C: size = PersonalInfoG2.SIZE; break;

            case GameVersion.RS:
            case GameVersion.E:
            case GameVersion.FR:
            case GameVersion.LG: size = PersonalInfoG3.SIZE; break;

            case GameVersion.DP:
            case GameVersion.Pt:
            case GameVersion.HGSS: size = PersonalInfoG4.SIZE; break;

            case GameVersion.BW: size = PersonalInfoBW.SIZE; break;

            case GameVersion.B2W2: size = PersonalInfoB2W2.SIZE; break;

            case GameVersion.XY: size = PersonalInfoXY.SIZE; break;

            case GameVersion.ORAS: size = PersonalInfoORAS.SIZE; break;

            case GameVersion.SM: size = PersonalInfoSM.SIZE; break;
            }

            if (size == 0)
            {
                Table = null; return;
            }

            byte[][]       entries = splitBytes(data, size);
            PersonalInfo[] d       = new PersonalInfo[data.Length / size];

            switch (format)
            {
            case GameVersion.RBY:
                for (int i = 0; i < d.Length; i++)
                {
                    d[i] = new PersonalInfoG1(entries[i]);
                }
                break;

            case GameVersion.GS:
            case GameVersion.C:
                for (int i = 0; i < d.Length; i++)
                {
                    d[i] = new PersonalInfoG2(entries[i]);
                }
                break;

            case GameVersion.RS:
            case GameVersion.E:
            case GameVersion.FR:
            case GameVersion.LG:
                Array.Resize(ref d, 387);
                for (int i = 0; i < d.Length; i++)     // entries are not in order of natdexID
                {
                    d[i] = new PersonalInfoG3(entries[PKX.getG3Species(i)]);
                }
                break;

            case GameVersion.DP:
            case GameVersion.Pt:
            case GameVersion.HGSS:
                for (int i = 0; i < d.Length; i++)
                {
                    d[i] = new PersonalInfoG4(entries[i]);
                }
                break;

            case GameVersion.BW:
                for (int i = 0; i < d.Length; i++)
                {
                    d[i] = new PersonalInfoBW(entries[i]);
                }
                break;

            case GameVersion.B2W2:
                for (int i = 0; i < d.Length; i++)
                {
                    d[i] = new PersonalInfoB2W2(entries[i]);
                }
                break;

            case GameVersion.XY:
                for (int i = 0; i < d.Length; i++)
                {
                    d[i] = new PersonalInfoXY(entries[i]);
                }
                break;

            case GameVersion.ORAS:
                for (int i = 0; i < d.Length; i++)
                {
                    d[i] = new PersonalInfoORAS(entries[i]);
                }
                break;

            case GameVersion.SM:
                for (int i = 0; i < d.Length; i++)
                {
                    d[i] = new PersonalInfoSM(entries[i]);
                }
                break;
            }
            Table = d;
        }
        private PersonalTable(byte[] data, GameVersion format)
        {
            int size = 0;
            switch (format)
            {
                case GameVersion.RBY: size = PersonalInfoG1.SIZE; break;
                case GameVersion.GS:
                case GameVersion.C: size = PersonalInfoG2.SIZE; break;
                case GameVersion.RS:
                case GameVersion.E:
                case GameVersion.FR:
                case GameVersion.LG: size = PersonalInfoG3.SIZE; break;
                case GameVersion.DP:
                case GameVersion.Pt:
                case GameVersion.HGSS: size = PersonalInfoG4.SIZE; break;
                case GameVersion.BW: size = PersonalInfoBW.SIZE; break;
                case GameVersion.B2W2: size = PersonalInfoB2W2.SIZE; break;
                case GameVersion.XY: size = PersonalInfoXY.SIZE; break;
                case GameVersion.ORAS: size = PersonalInfoORAS.SIZE; break;
                case GameVersion.SM: size = PersonalInfoSM.SIZE; break;
            }

            if (size == 0)
            { Table = null; return; }

            byte[][] entries = splitBytes(data, size);
            PersonalInfo[] d = new PersonalInfo[data.Length / size];

            switch (format)
            {
                case GameVersion.RBY:
                    for (int i = 0; i < d.Length; i++)
                        d[i] = new PersonalInfoG1(entries[i]);
                    break;
                case GameVersion.GS:
                case GameVersion.C:
                    for (int i = 0; i < d.Length; i++)
                        d[i] = new PersonalInfoG2(entries[i]);
                    break;
                case GameVersion.RS:
                case GameVersion.E:
                case GameVersion.FR:
                case GameVersion.LG:
                    Array.Resize(ref d, 387);
                    for (int i = 0; i < d.Length; i++) // entries are not in order of natdexID
                        d[i] = new PersonalInfoG3(entries[PKX.getG3Species(i)]);
                    break;
                case GameVersion.DP:
                case GameVersion.Pt:
                case GameVersion.HGSS:
                    for (int i = 0; i < d.Length; i++)
                        d[i] = new PersonalInfoG4(entries[i]);
                    break;
                case GameVersion.BW:
                    for (int i = 0; i < d.Length; i++)
                        d[i] = new PersonalInfoBW(entries[i]);
                    break;
                case GameVersion.B2W2:
                    for (int i = 0; i < d.Length; i++)
                        d[i] = new PersonalInfoB2W2(entries[i]);
                    break;
                case GameVersion.XY:
                    for (int i = 0; i < d.Length; i++)
                        d[i] = new PersonalInfoXY(entries[i]);
                    break;
                case GameVersion.ORAS:
                    for (int i = 0; i < d.Length; i++)
                        d[i] = new PersonalInfoORAS(entries[i]);
                    break;
                case GameVersion.SM:
                    for (int i = 0; i < d.Length; i++)
                        d[i] = new PersonalInfoSM(entries[i]);
                    break;
            }
            Table = d;
        }