コード例 #1
0
        private void GenerateFrames(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            uint initial, location;

            try
            {
                initial = uint.Parse(SeedTextBox.Text, System.Globalization.NumberStyles.HexNumber);
            }
            catch
            {
                MessageBox.Show("Error: Seed has not been entered properly, please fix this if you want results.");
                return;
            }
            try
            {
                location = uint.Parse(LocationComboBox.Text.Substring(0, 1));
            }
            catch
            {
                MessageBox.Show("Error: Location has not been entered properly, please fix this if you want results.");
                return;
            }
            LCRNG rng = new LCRNG(initial);
            uint  startingFrame, maxFrames;

            try
            {
                startingFrame = uint.Parse(StartingFrameTextBox.Text);
                maxFrames     = uint.Parse(FrameAmountTextBox.Text);
            }
            catch
            {
                MessageBox.Show("Error: Starting Frame and/or Frame Amount have not been entered properly, please fix this if you want results.");
                return;
            }
            List <decimal> minIVs = new List <decimal> {
                MinHPUD.Value, MinATKUD.Value, MinDEFUD.Value, MinSPAUD.Value, MinSPDUD.Value, MinSPEUD.Value
            };
            List <decimal> maxIVs = new List <decimal> {
                MaxHPUD.Value, MaxATKUD.Value, MaxDEFUD.Value, MaxSPAUD.Value, MaxSPDUD.Value, MaxSPEUD.Value
            };

            int delay = 0;

            if (DelayCheckBox.Checked)
            {
                try
                {
                    delay = int.Parse(DelayTextBox.Text);
                }
                catch
                {
                    MessageBox.Show("Error: Delay has not been entered properly, please fix this if you want it to impact the frames or uncheck the Delay box.");
                }
            }

            uint f = 1;

            while (f < startingFrame + delay)
            {
                rng.nextUInt();
                f += 1;
            }
            uint tid, sid, tsv;

            try
            {
                tid = uint.Parse(TIDTextBox.Text);
                sid = uint.Parse(SIDTextBox.Text);
                tsv = (tid ^ sid) / 8;
            }
            catch
            {
                tsv = 8193;
                MessageBox.Show("Error: TID/SID have not been entered properly, please fix this if you want shinies to be marked correctly.");
            }

            string selectedLetter;
            int    selectedNature, selectedLetterTest;


            selectedLetter     = FormComboBox.Text;
            selectedLetterTest = characters.IndexOf(selectedLetter);

            if (selectedLetterTest < 0 & FormCheckBox.Checked)
            {
                MessageBox.Show("Error: Chosen Form has not been entered properly, please fix this or uncheck the Form box if you want results.");
                return;
            }

            selectedNature = natures.IndexOf(NatureComboBox.Text);
            if (selectedNature < 0 & NatureCheckBox.Checked)
            {
                MessageBox.Show("Error: Chosen Nature has not been entered properly, please fix this or uncheck the Nature box if you want results.");
                return;
            }


            int j = 0;

            while (j < 6)
            {
                if (maxIVs[j] < minIVs[j] | minIVs[j] > maxIVs[j])
                {
                    MessageBox.Show("Error: IV Range has not been entered properly.");
                    break;
                }
                j += 1;
            }

            uint cnt = 0;

            while (cnt < maxFrames + delay)
            {
                bool   flag         = true;
                uint   seed         = rng.seed;
                LCRNG  go           = new LCRNG(rng.nextUInt());
                uint   slot         = go.nextUShort() % 100;
                string targetLetter = GetTargetLetter(location, slot);
                go.nextUInt();
                string letter = "";
                uint   pid    = 0;
                while (letter != targetLetter)
                {
                    uint high = go.nextUShort();
                    uint low  = go.nextUShort();
                    pid    = (high << 16) | low;
                    letter = GetLetter(pid);
                }
                uint        iv1   = go.nextUShort();
                uint        iv2   = go.nextUShort();
                List <uint> ivs   = GetIVs(iv1, iv2);
                string      shiny = "No";


                uint psv = ((pid & 0xFFFF) ^ (pid >> 16)) / 8;
                if (psv == tsv)
                {
                    shiny = "Yes";
                }

                int    natureint = (int)(pid % 25);
                string nature    = natures[natureint];


                if (ShinyCheckBox.Checked)
                {
                    if (!(tsv == psv))
                    {
                        flag = false;
                    }
                }


                if (FormCheckBox.Checked & !(selectedLetter == targetLetter))
                {
                    flag = false;
                }

                if (NatureCheckBox.Checked & !(selectedNature == natureint))
                {
                    flag = false;
                }

                int i = 0;

                while (i < 6)
                {
                    if (ivs[i] < minIVs[i] | ivs[i] > maxIVs[i])
                    {
                        flag = false;
                        break;
                    }
                    i += 1;
                }

                if (flag)
                {
                    dataGridView1.Rows.Add(cnt + startingFrame, seed.ToString("X"), pid.ToString("X"), psv, shiny, slot, letter, nature, ivs[0], ivs[1], ivs[2], ivs[3], ivs[4], ivs[5], GetHPowerType(ivs), GetHPowerDamage(ivs));
                }
                cnt += 1;
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string selectedLetter;
            int    selectedNature, selectedLetterTest;


            selectedLetter     = FormComboBox.Text;
            selectedLetterTest = characters.IndexOf(selectedLetter);

            if (selectedLetterTest < 0 & FormCheckBox.Checked)
            {
                MessageBox.Show("Error: Chosen Form has not been entered properly, please fix this or uncheck the Form box if you want results.");
                return;
            }

            selectedNature = natures.IndexOf(NatureComboBox.Text);
            if (selectedNature < 0 & NatureCheckBox.Checked)
            {
                MessageBox.Show("Error: Chosen Nature has not been entered properly, please fix this or uncheck the Nature box if you want results.");
                return;
            }

            List <decimal> minIVs = new List <decimal> {
                MinHPUD.Value, MinATKUD.Value, MinDEFUD.Value, MinSPAUD.Value, MinSPDUD.Value, MinSPEUD.Value
            };
            List <decimal> maxIVs = new List <decimal> {
                MaxHPUD.Value, MaxATKUD.Value, MaxDEFUD.Value, MaxSPAUD.Value, MaxSPDUD.Value, MaxSPEUD.Value
            };

            int j = 0;

            while (j < 6)
            {
                if (maxIVs[j] < minIVs[j] | minIVs[j] > maxIVs[j])
                {
                    MessageBox.Show("Error: IV Range has not been entered properly.");
                    break;
                }
                j += 1;
            }

            dataGridView1.Rows.Clear();
            List <uint> origin = new List <uint>();

            for (uint hp = (uint)MinHPUD.Value; hp <= MaxHPUD.Value; hp++)
            {
                for (uint atk = (uint)MinATKUD.Value; atk <= MaxATKUD.Value; atk++)
                {
                    for (uint def = (uint)MinDEFUD.Value; def <= MaxDEFUD.Value; def++)
                    {
                        for (uint spe = (uint)MinSPEUD.Value; spe <= MaxSPEUD.Value; spe++)
                        {
                            for (uint spa = (uint)MinSPAUD.Value; spa <= MaxSPAUD.Value; spa++)
                            {
                                for (uint spd = (uint)MinSPDUD.Value; spd <= MaxSPDUD.Value; spd++)
                                {
                                    origin.AddRange(Recover(hp, atk, def, spa, spd, spe));
                                }
                            }
                        }
                    }
                }
            }

            foreach (uint val in origin)
            {
                List <bool> xoredlist = new List <bool> {
                    false, true
                };
                foreach (bool opp in xoredlist)
                {
                    uint valmod = val;
                    if (opp)
                    {
                        valmod ^= 0x80000000;
                    }
                    PokeRNGR rng   = new PokeRNGR(valmod);
                    uint     plow  = rng.nextUShort();
                    uint     phigh = rng.nextUShort();
                    uint     pid   = phigh << 16 | plow;
                    bool     sflag = false;
                    uint     seed;


                    while (!sflag)
                    {
                        PokeRNGR go        = new PokeRNGR(rng.seed);
                        uint     plowtest  = go.nextUShort();
                        uint     phightest = go.nextUShort();
                        uint     pidtest   = phightest << 16 | plowtest;
                        go.nextUInt();
                        uint          slot        = go.nextUShort() % 100;
                        List <string> letterslots = GetLetterSlots(slot);
                        if (GetLetter(pidtest) == GetLetter(pid))
                        {
                            sflag = true;
                        }
                        if (letterslots.Contains(GetLetter(pid)) & !sflag)
                        {
                            sflag = true;
                            go.nextUInt();
                            seed = go.nextUInt();

                            LCRNG go2 = new LCRNG(seed);
                            go2.nextUInt();
                            uint slot2 = go2.nextUShort() % 100;
                            go2.nextUInt();
                            string letter       = "";
                            uint   pid2         = 0;
                            string targetLetter = GetTargetLetter(GetLocation(GetLetter(pid)), slot2);
                            while (letter != targetLetter)
                            {
                                uint high2 = go2.nextUShort();
                                uint low2  = go2.nextUShort();
                                pid2   = (high2 << 16) | low2;
                                letter = GetLetter(pid2);
                            }
                            uint   psv   = ((pid & 0xFFFF) ^ (pid >> 16)) / 8;
                            string shiny = "No";
                            if (tsv == psv)
                            {
                                shiny = "Yes";
                            }

                            int    natureint = (int)(pid % 25);
                            string nature    = natures[natureint];

                            uint        iv1 = go2.nextUShort();
                            uint        iv2 = go2.nextUShort();
                            List <uint> ivs = GetIVs(iv1, iv2);
                            //cnt + startingFrame, seed.ToString("X"), pid.ToString("X"), psv, shiny, slot, letter, nature, ivs[0], ivs[1], ivs[2], ivs[3], ivs[4], ivs[5], GetHPowerType(ivs), GetHPowerDamage(ivs)

                            bool flag = true;

                            if (ShinyCheckBox.Checked)
                            {
                                if (!(tsv == psv))
                                {
                                    flag = false;
                                }
                            }


                            if (FormCheckBox.Checked & !(selectedLetter == targetLetter))
                            {
                                flag = false;
                            }

                            if (NatureCheckBox.Checked & !(selectedNature == natureint))
                            {
                                flag = false;
                            }

                            if (flag)
                            {
                                dataGridView1.Rows.Add(seed.ToString("X"), pid2.ToString("X"), psv, shiny, slot, GetLetter(pid2), nature, ivs[0], ivs[1], ivs[2], ivs[3], ivs[4], ivs[5], GetHPowerType(ivs), GetHPowerDamage(ivs));
                            }
                        }

                        rng.nextUInt();
                        rng.nextUInt();
                    }
                }
            }
        }