Ejemplo n.º 1
0
        private void buttonGenerate_Click(object sender, EventArgs e)
        {
            uint hp = 0;
            uint atk = 0;
            uint def = 0;
            uint spa = 0;
            uint spd = 0;
            uint spe = 0;

            if (maskedTextBoxHP_A.Text != "")
                hp = uint.Parse(maskedTextBoxHP_A.Text);
            if (maskedTextBoxAtk_A.Text != "")
                atk = uint.Parse(maskedTextBoxAtk_A.Text);
            if (maskedTextBoxDef_A.Text != "")
                def = uint.Parse(maskedTextBoxDef_A.Text);
            if (maskedTextBoxSpA_A.Text != "")
                spa = uint.Parse(maskedTextBoxSpA_A.Text);
            if (maskedTextBoxSpD_A.Text != "")
                spd = uint.Parse(maskedTextBoxSpD_A.Text);
            if (maskedTextBoxSpe_A.Text != "")
                spe = uint.Parse(maskedTextBoxSpe_A.Text);

            uint year_a = 0;
            uint month_a = 1;
            uint date_a = 1;
            uint hours_a = 0;
            uint minutes_a = 0;

            if (maskedTextBoxYear_A.Text != "")
                year_a = uint.Parse(maskedTextBoxYear_A.Text);

            if (maskedTextBoxMonth_A.Text != "")
                month_a = uint.Parse(maskedTextBoxMonth_A.Text);

            if (maskedTextBoxDate_A.Text != "")
                date_a = uint.Parse(maskedTextBoxDate_A.Text);

            if (maskedTextBoxHours_A.Text != "")
                hours_a = uint.Parse(maskedTextBoxHours_A.Text);

            if (maskedTextBoxMinutes_A.Text != "")
                minutes_a = uint.Parse(maskedTextBoxMinutes_A.Text);

            var nature = (Nature) comboBoxNature_A.SelectedValue;

            bool showMonster = checkBoxShowMonster.Checked;

            //  Get a list of possible starting seeds that we are going to use
            //  to work backwards and find probable initial seeds.
            List<Seed> startingSeeds =
                IVtoSeed.GetSeeds(hp, atk, def, spa, spd, spe, (uint) nature.Number);

            //  Now that we have developed a list of possible seeds we need to
            //  start working those backwards and then building a list of
            //  initial seeds that may have been possible.
            var seeds = new List<SeedInitial>();

            bool monsterFound = false;
            bool initialFound = false;

            uint minDefaultDelay = 550;
            if (radioButton_SIV_HGSS.Checked)
                minDefaultDelay = 400;

            uint maxDefaultDelay = 3600;

            if (maskedTextBoxMinDelay_A.Text != "" && radioButton_SIV_CUSTOM.Checked)
                minDefaultDelay = uint.Parse(maskedTextBoxMinDelay_A.Text);
            if (maskedTextBoxMaxDelay_A.Text != "" && radioButton_SIV_CUSTOM.Checked)
                maxDefaultDelay = uint.Parse(maskedTextBoxMaxDelay_A.Text);

            foreach (Seed seed in startingSeeds)
            {
                if (seed.FrameType == FrameType.Method1)
                {
                    if (showMonster)
                    {
                        seeds.Add(new SeedInitial(seed.MonsterSeed, 0, "Monster", 0, 0));
                    }

                    monsterFound = true;

                    //  start backing up, we are going to back up
                    //  a grand totol of 1000 times max for the
                    //  time being,
                    var rng = new PokeRngR(seed.MonsterSeed);

                    for (uint backCount = 1; backCount < 2000; backCount++)
                    {
                        uint testSeed = rng.Seed;
                        rng.GetNext16BitNumber();

                        uint seedAB = testSeed >> 24;
                        uint seedCD = (testSeed & 0x00FF0000) >> 16;
                        uint seedEFGH = testSeed & 0x0000FFFF;

                        if ((seedEFGH > (minDefaultDelay + year_a - 2000) &&
                             seedEFGH < (maxDefaultDelay + year_a - 2000)) ||
                            radioButton_SIV_OPEN.Checked)
                        {
                            //  Disqualify on hours second as it is very likely
                            //  to be a poor choice for use to work with.
                            if ((seedCD == hours_a) || radioButton_SIV_OPEN.Checked)
                            {
                                if (!radioButton_SIV_OPEN.Checked)
                                {
                                    for (uint secondsCount = 0; secondsCount < 60; secondsCount++)
                                    {
                                        if (((month_a*date_a + minutes_a + secondsCount)%0x100) == seedAB)
                                        {
                                            var initialSeed =
                                                new SeedInitial(
                                                    testSeed,
                                                    backCount,
                                                    "Initial",
                                                    secondsCount,
                                                    seedEFGH - (year_a - 2000));

                                            seeds.Add(initialSeed);

                                            initialFound = true;
                                        }
                                    }
                                }
                                else // if (!checkBoxOpenSearch.Checked)
                                {
                                    //  Do the open search, which is completely open and does not
                                    //  honor the min/max delay of the advanced search, so we should
                                    //  likely make the selection of those mutially exclusive.
                                    if (seedCD < 24)
                                    {
                                        if ((checkBoxLowDelay.Checked && seedEFGH < 10000) || !checkBoxLowDelay.Checked)
                                        {
                                            var initialSeed =
                                                new SeedInitial(
                                                    testSeed,
                                                    backCount,
                                                    "Initial",
                                                    0,
                                                    seedEFGH - (year_a - 2000));

                                            seeds.Add(initialSeed);

                                            initialFound = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            dataGridViewValues.DataSource = seeds;

            if (!monsterFound)
            {
                MessageBox.Show("No matches found for the IVs entered.  Please check and try again.", "No Data Found",
                                MessageBoxButtons.OK);
            }
            else if (!initialFound)
            {
                MessageBox.Show("No reasonable initial seed found. Please check your DATE and TIME.", "No Data Found",
                                MessageBoxButtons.OK);
            }

            Settings.Default.YearA = year_a.ToString();
            Settings.Default.MonthA = month_a.ToString();
            Settings.Default.DateA = date_a.ToString();
            Settings.Default.MinutesA = minutes_a.ToString();
            Settings.Default.HoursA = hours_a.ToString();

            if (maskedTextBoxMinDelay_A.Text != "" && radioButton_SIV_CUSTOM.Checked)
            {
                minDefaultDelay = uint.Parse(maskedTextBoxMinDelay_A.Text);
                Settings.Default.DelayMinA = minDefaultDelay.ToString();
            }
            if (maskedTextBoxMaxDelay_A.Text != "" && radioButton_SIV_CUSTOM.Checked)
            {
                maxDefaultDelay = uint.Parse(maskedTextBoxMaxDelay_A.Text);
                Settings.Default.DelayMaxA = maxDefaultDelay.ToString();
            }

            string SIV_Mode = "DPP";
            if (radioButton_SIV_DPP.Checked)
            {
                SIV_Mode = "DPP";
            }
            else if (radioButton_SIV_HGSS.Checked)
            {
                SIV_Mode = "HGSS";
            }
            else if (radioButton_SIV_CUSTOM.Checked)
            {
                SIV_Mode = "CUSTOM";
            }
            else if (radioButton_SIV_OPEN.Checked)
            {
                SIV_Mode = "OPEN";
            }
            Settings.Default.SIVMode = SIV_Mode;
            Settings.Default.SIVLowDelay = checkBoxLowDelay.Checked;
            Settings.Default.Save();
        }
Ejemplo n.º 2
0
        private void buttonFind_ByIVRange_Click(object sender, EventArgs e)
        {
            uint year_ivrange = 0;
            uint month_ivrange = 1;
            uint date_ivrange = 1;
            uint hours_ivrange = 0;
            uint minutes_ivrange = 0;

            var nature = (Nature) comboBoxNature_IVRange.SelectedValue;

            if (maskedTextBoxYear_IVRange.Text != "")
                year_ivrange = uint.Parse(maskedTextBoxYear_IVRange.Text);

            if (maskedTextBoxMonth_IVRange.Text != "")
                month_ivrange = uint.Parse(maskedTextBoxMonth_IVRange.Text);

            if (maskedTextBoxDate_IVRange.Text != "")
                date_ivrange = uint.Parse(maskedTextBoxDate_IVRange.Text);

            if (maskedTextBoxHours_IVRange.Text != "")
                hours_ivrange = uint.Parse(maskedTextBoxHours_IVRange.Text);

            if (maskedTextBoxMinutes_IVRange.Text != "")
                minutes_ivrange = uint.Parse(maskedTextBoxMinutes_IVRange.Text);

            bool showMonster = checkBoxShowMonster.Checked;

            var Possibilities =
                new List<List<uint>>
                    {
                        new List<uint>(),
                        new List<uint>(),
                        new List<uint>(),
                        new List<uint>(),
                        new List<uint>(),
                        new List<uint>()
                    };

            var minIvs = new uint[6];
            uint.TryParse(maskedTextBoxMinHP.Text, out minIvs[0]);
            uint.TryParse(maskedTextBoxMinAtk.Text, out minIvs[1]);
            uint.TryParse(maskedTextBoxMinDef.Text, out minIvs[2]);
            uint.TryParse(maskedTextBoxMinSpAtk.Text, out minIvs[3]);
            uint.TryParse(maskedTextBoxMinSpDef.Text, out minIvs[4]);
            uint.TryParse(maskedTextBoxMinSpeed.Text, out minIvs[5]);
            var maxIvs = new uint[6];
            uint.TryParse(maskedTextBoxMaxHP.Text, out maxIvs[0]);
            uint.TryParse(maskedTextBoxMaxAtk.Text, out maxIvs[1]);
            uint.TryParse(maskedTextBoxMaxDef.Text, out maxIvs[2]);
            uint.TryParse(maskedTextBoxMaxSpAtk.Text, out maxIvs[3]);
            uint.TryParse(maskedTextBoxMaxSpDef.Text, out maxIvs[4]);
            uint.TryParse(maskedTextBoxMaxSpeed.Text, out maxIvs[5]);

            uint minDefaultDelay;
            uint.TryParse(maskedTextBoxMinDelay_IVRange.Text, out minDefaultDelay);
            uint maxDefaultDelay;
            uint.TryParse(maskedTextBoxMaxDelay_IVRange.Text, out maxDefaultDelay);

            for (int statCnt = 0; statCnt <= 5; statCnt++)
            {
                for (uint charCnt = minIvs[statCnt]; charCnt <= maxIvs[statCnt]; charCnt++)
                {
                    Possibilities[statCnt].Add(charCnt);
                }
            }

            int combinations =
                Possibilities[0].Count*
                Possibilities[1].Count*
                Possibilities[2].Count*
                Possibilities[3].Count*
                Possibilities[4].Count*
                Possibilities[5].Count;

            //  If there are too many different combinations we need
            //  to notify the user that they may not proceed.
            if (combinations > 100)
            {
                MessageBox.Show(
                    "There were too many combinations of IV possibilities to accurately find your intitial seed (" +
                    combinations + ") please try with a higher level Pokemon,", "Too many IV Combinations");
            }
            else
            {
                var allSeeds = new List<Seed>();

                //  Iterate through all of the combinations of IVs and check
                //  so something good, first using the IvToPID.
                foreach (uint combo_HP in Possibilities[0])
                    foreach (uint combo_Atk in Possibilities[1])
                        foreach (uint combo_Def in Possibilities[2])
                            foreach (uint combo_SpA in Possibilities[3])
                                foreach (uint combo_SpD in Possibilities[4])
                                    foreach (uint combo_Spe in Possibilities[5])
                                    {
                                        List<Seed> startingSeeds =
                                            IVtoSeed.GetSeeds(
                                                combo_HP, combo_Atk, combo_Def,
                                                combo_SpA, combo_SpD, combo_Spe,
                                                (uint) nature.Number, 0);

                                        allSeeds.AddRange(startingSeeds);
                                    }

                //  We now have a complete list of starting seeds so we can run the
                //  same logic that we normally run here, but we might want to tone
                //  down how much we actually search.

                //  Now that we have developed a list of possible seeds we need to
                //  start working those backwards and then building a list of
                //  initial seeds that may have been possible.
                var seeds = new List<SeedInitial>();

                bool monsterFound = false;
                bool initialFound = false;

                foreach (Seed seed in allSeeds)
                {
                    if (seed.FrameType == FrameType.Method1)
                    {
                        if (showMonster)
                        {
                            seeds.Add(new SeedInitial(seed.MonsterSeed, 0, "Monster", 0, 0));
                        }

                        monsterFound = true;

                        //  start backing up, we are going to back up
                        //  a grand totol of 10,000 times max for the
                        //  time being,
                        var rng = new PokeRngR(seed.MonsterSeed);

                        //  back to 500
                        for (uint backCount = 1; backCount < 500; backCount++)
                        {
                            uint testSeed = rng.Seed;
                            rng.GetNext32BitNumber();

                            uint seedAB = testSeed >> 24;
                            uint seedCD = (testSeed & 0x00FF0000) >> 16;
                            uint seedEFGH = testSeed & 0x0000FFFF;

                            if (seedEFGH > (minDefaultDelay + year_ivrange - 2000) &&
                                seedEFGH < (maxDefaultDelay + year_ivrange - 2000))
                            {
                                //  Disqualify on hours second as it is very likely
                                //  to be a poor choice for use to work with.
                                //wfy back to exact hour
                                if (seedCD == hours_ivrange)
                                {
                                    for (uint secondsCount = 0; secondsCount < 60; secondsCount++)
                                    {
                                        if (((month_ivrange*date_ivrange + minutes_ivrange + secondsCount)%0x100) ==
                                            seedAB)
                                        {
                                            var initialSeed =
                                                new SeedInitial(
                                                    testSeed,
                                                    backCount,
                                                    "Initial",
                                                    secondsCount,
                                                    seedEFGH - (year_ivrange - 2000));

                                            seeds.Add(initialSeed);

                                            initialFound = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                dataGridViewSeeds_IVRange.DataSource = seeds;

                if (!monsterFound)
                {
                    MessageBox.Show("No matches found for the IVs entered.  Please check and try again.",
                                    "No Data Found", MessageBoxButtons.OK);
                }
                else if (!initialFound)
                {
                    MessageBox.Show("No reasonable initial seed found. Please check your DATE and TIME.",
                                    "No Data Found", MessageBoxButtons.OK);
                }

                Settings.Default.YearIVR = year_ivrange.ToString();
                Settings.Default.MonthIVR = month_ivrange.ToString();
                Settings.Default.DateIVR = date_ivrange.ToString();
                Settings.Default.MinutesIVR = minutes_ivrange.ToString();
                Settings.Default.HoursIVR = hours_ivrange.ToString();
                Settings.Default.DelayMinIVR = minDefaultDelay.ToString();
                Settings.Default.DelayMaxIVR = maxDefaultDelay.ToString();
                Settings.Default.Save();
            }
        }
Ejemplo n.º 3
0
        private void buttonFind_Stat_Click(object sender, EventArgs e)
        {
            uint year_stat = 0;
            uint month_stat = 1;
            uint date_stat = 1;
            uint hours_stat = 0;
            uint minutes_stat = 0;

            uint hp = 0;
            uint atk = 0;
            uint def = 0;
            uint spa = 0;
            uint spd = 0;
            uint spe = 0;

            uint level = 1;

            var pokemon = (Pokemon) comboBoxPokemon_Stat.SelectedValue;
            var nature = (Nature) comboBoxNature_Stat.SelectedValue;

            if (maskedTextBoxHP_Stat.Text != "")
                hp = uint.Parse(maskedTextBoxHP_Stat.Text);

            if (maskedTextBoxAtk_Stat.Text != "")
                atk = uint.Parse(maskedTextBoxAtk_Stat.Text);

            if (maskedTextBoxDef_Stat.Text != "")
                def = uint.Parse(maskedTextBoxDef_Stat.Text);

            if (maskedTextBoxSpA_Stat.Text != "")
                spa = uint.Parse(maskedTextBoxSpA_Stat.Text);

            if (maskedTextBoxSpD_Stat.Text != "")
                spd = uint.Parse(maskedTextBoxSpD_Stat.Text);

            if (maskedTextBoxSpe_Stat.Text != "")
                spe = uint.Parse(maskedTextBoxSpe_Stat.Text);

            if (maskedTextBoxLevel_Stat.Text != "")
                level = uint.Parse(maskedTextBoxLevel_Stat.Text);

            if (maskedTextBoxYear_Stat.Text != "")
                year_stat = uint.Parse(maskedTextBoxYear_Stat.Text);

            if (maskedTextBoxMonth_Stat.Text != "")
                month_stat = uint.Parse(maskedTextBoxMonth_Stat.Text);

            if (maskedTextBoxDate_Stat.Text != "")
                date_stat = uint.Parse(maskedTextBoxDate_Stat.Text);

            if (maskedTextBoxHours_Stat.Text != "")
                hours_stat = uint.Parse(maskedTextBoxHours_Stat.Text);

            if (maskedTextBoxMinutes_Stat.Text != "")
                minutes_stat = uint.Parse(maskedTextBoxMinutes_Stat.Text);

            bool showMonster = checkBoxShowMonster.Checked;

            var stats = new[] {hp, atk, def, spa, spd, spe};

            Characteristic characteristic = null;

            if (comboBoxCharacteristic_Stat.SelectedItem.ToString() != "NONE")
            {
                characteristic = (Characteristic) comboBoxCharacteristic_Stat.SelectedItem;
            }

            //  Run the IV checker with the stats and monster information
            //  that were entered into the intial seed finder,
            var ivCheck = new IVCheck(pokemon, level, nature, characteristic, stats);

            //  If there are any invalid IVs we need to notify the user
            //  what we may not proceed.
            if (!ivCheck.IsValid)
            {
                MessageBox.Show(
                    "There was a problem with the stats/nature/Pokemon you have entered.  Please check them and try again. " +
                    Environment.NewLine + Environment.NewLine + ivCheck, "Invalid Stats");
            }
            else
            {
                uint minDefaultDelay = 550;
                if (radioButton_SS_HGSS.Checked)
                    minDefaultDelay = 400;

                uint maxDefaultDelay = 1200;

                if (maskedTextBoxMinDelay_Stat.Text != "" && radioButton_SS_CUSTOM.Checked)
                    minDefaultDelay = uint.Parse(maskedTextBoxMinDelay_Stat.Text);
                if (maskedTextBoxMaxDelay_Stat.Text != "" && radioButton_SS_CUSTOM.Checked)
                    maxDefaultDelay = uint.Parse(maskedTextBoxMaxDelay_Stat.Text);

                int combinations =
                    ivCheck.Possibilities[0].Count*
                    ivCheck.Possibilities[1].Count*
                    ivCheck.Possibilities[2].Count*
                    ivCheck.Possibilities[3].Count*
                    ivCheck.Possibilities[4].Count*
                    ivCheck.Possibilities[5].Count;

                //  If there are too many different combinations we need
                //  to notify the user that they may not proceed.
                if (combinations > 100)
                {
                    MessageBox.Show(
                        "There were too many combinations of IV possibilities to accurately find your intitial seed (" +
                        combinations + ") please try with a higher level Pokemon,", "To many IV Combinations");
                }
                else
                {
                    var allSeeds = new List<Seed>();

                    //  Iterate through all of the combinations of IVs and check
                    //  so something good, first using the IvToPID.
                    foreach (uint combo_HP in ivCheck.Possibilities[0])
                        foreach (uint combo_Atk in ivCheck.Possibilities[1])
                            foreach (uint combo_Def in ivCheck.Possibilities[2])
                                foreach (uint combo_SpA in ivCheck.Possibilities[3])
                                    foreach (uint combo_SpD in ivCheck.Possibilities[4])
                                        foreach (uint combo_Spe in ivCheck.Possibilities[5])
                                        {
                                            List<Seed> startingSeeds =
                                                IVtoSeed.GetSeeds(
                                                    combo_HP, combo_Atk, combo_Def,
                                                    combo_SpA, combo_SpD, combo_Spe,
                                                    (uint) nature.Number, 0);

                                            allSeeds.AddRange(startingSeeds);
                                        }

                    //  We now have a complete list of starting seeds so we can run the
                    //  same logic that we normally run here, but we might want to tone
                    //  down how much we actually search.

                    //  Now that we have developed a list of possible seeds we need to
                    //  start working those backwards and then building a list of
                    //  initial seeds that may have been possible.
                    var seeds = new List<SeedInitial>();

                    bool monsterFound = false;
                    bool initialFound = false;

                    foreach (Seed seed in allSeeds)
                    {
                        if (seed.FrameType == FrameType.Method1)
                        {
                            if (showMonster)
                            {
                                seeds.Add(new SeedInitial(seed.MonsterSeed, 0, "Monster", 0, 0));
                            }

                            monsterFound = true;

                            //  start backing up, we are going to back up
                            //  a grand totol of 10,000 times max for the
                            //  time being,
                            var rng = new PokeRngR(seed.MonsterSeed);

                            //  back to 500
                            for (uint backCount = 1; backCount < 500; backCount++)
                            {
                                uint testSeed = rng.Seed;
                                rng.GetNext32BitNumber();

                                uint seedAB = testSeed >> 24;
                                uint seedCD = (testSeed & 0x00FF0000) >> 16;
                                uint seedEFGH = testSeed & 0x0000FFFF;

                                if (seedEFGH > (minDefaultDelay + year_stat - 2000) &&
                                    seedEFGH < (maxDefaultDelay + year_stat - 2000))
                                {
                                    //  Disqualify on hours second as it is very likely
                                    //  to be a poor choice for use to work with.
                                    //wfy back to exact hour
                                    if (seedCD == hours_stat)
                                    {
                                        for (uint secondsCount = 0; secondsCount < 60; secondsCount++)
                                        {
                                            if (((month_stat*date_stat + minutes_stat + secondsCount)%0x100) == seedAB)
                                            {
                                                var initialSeed =
                                                    new SeedInitial(
                                                        testSeed,
                                                        backCount,
                                                        "Initial",
                                                        secondsCount,
                                                        seedEFGH - (year_stat - 2000));

                                                seeds.Add(initialSeed);

                                                initialFound = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    dataGridViewValues_Stat.DataSource = seeds;

                    if (!monsterFound)
                    {
                        MessageBox.Show("No matches found for the IVs entered.  Please check and try again.",
                                        "No Data Found", MessageBoxButtons.OK);
                    }
                    else if (!initialFound)
                    {
                        MessageBox.Show("No reasonable initial seed found. Please check your DATE and TIME.",
                                        "No Data Found", MessageBoxButtons.OK);
                    }

                    //  Save our information for the next run
                    Settings.Default.YearS = year_stat.ToString();
                    Settings.Default.MonthS = month_stat.ToString();
                    Settings.Default.DateS = date_stat.ToString();
                    Settings.Default.MinutesS = minutes_stat.ToString();
                    Settings.Default.HoursS = hours_stat.ToString();

                    if (maskedTextBoxMinDelay_Stat.Text != "" && radioButton_SIV_CUSTOM.Checked)
                    {
                        minDefaultDelay = uint.Parse(maskedTextBoxMinDelay_Stat.Text);
                        Settings.Default.DelayMinS = minDefaultDelay.ToString();
                    }
                    if (maskedTextBoxMaxDelay_Stat.Text != "" && radioButton_SIV_CUSTOM.Checked)
                    {
                        maxDefaultDelay = uint.Parse(maskedTextBoxMaxDelay_Stat.Text);
                        Settings.Default.DelayMaxS = maxDefaultDelay.ToString();
                    }

                    string SS_Mode = "DPP";

                    if (radioButton_SS_DPP.Checked)
                    {
                        SS_Mode = "DPP";
                    }
                    else if (radioButton_SS_HGSS.Checked)
                    {
                        SS_Mode = "HGSS";
                    }
                    else if (radioButton_SS_CUSTOM.Checked)
                    {
                        SS_Mode = "CUSTOM";
                    }
                    Settings.Default.SSMode = SS_Mode;
                    Settings.Default.Save();
                }
            }
        }