コード例 #1
0
ファイル: HgSsRoamers.cs プロジェクト: tnodland/RNGReporter
        public static HgSsRoamerInformation GetHgSsRoamerInformation(
            uint seed,
            bool rRoaming,
            bool eRoaming,
            bool lRoaming,
            uint rPreviousRoute,
            uint ePreviousRoute,
            uint lPreviousRoute)
        {
            var information = new HgSsRoamerInformation();

            var rng = new PokeRng(seed);

            uint rngCalls = 0;

            if (rRoaming)
            {
                while (true)
                {
                    rngCalls++;
                    uint rngReturn = rng.GetNext16BitNumber();
                    uint route     = RouteFromRngJ(rngReturn);

                    if (rPreviousRoute != route)
                    {
                        information.RCurrentRoute = route;
                        break;
                    }
                }
            }

            if (eRoaming)
            {
                while (true)
                {
                    rngCalls++;
                    uint rngReturn = rng.GetNext16BitNumber();
                    uint route     = RouteFromRngJ(rngReturn);

                    if (ePreviousRoute != route)
                    {
                        information.ECurrentRoute = route;
                        break;
                    }
                }
            }

            if (lRoaming)
            {
                while (true)
                {
                    rngCalls++;
                    uint rngReturn = rng.GetNext16BitNumber();
                    uint route     = RouteFromRngK(rngReturn);

                    if (lPreviousRoute != route)
                    {
                        information.LCurrentRoute = route;
                        break;
                    }
                }
            }

            information.RngCalls = rngCalls;

            return(information);
        }
