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

            Profile selectedProfile = Profiles[ProfileCB.SelectedIndex];
            uint    startingFrame   = (uint)StartingFrame.Value;
            uint    lastFrame       = (uint)EndingFrame.Value;
            uint    targetFrame     = (uint)TargetFrame.Value;
            uint    calibration     = (uint)Calibration.Value;
            uint    delay           = (uint)Delay.Value;
            uint    tid             = selectedProfile.TID;
            uint    sid             = selectedProfile.SID;
            uint    compatability   = (uint)(CompatabilityCB.SelectedIndex == 0 ? 20 : CompatabilityCB.SelectedIndex == 1 ? 50 : 70);
            uint    genderRatio     = ratios[GenderRatioCB.SelectedIndex];

            PokeRNG rng = new PokeRNG(0);

            rng.advance(startingFrame + calibration + delay);
            startingFrame += delay;
            lastFrame     += delay;

            for (uint frame = startingFrame; frame <= lastFrame; frame++)
            {
                State state = Generate(frame, targetFrame + delay + delay, rng, selectedProfile.HasLightningRod, compatability, genderRatio, tid, sid, selectedProfile.Trainers);

                bool flag = true;
                if (AbilityCB.Text != "Any" & AbilityCB.Text != state.Ability)
                {
                    flag = false;
                }
                if (NatureCB.Text != "Any" & NatureCB.Text != state.Nature)
                {
                    flag = false;
                }
                if (ShinyCB.Text != "Any" & ShinyCB.Text != state.Shiny & !(ShinyCB.Text == "Star/Square" & state.Shiny != "No"))
                {
                    flag = false;
                }
                if (GenderCB.Text != "Any" & GenderCB.Text != state.Gender)
                {
                    flag = false;
                }
                if (flag)
                {
                    int row = dataGridView1.Rows.Add(state.Frame - delay, state.Index + delay, state.EggRand, state.PID, state.Nature, state.Ability, state.Gender, state.Call);
                    dataGridView1.Rows[row].DefaultCellStyle.BackColor = shinyColor[state.Shiny];
                }

                rng.nextUInt();
            }
        }
コード例 #2
0
        private State Generate(uint frame, uint targetFrame, PokeRNG baserng, bool hasLightningRod, uint compatability, uint genderRatio, uint tid, uint sid, List <string> trainerlist)
        {
            State result = new State
            {
                Index   = (int)frame - (int)targetFrame,
                PID     = "---",
                Nature  = "---",
                Ability = "---",
                Gender  = "---",
                Call    = "No Call",
                Shiny   = "No",
                Frame   = frame,
            };

            uint    txor = tid ^ sid;
            PokeRNG rng  = new PokeRNG(baserng.seed);

            result.EggRand = rng.nextUShort() * 100 >> 16;

            if (result.EggRand <= compatability)
            {
                PokeRNG rng2 = new PokeRNG(frame & 0xFFFF);
                uint    low  = (rng.nextUShort() % 0xFFFE) + 1;
                uint    high = rng2.nextUShort();
                uint    pid  = (high << 16) | low;
                uint    pxor = low ^ high;
                result.Shiny = pxor / 8 == txor / 8 ? pxor == txor ? "Square" : "Star" : "No";

                result.PID     = pid.ToString("X");
                result.Nature  = natures[(int)(pid % 25)];
                result.Ability = ((pid & 1) + 1).ToString();
                result.Gender  = GetGender(pid & 255, genderRatio).ToString();
            }

            if ((rng.nextUShort() % 10) < (hasLightningRod ? 6 : 3))
            {
                result.Call = trainerlist[(int)(rng.nextUShort() % trainerlist.Count)];
            }

            return(result);
        }