Example #1
0
        private static IEnumerable <int> getTutorMoves(PKM pkm, int species, int form, bool specialTutors)
        {
            PersonalInfo info = pkm.PersonalInfo;
            // Type Tutors
            List <int> moves = TypeTutor.Where((t, i) => info.TypeTutors[i]).ToList();

            // Varied Tutors
            //if (pkm.InhabitedGeneration(5) && Tutors)
            //{
            //    //PersonalInfo pi = PersonalTable.B2W2.getFormeEntry(species, form);
            //    //for (int i = 0; i < Tutors_B2W2.Length; i++)
            //    //    for (int b = 0; b < Tutors_B2W2[i].Length; b++)
            //    //        if (pi.SpecialTutors[i][b])
            //    //            moves.Add(Tutors_B2W2[i][b]);
            //}
            if (pkm.InhabitedGeneration(6) && specialTutors && (pkm.AO || !pkm.IsUntraded))
            {
                PersonalInfo pi = PersonalTable.AO.getFormeEntry(species, form);
                for (int i = 0; i < Tutors_AO.Length; i++)
                {
                    for (int b = 0; b < Tutors_AO[i].Length; b++)
                    {
                        if (pi.SpecialTutors[i][b])
                        {
                            moves.Add(Tutors_AO[i][b]);
                        }
                    }
                }
            }
            // No tutors in G7

            // Keldeo - Secret Sword
            if (species == 647)
            {
                moves.Add(548);
            }
            return(moves.Distinct());
        }
Example #2
0
        public ushort[] getStats(PersonalInfo p)
        {
            int level = CurrentLevel;

            ushort[] Stats = new ushort[6];
            Stats[0] = (ushort)(p.HP == 1 ? 1 : (IV_HP + 2 * p.HP + EV_HP / 4 + 100) * level / 100 + 10);
            Stats[1] = (ushort)((IV_ATK + 2 * p.ATK + EV_ATK / 4) * level / 100 + 5);
            Stats[2] = (ushort)((IV_DEF + 2 * p.DEF + EV_DEF / 4) * level / 100 + 5);
            Stats[4] = (ushort)((IV_SPA + 2 * p.SPA + EV_SPA / 4) * level / 100 + 5);
            Stats[5] = (ushort)((IV_SPD + 2 * p.SPD + EV_SPD / 4) * level / 100 + 5);
            Stats[3] = (ushort)((IV_SPE + 2 * p.SPE + EV_SPE / 4) * level / 100 + 5);

            // Account for nature
            int incr = Nature / 5 + 1;
            int decr = Nature % 5 + 1;

            if (incr == decr)
            {
                return(Stats);
            }
            Stats[incr] *= 11; Stats[incr] /= 10;
            Stats[decr] *= 9; Stats[decr] /= 10;
            return(Stats);
        }
Example #3
0
        private static IEnumerable <int> getMoves(PKM pkm, int species, int lvl, int form, bool moveTutor, GameVersion Version, bool LVL, bool specialTutors, bool Machine, int Generation, bool MoveReminder)
        {
            List <int> r = new List <int>();

            var ver = Version;

            switch (Generation)
            {
            case 6:
                switch (ver)
                {
                case GameVersion.Any:         // Start at the top, hit every table
                case GameVersion.X:
                case GameVersion.Y:
                case GameVersion.XY:
                {
                    int          index = PersonalTable.XY.getFormeIndex(species, form);
                    PersonalInfo pi    = PersonalTable.XY.getFormeEntry(species, form);

                    if (LVL)
                    {
                        r.AddRange(LevelUpXY[index].getMoves(lvl));
                    }
                    if (moveTutor)
                    {
                        r.AddRange(getTutorMoves(pkm, species, form, specialTutors));
                    }
                    if (Machine)
                    {
                        r.AddRange(TMHM_XY.Where((t, m) => pi.TMHM[m]));
                    }

                    if (ver == GameVersion.Any)         // Fall Through
                    {
                        goto case GameVersion.ORAS;
                    }
                    break;
                }

                case GameVersion.AS:
                case GameVersion.OR:
                case GameVersion.ORAS:
                {
                    int          index = PersonalTable.AO.getFormeIndex(species, form);
                    PersonalInfo pi    = PersonalTable.AO.getFormeEntry(species, form);

                    if (LVL)
                    {
                        r.AddRange(LevelUpAO[index].getMoves(lvl));
                    }
                    if (moveTutor)
                    {
                        r.AddRange(getTutorMoves(pkm, species, form, specialTutors));
                    }
                    if (Machine)
                    {
                        r.AddRange(TMHM_AO.Where((t, m) => pi.TMHM[m]));
                    }
                    break;
                }
                }
                break;

            case 7:
                switch (ver)
                {
                case GameVersion.Any:
                case GameVersion.SN:
                case GameVersion.MN:
                case GameVersion.SM:
                {
                    int          index = PersonalTable.SM.getFormeIndex(species, form);
                    PersonalInfo pi    = PersonalTable.SM.getFormeEntry(species, form);
                    if (MoveReminder)
                    {
                        lvl = 100;         // Move reminder can teach any level in movepool now!
                    }
                    if (LVL)
                    {
                        r.AddRange(LevelUpSM[index].getMoves(lvl));
                    }
                    if (moveTutor)
                    {
                        r.AddRange(getTutorMoves(pkm, species, form, specialTutors));
                    }
                    if (Machine)
                    {
                        r.AddRange(TMHM_SM.Where((t, m) => pi.TMHM[m]));
                    }
                    break;
                }
                }
                break;

            default:
                return(r);
            }
            return(r);
        }
Example #4
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;
        }
Example #5
0
File: PKX.cs Project: suloku/PKHeX
 internal static PersonalInfo[] getPersonalArray(byte[] data)
 {
     PersonalInfo[] d = new PersonalInfo[data.Length / PersonalInfo.Size];
     for (int i = 0; i < d.Length; i++)
         d[i] = new PersonalInfo(data.Skip(i*PersonalInfo.Size).Take(PersonalInfo.Size).ToArray());
     return 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;
        }
Example #7
0
        public override ushort[] getStats(PersonalInfo p)
        {
            ushort[] Stats = new ushort[6];
            for (int i = 0; i < Stats.Length; i++)
            {
                ushort L = (ushort)Stat_Level;
                ushort B = (ushort)p.Stats[i];
                ushort I = (ushort)IVs[i];
                ushort E = // Fixed formula via http://www.smogon.com/ingame/guides/rby_gsc_stats
                    (ushort)Math.Floor(Math.Min(255, Math.Floor(Math.Sqrt(Math.Max(0, EVs[i] - 1)) + 1)) / 4.0);
                Stats[i] = (ushort)Math.Floor((2 * (B + I) + E) * L / 100.0 + 5);
            }
            Stats[0] += (ushort)(5 + Stat_Level); // HP

            return Stats;
        }