コード例 #2
0
        private void Generate()
        {
            if (maskedTextBoxYear.Text == "")
            {
                MessageBox.Show("You must enter a year.", "Please Enter a Year", MessageBoxButtons.OK);
                return;
            }

            int lockedSecond = 0;

            if (maskedTextBoxSeconds.Text == "" && checkBoxLockSeconds.Checked)
            {
                MessageBox.Show("You must enter a seconds value.", "Please Enter Seconds", MessageBoxButtons.OK);
                return;
            }

            if (checkBoxLockSeconds.Checked)
            {
                lockedSecond = int.Parse(maskedTextBoxSeconds.Text);
            }

            if (textBoxSeed.Text != "")
            {
                Seed = uint.Parse(textBoxSeed.Text, NumberStyles.HexNumber);
            }

            if (radioBtnDPPt.Checked)
            {
                labelVerificationType.Text = "Coin Flips for Seed:";
                labelFlipsElmsForSeed.Text = CoinFlips.GetFlips(Seed, 15);
                labelRoamerRoutes.Text     = "";
            }
            else if (radioBtnHgSs.Checked)
            {
                labelVerificationType.Text = "Elm Responses for Seed:";
                //labelFlipsElmsForSeed.Text = ElmResponse.GetResponses(seed, 10, 0);

                // Handle all of the roaming Pokemon here
                uint rRoute = 0;
                uint eRoute = 0;
                uint lRoute = 0;

                // need to tryparse out all of the route values
                if (maskedTextBoxRRoute.Text != "")
                {
                    rRoute = uint.Parse(maskedTextBoxRRoute.Text);
                }

                if (maskedTextBoxERoute.Text != "")
                {
                    eRoute = uint.Parse(maskedTextBoxERoute.Text);
                }

                if (maskedTextBoxLRoute.Text != "")
                {
                    lRoute = uint.Parse(maskedTextBoxLRoute.Text);
                }

                //  We need to know two things, forced advancement and the
                //  starting route of each of the roamers the user has
                //  shown interest in --
                HgSsRoamerInformation information = HgSsRoamers.GetHgSsRoamerInformation(
                    Seed,
                    checkBoxRPresent.Checked,
                    checkBoxEPresent.Checked,
                    checkBoxLPresent.Checked,
                    rRoute,
                    eRoute,
                    lRoute);

                //  Build our roaming monster string
                //labelRoamerRoutes.Text = "";

                string labelRoamerRoutesText = "";

                bool firstDisplay = true;

                if (checkBoxRPresent.Checked)
                {
                    labelRoamerRoutesText += "R: " + information.RCurrentRoute;
                    firstDisplay           = false;
                }

                if (checkBoxEPresent.Checked)
                {
                    if (!firstDisplay)
                    {
                        labelRoamerRoutesText += "  ";
                    }

                    labelRoamerRoutesText += "E: " + information.ECurrentRoute;
                    firstDisplay           = false;
                }

                if (checkBoxLPresent.Checked)
                {
                    if (!firstDisplay)
                    {
                        labelRoamerRoutesText += "  ";
                    }

                    labelRoamerRoutesText += "L: " + information.LCurrentRoute;
                    firstDisplay           = false;
                }

                if (!firstDisplay)
                {
                    labelRoamerRoutesText += "  ---  ";
                    labelRoamerRoutesText += "Frame(s) Advanced: " + information.RngCalls;
                }

                labelRoamerRoutes.Text = labelRoamerRoutesText;

                //  Handle elm here, letting it know the foced advancement
                labelFlipsElmsForSeed.Text = Responses.ElmResponses(Seed, 15, information.RngCalls);
            }
            else
            {
                labelVerificationType.Text = "First 10 IVs in Seed:";
                labelFlipsElmsForSeed.Text = Gen5IVs.GetIVs(Seed, 1, 10);
                labelRoamerRoutes.Text     = "";
            }

            //  Break seed out into parts
            if (!radioBtnBW.Checked)
            {
                MAC_Address = 0;
            }
            uint partialmac = (uint)MAC_Address & 0xFFFFFF;
            uint ab         = (Seed - partialmac) >> 24;
            uint cd         = ((Seed - partialmac) & 0x00FF0000) >> 16;
            uint efgh       = (Seed - partialmac) & 0x0000FFFF;

            //  Get the year and the seed from the dialog
            //  we need to get the year because we let the
            //  user change this in the dialog

            // wfy this can fail if nothing entred
            int generateYear = int.Parse(maskedTextBoxYear.Text);

            //  Get Delay
            int delay = (int)efgh + (2000 - generateYear);

            //  Get Hour
            var hour = (int)cd;

            //  We need to check here, as a user could have entered a seed
            //  that is not possible (invalid hour) to lets warn and exit
            //  on it.
            if (hour > 23)
            {
                MessageBox.Show("This seed is invalid, please verify that you have entered it correctly and try again.",
                                "Invalid Seed", MessageBoxButtons.OK);

                return;
            }

            var timeAndDeleays = new List <TimeAndDelay>();

            //  Loop through all months
            for (int month = 1; month <= 12; month++)
            {
                int daysInMonth = DateTime.DaysInMonth(generateYear, month);

                //  Loop through all days
                for (int day = 1; day <= daysInMonth; day++)
                {
                    //  Loop through all minutes
                    for (int minute = 0; minute <= 59; minute++)
                    {
                        //  Loop through all seconds
                        for (int second = 0; second <= 59; second++)
                        {
                            if (ab == ((month * day + minute + second) % 0x100))
                            {
                                if (!checkBoxLockSeconds.Checked || second == lockedSecond)
                                {
                                    //  Create Date/Time and add item to collection
                                    var timeAndDelay = new TimeAndDelay();

                                    //  Build DateTime
                                    var dateTime = new DateTime(generateYear, month, day, hour, minute, second);

                                    timeAndDelay.Date  = dateTime;
                                    timeAndDelay.Delay = delay;

                                    //  Add to collection
                                    timeAndDeleays.Add(timeAndDelay);
                                }
                            }
                        }
                    }
                }
            }

            //  Do our databind to the grid here so the user
            //  can get the time listing.
            dataGridViewValues.DataSource = timeAndDeleays;
        }
コード例 #3
0
        public static HgSsRoamerInformation GetHgSsRoamerInformation(
            uint seed,
            bool rRoaming,
            bool eRoaming,
            bool lRoaming,
            uint rPreviousRoute,
            uint ePreviousRoute,
            uint lPreviousRoute)
        {
            var information = new HgSsRoamerInformation();

            var rng = new PokeRng(seed);

            uint rngCalls = 0;

            if (rRoaming)
            {
                while (true)
                {
                    rngCalls++;
                    ushort rngReturn = rng.GetNext16BitNumber();
                    uint route = RouteFromRngJ(rngReturn);

                    if (rPreviousRoute != route)
                    {
                        information.RCurrentRoute = route;
                        break;
                    }
                }
            }

            if (eRoaming)
            {
                while (true)
                {
                    rngCalls++;
                    ushort rngReturn = rng.GetNext16BitNumber();
                    uint route = RouteFromRngJ(rngReturn);

                    if (ePreviousRoute != route)
                    {
                        information.ECurrentRoute = route;
                        break;
                    }
                }
            }

            if (lRoaming)
            {
                while (true)
                {
                    rngCalls++;
                    ushort rngReturn = rng.GetNext16BitNumber();
                    uint route = RouteFromRngK(rngReturn);

                    if (lPreviousRoute != route)
                    {
                        information.LCurrentRoute = route;
                        break;
                    }
                }
            }

            information.RngCalls = rngCalls;

            return information;
        }