private void buttonCheck_Click(object sender, EventArgs e)
        {
            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.SelectedValue;
            var nature = (Nature) comboBoxNature.SelectedValue;

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

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

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

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

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

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

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

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

            Characteristic characteristic = null;

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

            var ivCheck = new IVCheck(pokemon, level, nature, characteristic, stats);

            minstats = new uint[6];
            maxstats = new uint[6];

            for (int statCount = 0; statCount < 6; statCount++)
            {
                if (ivCheck.Possibilities[statCount].Count == 0)
                {
                    buttonOk.Enabled = false;
                    break;
                }

                minstats[statCount] = ivCheck.Possibilities[statCount][0];
                maxstats[statCount] = ivCheck.Possibilities[statCount][ivCheck.Possibilities[statCount].Count - 1];
                buttonOk.Enabled = true;
            }

            //  Get the results back and display them to the user
            textBoxResults.Text = ivCheck.ToString();
        }
Beispiel #2
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();
                }
            }
        }
Beispiel #3
0
        private void buttonCheck_Click(object sender, EventArgs e)
        {
            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.SelectedValue;
            var nature = (Nature) comboBoxNature.SelectedValue;

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

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

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

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

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

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

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

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

            Characteristic characteristic = null;

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

            var ivCheck = new IVCheck(pokemon, level, nature, characteristic, stats);

            //  Get the results back and display them to the user
            textBoxResults.Text = ivCheck.ToString();
        }