//-------------------------------------------------------------------------------------------------- private void buttonShinyGenerate_Click(object sender, EventArgs e) { //the main function for the shiny Time finder //check to make sure the user hasn't filled the text //boxes with exception-throwing garbage validateShinyInput(); if (checkBoxShinyDreamWorld.Checked && checkBoxShinyDittoParent.Checked) { MessageBox.Show("Unable to have Ditto parent and Dream World ability at the same time."); checkBoxShinyDittoParent.Focus(); return; } //read the user input from the form int year = Convert.ToInt32(maskedTextBoxShinyYear.Text); if (year < 2000 || year > 2099) { MessageBox.Show("Year must be between 2000 and 2099."); maskedTextBoxShinyYear.Focus(); return; } var months = new List<int>(); for (int month = 1; month <= 12; month++) { if (comboBoxShinyMonth.CheckBoxItems[month].Checked) months.Add(month); } if (months.Count == 0) { comboBoxShinyMonth.Focus(); return; } List<uint> nature = null; if (comboBoxShinyNature.SelectedIndex != 0) nature = new List<uint> {(uint) ((Nature) comboBoxShinyNature.SelectedItem).Number}; // Don't proceed without all DS Parameters if (!DSParametersInputCheck()) return; if (maskedTextBoxShinyMinFrame.Text == "") { maskedTextBoxShinyMinFrame.Focus(); maskedTextBoxShinyMinFrame.SelectAll(); return; } if (maskedTextBoxShinyMaxFrame.Text == "") { maskedTextBoxShinyMaxFrame.Focus(); maskedTextBoxShinyMaxFrame.SelectAll(); return; } var parentA = new uint[6]; var parentB = new uint[6]; uint.TryParse(maskedTextBoxShinyHPParentA.Text, out parentA[0]); uint.TryParse(maskedTextBoxShinyAtkParentA.Text, out parentA[1]); uint.TryParse(maskedTextBoxShinyDefParentA.Text, out parentA[2]); uint.TryParse(maskedTextBoxShinySpAParentA.Text, out parentA[3]); uint.TryParse(maskedTextBoxShinySpDParentA.Text, out parentA[4]); uint.TryParse(maskedTextBoxShinySpeParentA.Text, out parentA[5]); uint.TryParse(maskedTextBoxShinyHPParentB.Text, out parentB[0]); uint.TryParse(maskedTextBoxShinyAtkParentB.Text, out parentB[1]); uint.TryParse(maskedTextBoxShinyDefParentB.Text, out parentB[2]); uint.TryParse(maskedTextBoxShinySpAParentB.Text, out parentB[3]); uint.TryParse(maskedTextBoxShinySpDParentB.Text, out parentB[4]); uint.TryParse(maskedTextBoxShinySpeParentB.Text, out parentB[5]); uint minFrame; uint maxFrame; uint.TryParse(maskedTextBoxShinyMinFrame.Text, out minFrame); uint.TryParse(maskedTextBoxShinyMaxFrame.Text, out maxFrame); if (minFrame > maxFrame) { maskedTextBoxShinyMinFrame.Focus(); maskedTextBoxShinyMinFrame.SelectAll(); return; } generator = new FrameGenerator {FrameType = FrameType.Method5Standard, InitialFrame = 8, MaxResults = 1}; shinygenerator = new FrameGenerator { FrameType = !checkBoxIntlParents.Checked ? FrameType.BWBred : FrameType.BWBredInternational, ParentA = parentA, ParentB = parentB, SynchNature = ((Nature) comboBoxShinyEverstoneNature.SelectedItem).Number, InitialFrame = minFrame, MaxResults = maxFrame - minFrame + 1, DittoUsed = checkBoxShinyDittoParent.Checked, MaleOnlySpecies = cbNidoBeat.Checked, ShinyCharm = cbShinyCharm.Visible && cbShinyCharm.Checked }; frameCompare = new FrameCompare( null, null, -1, false, false, false, null, new NoGenderFilter()); subFrameCompare = new FrameCompare( ivFiltersEggs.IVFilter, nature, (int) ((ComboBoxItem) comboBoxShinyAbility.SelectedItem).Reference, checkBoxShinyShinyOnly.Checked, false, checkBoxShinyDreamWorld.Checked, null, (GenderFilter) (comboBoxShinyGender.SelectedItem)); // Here we check the parent IVs // To make sure they even have a chance of producing the desired spread int parentPassCount = 0; for (int i = 0; i < 6; i++) { if (subFrameCompare.CompareIV(i, parentA[i]) || subFrameCompare.CompareIV(i, parentB[i])) { parentPassCount++; } } if (parentPassCount < 3) { MessageBox.Show("The parent IVs you have listed cannot produce your desired search results."); return; } iframesEgg = new List<IFrameCapture>(); listBindingEgg = new BindingSource {DataSource = iframesEgg}; dataGridViewShinyResults.DataSource = listBindingEgg; var profile = (Profile) comboBoxProfiles.SelectedItem; List<List<ButtonComboType>> keypresses = profile.GetKeypresses(); bool fastSearch = FastEggFilters() && eggSeeds != null && eggSeeds.Count > 0; // && FastEggFrames() int dayTotal = months.Sum(month => DateTime.DaysInMonth(year, month)); progressTotal = (ulong) (dayTotal*86400*keypresses.Count*(profile.Timer0Max - profile.Timer0Min + 1)*(maxFrame - minFrame + 1)); float interval = ((float) 24/cpus + (float) 0.05); var hourMin = new int[cpus]; var hourMax = new int[cpus]; jobs = new Thread[cpus]; generators = new FrameGenerator[cpus]; shinygenerators = new FrameGenerator[cpus]; waitHandle = new EventWaitHandle(true, EventResetMode.ManualReset); for (int i = 0; i < jobs.Length; i++) { hourMin[i] = (int) (interval*i); hourMax[i] = (int) (interval*(i + 1) - 1); if (hourMax[i] > 23) { hourMax[i] = 23; } } for (int i = 0; i < jobs.Length; i++) { generators[i] = generator.Clone(); if (shinygenerator != null) { shinygenerators[i] = shinygenerator.Clone(); } //copy to prevent issues with i being incremented before the call int i1 = i; jobs[i] = new Thread( () => GenerateShinyJob((uint) year, months, hourMin[i1], hourMax[i1], profile, keypresses, fastSearch, i1)); jobs[i].Start(); // for some reason not making the thread sleep causes issues with updating dayMin\Max Thread.Sleep(200); } var progressJob = new Thread( () => ManageProgress(listBindingEgg, dataGridViewShinyResults, shinygenerator.FrameType, 2000)); progressJob.Start(); progressJob.Priority = ThreadPriority.Lowest; buttonCapGenerate.Enabled = false; buttonShinyGenerate.Enabled = false; dataGridViewShinyResults.Focus(); }
// Capture code begins here -- This is all of the good stuff for // captured Pokemon. private void buttonCapGenerate_Click(object sender, EventArgs e) { var profile = (Profile) comboBoxProfiles.SelectedItem; iframes = new List<IFrameCapture>(); listBindingCap = new BindingSource {DataSource = iframes}; dataGridViewCapValues.DataSource = listBindingCap; jobs = new Thread[cpus]; generators = new FrameGenerator[cpus]; shinygenerators = new FrameGenerator[cpus]; waitHandle = new EventWaitHandle(true, EventResetMode.ManualReset); var year = (uint) DateTime.Now.Year; if (maskedTextBoxCapYear.Text != "") { year = uint.Parse(maskedTextBoxCapYear.Text); // Need to validate the year here if (year < 2000) { MessageBox.Show("You must enter a year greater than 1999.", "Please Enter a Valid Year", MessageBoxButtons.OK); return; } } uint maxOffset = 1000; if (maskedTextBoxCapMaxOffset.Text != "") { maxOffset = uint.Parse(maskedTextBoxCapMaxOffset.Text); } else { maskedTextBoxCapMaxOffset.Text = "1000"; } uint minOffset = 1; if (maskedTextBoxCapMinOffset.Text != "") { minOffset = uint.Parse(maskedTextBoxCapMinOffset.Text); } else { maskedTextBoxCapMinOffset.Text = "1"; } if (minOffset > maxOffset) { maskedTextBoxCapMinOffset.Focus(); maskedTextBoxCapMinOffset.SelectAll(); return; } generator = new FrameGenerator { // Now that each combo box item is a custom object containing the FrameType reference // We can simply retrieve the FrameType from the selected item FrameType = (FrameType) ((ComboBoxItem) comboBoxMethod.SelectedItem).Reference, EncounterType = (EncounterType) ((ComboBoxItem) comboBoxEncounterType.SelectedItem).Reference, EncounterMod = Objects.EncounterMod.Search, InitialFrame = minOffset, MaxResults = maxOffset - minOffset + 1 }; if (generator.FrameType == FrameType.BWBred && profile.IsBW2()) generator.FrameType = FrameType.BW2Bred; if (generator.FrameType == FrameType.BWBredInternational && profile.IsBW2()) generator.FrameType = FrameType.BW2BredInternational; generator.isBW2 = profile.IsBW2(); // set up the hashtables containing precomputed MTRNG values // this saves time by reducing the search to a hashtable lookup // of MTRNG seeds that corresponds to common spreads //list = new Hashtable[6]; list = new Dictionary<uint, uint>[6]; bool fastSearch = FastCapFilters() && FastCapFrames(); // Build up a FrameComparer // Map the information from the IV box. Anything // that is blank is considered a zero. List<int> encounterSlots = null; if (comboBoxEncounterSlot.Text != "Any" && comboBoxEncounterSlot.CheckBoxItems.Count > 0) { encounterSlots = new List<int>(); for (int i = 0; i < comboBoxEncounterSlot.CheckBoxItems.Count; i++) { if (comboBoxEncounterSlot.CheckBoxItems[i].Checked) // We have to subtract 1 because this custom control contains a hidden item for text display encounterSlots.Add(i - 1); } } List<uint> natures = null; if (comboBoxNature.Text != "Any" && comboBoxNature.CheckBoxItems.Count > 0) { natures = (from t in comboBoxNature.CheckBoxItems where t.Checked select (uint) ((Nature) t.ComboBoxItem).Number).ToList(); } uint shinyOffset = 0; if (checkBoxShinyOnly.Checked) { uint.TryParse(maskedTextBoxMaxShiny.Text, out shinyOffset); } if (generator.FrameType == FrameType.Method5CGear || generator.FrameType == FrameType.Method5Standard) { EncounterSlot.Visible = false; EncounterMod.Visible = false; PID.Visible = false; Shiny.Visible = false; NearestShiny.Visible = false; Nature.Visible = false; Ability.Visible = false; CapHP.Visible = true; CapAtk.Visible = true; CapDef.Visible = true; CapSpA.Visible = true; CapSpD.Visible = true; CapSpe.Visible = true; HiddenPower.Visible = true; HiddenPowerPower.Visible = true; f25.Visible = false; f50.Visible = false; f75.Visible = false; f125.Visible = false; if (generator.FrameType == FrameType.Method5Standard) { CapSeed.DefaultCellStyle.Format = "X16"; CapSeed.Width = seedColumnLong(true); CapDateTime.Visible = true; CapKeypress.Visible = true; CapTimer0.Visible = true; if (shinyOffset > 0) { shinygenerator = new FrameGenerator { FrameType = FrameType.Method5Natures, EncounterType = (EncounterType) ((ComboBoxItem) comboBoxEncounterType.SelectedItem).Reference, EncounterMod = Objects.EncounterMod.Search, InitialFrame = 1, MaxResults = shinyOffset, //ShinyCharm = cbCapShinyCharm.Checked }; subFrameCompare = new FrameCompare( ivFiltersCapture.IVFilter, natures, (int) ((ComboBoxItem) comboBoxAbility.SelectedItem).Reference, true, checkBoxSynchOnly.Checked, false, encounterSlots, constructGenderFilter()); NearestShiny.Visible = true; PID.Visible = false; if (shinygenerator.EncounterType != EncounterType.Gift && shinygenerator.EncounterType != EncounterType.Roamer && shinygenerator.EncounterType != EncounterType.LarvestaEgg && shinygenerator.EncounterType != EncounterType.AllEncounterShiny) EncounterMod.Visible = true; else EncounterMod.Visible = false; if (shinygenerator.EncounterType != EncounterType.Stationary && shinygenerator.EncounterType != EncounterType.Gift && shinygenerator.EncounterType != EncounterType.Roamer && shinygenerator.EncounterType != EncounterType.LarvestaEgg && shinygenerator.EncounterType != EncounterType.AllEncounterShiny) EncounterSlot.Visible = true; else EncounterSlot.Visible = false; Nature.Visible = true; Ability.Visible = true; DisplayGenderColumns(); } if (profile.IsBW2()) generator.InitialFrame += 2; } else { CapSeed.DefaultCellStyle.Format = "X8"; CapSeed.Width = seedColumnLong(false); CapDateTime.Visible = false; CapKeypress.Visible = false; CapTimer0.Visible = false; } frameCompare = new FrameCompare( ivFiltersCapture.IVFilter, null, -1, false, false, false, null, new NoGenderFilter()); } if (generator.FrameType == FrameType.Wondercard5thGen || generator.FrameType == FrameType.Wondercard5thGenFixed) { CapSeed.DefaultCellStyle.Format = "X16"; CapSeed.Width = seedColumnLong(true); EncounterMod.Visible = false; EncounterSlot.Visible = false; PID.Visible = true; Shiny.Visible = true; NearestShiny.Visible = false; Nature.Visible = true; Ability.Visible = false; CapHP.Visible = true; CapAtk.Visible = true; CapDef.Visible = true; CapSpA.Visible = true; CapSpD.Visible = true; CapSpe.Visible = true; HiddenPower.Visible = true; HiddenPowerPower.Visible = true; f25.Visible = false; f50.Visible = false; f75.Visible = false; f125.Visible = false; CapDateTime.Visible = true; CapKeypress.Visible = true; CapTimer0.Visible = true; // genders are unsupported for now, fix this later frameCompare = new FrameCompare( ivFiltersCapture.IVFilter, natures, -1, checkBoxShinyOnly.Checked, false, false, null, new NoGenderFilter()); } if (generator.FrameType == FrameType.Method5Natures) { CapSeed.DefaultCellStyle.Format = "X16"; CapSeed.Width = seedColumnLong(true); if (generator.EncounterType != EncounterType.Gift && generator.EncounterType != EncounterType.Roamer && generator.EncounterType != EncounterType.LarvestaEgg && generator.EncounterType != EncounterType.AllEncounterShiny) EncounterMod.Visible = true; else EncounterMod.Visible = false; if (generator.EncounterType != EncounterType.Stationary && generator.EncounterType != EncounterType.Gift && generator.EncounterType != EncounterType.Roamer && generator.EncounterType != EncounterType.LarvestaEgg) EncounterSlot.Visible = true; else EncounterSlot.Visible = false; PID.Visible = true; Shiny.Visible = true; NearestShiny.Visible = false; Nature.Visible = true; Ability.Visible = true; CapHP.Visible = false; CapAtk.Visible = false; CapDef.Visible = false; CapSpA.Visible = false; CapSpD.Visible = false; CapSpe.Visible = false; HiddenPower.Visible = false; HiddenPowerPower.Visible = false; DisplayGenderColumns(); CapDateTime.Visible = true; CapKeypress.Visible = true; CapTimer0.Visible = true; //generator.ShinyCharm = cbCapShinyCharm.Checked; frameCompare = new FrameCompare( ivFiltersCapture.IVFilter, natures, (int) ((ComboBoxItem) comboBoxAbility.SelectedItem).Reference, checkBoxShinyOnly.Checked, checkBoxSynchOnly.Checked, false, encounterSlots, constructGenderFilter()); } if (generator.FrameType != FrameType.Method5CGear) { if (fastSearch) { Assembly thisExe = Assembly.GetExecutingAssembly(); Stream file; if (generator.EncounterType == EncounterType.Roamer) { file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame1D-Roamer.txt"); list[0] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame2D-Roamer.txt"); list[1] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame3D-Roamer.txt"); list[2] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame4D-Roamer.txt"); list[3] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame5D-Roamer.txt"); list[4] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame6D-Roamer.txt"); list[5] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); foreach (var partialList in list) { if (partialList == null) MessageBox.Show("error in loading roamer tables"); } } else { if (profile.IsBW2()) { // entralink if (minOffset > 21) { file = thisExe.GetManifestResourceStream( "RNGReporter.Resources.MTRNG-Frame25-Entralink.txt"); list[0] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream( "RNGReporter.Resources.MTRNG-Frame26-Entralink.txt"); list[1] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream( "RNGReporter.Resources.MTRNG-Frame27-Entralink.txt"); list[2] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream( "RNGReporter.Resources.MTRNG-Frame28-Entralink.txt"); list[3] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream( "RNGReporter.Resources.MTRNG-Frame29-Entralink.txt"); list[4] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream( "RNGReporter.Resources.MTRNG-Frame30-Entralink.txt"); list[5] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); } else { file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame3D.txt"); list[0] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame4D.txt"); list[1] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame5D.txt"); list[2] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame6D.txt"); list[3] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame7D.txt"); list[4] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame8D.txt"); list[5] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); } } else { file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame1D.txt"); list[0] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame2D.txt"); list[1] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame3D.txt"); list[2] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame4D.txt"); list[3] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame5D.txt"); list[4] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame6D.txt"); list[5] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); } foreach (var partialList in list) { if (partialList == null) MessageBox.Show("error in loading hashtables"); } } } generateTimesToolStripMenuItem.Visible = false; generateEntralinkNatureSeedsToolStripMenuItem.Visible = false; generateAdjacentSeedsToolStripMenuItem.Visible = true; var months = new List<int>(); for (int month = 1; month <= 12; month++) { if (comboBoxCapMonth.CheckBoxItems[month].Checked) months.Add(month); } if (months.Count == 0) { comboBoxCapMonth.Focus(); return; } if (!DSParametersInputCheck()) return; List<List<ButtonComboType>> keypresses = profile.GetKeypresses(); progressSearched = 0; progressFound = 0; int dayTotal = months.Sum(month => DateTime.DaysInMonth((int) year, month)); progressTotal = (ulong) (dayTotal*86400*(maxOffset - minOffset + 1)*keypresses.Count* (profile.Timer0Max - profile.Timer0Min + 1)); for (int i = 0; i < jobs.Length; i++) { generators[i] = generator.Clone(); if (shinygenerator != null) { shinygenerators[i] = shinygenerator.Clone(); } //copy to prevent issues with it being incremented before the actual thread really starts int i1 = i; //passing in a profile instead of the params would probably be more efficent if (generator.FrameType == FrameType.Wondercard5thGen || generator.FrameType == FrameType.Wondercard5thGenFixed) { int shiny = comboBoxShiny.SelectedIndex; jobs[i] = new Thread( () => GenerateWonderCardJob(year, months, 0, 23, profile, shinyOffset, fastSearch, i1, shiny)); } else { jobs[i] = new Thread( () => GenerateJob(year, months, 0, 23, profile, shinyOffset, fastSearch, i1)); } jobs[i].Start(); // for some reason not making the thread sleep causes issues with updating dayMin\Max Thread.Sleep(200); } var progressJob = new Thread(() => ManageProgress(listBindingCap, dataGridViewCapValues, generator.FrameType, 2000)); progressJob.Start(); progressJob.Priority = ThreadPriority.Lowest; buttonCapGenerate.Enabled = false; buttonShinyGenerate.Enabled = false; } else { // We want to get our year and offset ranges here so // that we can have some values for our looping. // Default these to this value, but save to // the registry so we can not have to redo. uint maxDelay = 610; if (maskedTextBoxCapMaxDelay.Text != "") maxDelay = uint.Parse(maskedTextBoxCapMaxDelay.Text); uint minDelay = 600; if (maskedTextBoxCapMinDelay.Text != "") minDelay = uint.Parse(maskedTextBoxCapMinDelay.Text); uint minEfgh = (year - 2000) + minDelay; uint maxEfgh = (year - 2000) + maxDelay; if (fastSearch) { Assembly thisExe = Assembly.GetExecutingAssembly(); Stream file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame21-Entralink.txt"); list[0] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame22-Entralink.txt"); list[1] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame23-Entralink.txt"); list[2] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame24-Entralink.txt"); list[3] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame25-Entralink.txt"); list[4] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); file = thisExe.GetManifestResourceStream("RNGReporter.Resources.MTRNG-Frame26-Entralink.txt"); list[5] = (Dictionary<uint, uint>) new BinaryFormatter().Deserialize(file); foreach (var partialList in list) { if (partialList == null) MessageBox.Show("error in loading hashtables"); } } generateTimesToolStripMenuItem.Visible = true; generateEntralinkNatureSeedsToolStripMenuItem.Visible = true; generateAdjacentSeedsToolStripMenuItem.Visible = false; jobs = new Thread[1]; //todo: split this into multiple threads //jobs[0] = new Thread(() => GenerateCGearCapJob(profile, minEfgh, maxEfgh, fastSearch)); jobs[0] = new Thread( () => GenerateCGearCapJob(profile.MAC_Address, minEfgh, maxEfgh, fastSearch, profile.ID, profile.SID)); jobs[0].Start(); progressTotal = (255*24*(maxEfgh - minEfgh + 1)*generator.MaxResults); var progressJob = new Thread(() => ManageProgress(listBindingCap, dataGridViewCapValues, generator.FrameType, 0)); progressJob.Start(); progressJob.Priority = ThreadPriority.Lowest; buttonCapGenerate.Enabled = false; } dataGridViewCapValues.Focus(); }
//-------------------------------------------------------------------------------------------------- private void buttonShinyGenerate_Click(object sender, EventArgs e) { //the main function for the shiny Time finder //check to make sure the user hasn't filled the text //boxes with exception-throwing garbage validateShinyInput(); //ShinyFinder stores TimeData structs in a list in order to pass them to //its adjacents window, so one is used to store all the variables in this function //read the user input from the form int year = Convert.ToInt32(maskedTextBoxShinyYear.Text); uint minDelay = Convert.ToUInt32(maskedTextBoxShinyMinDelay.Text); uint maxDelay = Convert.ToUInt32(maskedTextBoxShinyMaxDelay.Text); var minEfgh = (uint) (minDelay + year - 2000); var maxEfgh = (uint) (maxDelay + year - 2000); if (!uint.TryParse(maskedTextBoxShinyID.Text, out id)) { id = 0; } if (!uint.TryParse(maskedTextBoxShinySecretID.Text, out sid)) { sid = 0; } List<uint> nature = null; if (comboBoxShinyNature.SelectedIndex != 0) nature = new List<uint> {(uint) ((Nature) comboBoxShinyNature.SelectedItem).Number}; //List<IFrameEggPID> iframesEgg = new List<IFrameEggPID>(); generator = new FrameGenerator(); iframesEggShiny = new List<IFrameEggPID>(); frameCompare = new FrameCompare(0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, nature, (int) ((ComboBoxItem) comboBoxShinyAbility.SelectedItem).Reference, checkBoxShinyShinyOnly.Checked, false, false, null, (GenderFilter) (comboBoxShinyGender.SelectedItem)); listBindingShiny = new BindingSource {DataSource = iframesEggShiny}; dataGridViewShinyResults.DataSource = listBindingShiny; uint maxTaps = Convert.ToUInt32(maskedTextBoxMaxTaps.Text); if (radioButtonDPPt.Checked && !checkBoxIntlParents.Checked) { generator.FrameType = FrameType.Gen4Normal; if (checkBoxNoHappiness.Checked) { generator.InitialFrame = 11; generator.MaxResults = 11; } else { generator.InitialFrame = 23; generator.MaxResults = 11 + maxTaps*12; } } else if (radioButtonDPPt.Checked && checkBoxIntlParents.Checked) { generator.FrameType = FrameType.Gen4International; if (checkBoxNoHappiness.Checked) { generator.InitialFrame = 11; generator.MaxResults = 11; } else { generator.InitialFrame = 23; generator.MaxResults = 11 + maxTaps*12; } } else if (radioButtonHGSS.Checked && !checkBoxIntlParents.Checked) { generator.FrameType = FrameType.Gen4Normal; generator.InitialFrame = 1; generator.MaxResults = 14; } else if (radioButtonHGSS.Checked && checkBoxIntlParents.Checked) { generator.FrameType = FrameType.Gen4International; generator.InitialFrame = 1; generator.MaxResults = 14; } progressSearched = 0; progressFound = 0; progressTotal = (255*24*(maxEfgh - minEfgh + 1)*generator.MaxResults); waitHandle = new EventWaitHandle(true, EventResetMode.ManualReset); jobs = new Thread[1]; jobs[0] = new Thread(() => Generate4thGenEggPIDJob(minEfgh, maxEfgh)); jobs[0].Start(); Thread.Sleep(200); var progressJob = new Thread(() => ManageProgress(listBindingShiny, dataGridViewShinyResults, generator.FrameType, 0)); progressJob.Start(); progressJob.Priority = ThreadPriority.Lowest; buttonCapGenerate.Enabled = false; buttonShinyGenerate.Enabled = false; buttonEggGenerate.Enabled = false; // Here is where we should have a collection that we can // bind to the grid and display information to the user if (radioButtonHGSS.Checked) { EggSeed.DefaultCellStyle.Format = "X8"; ShinyTaps.Visible = false; ShinyFlipSequence.Visible = false; ShinyFlips.Visible = false; ShinyOffset.Visible = true; } else if (radioButtonDPPt.Checked) { EggSeed.DefaultCellStyle.Format = "X8"; ShinyTaps.Visible = !checkBoxNoHappiness.Checked; ShinyFlipSequence.Visible = true; ShinyFlips.Visible = true; ShinyOffset.Visible = false; } dataGridViewShinyResults.Focus(); }
public FrameGenerator Clone() { var clone = new FrameGenerator { frameType = frameType, EncounterType = EncounterType, EncounterMod = EncounterMod, SynchNature = SynchNature, InitialSeed = InitialSeed, InitialFrame = InitialFrame, maxResults = maxResults, DittoUsed = DittoUsed, MaleOnlySpecies = MaleOnlySpecies, ParentA = ParentA, ParentB = ParentB, RNGIVs = RNGIVs }; clone.SelectRNG(); return clone; }
// Capture code begins here -- This is all of the good stuff for // captured Pokemon. private void buttonCapGenerate_Click(object sender, EventArgs e) { if (!uint.TryParse(maskedTextBoxID.Text, out id)) { id = 0; } if (!uint.TryParse(maskedTextBoxSID.Text, out sid)) { sid = 0; } iframes = new List<IFrameCapture>(); listBindingCap = new BindingSource {DataSource = iframes}; dataGridViewCapValues.DataSource = listBindingCap; waitHandle = new EventWaitHandle(true, EventResetMode.ManualReset); // We want to get our year and offset ranges here so // that we can have some values for our looping. // Default these to this value, but save to // the registry so we can not have to redo. uint maxDelay = 610; if (maskedTextBoxCapMaxDelay.Text != "") maxDelay = uint.Parse(maskedTextBoxCapMaxDelay.Text); uint minDelay = 600; if (maskedTextBoxCapMinDelay.Text != "") minDelay = uint.Parse(maskedTextBoxCapMinDelay.Text); var year = (uint) DateTime.Now.Year; if (maskedTextBoxCapYear.Text != "") { year = uint.Parse(maskedTextBoxCapYear.Text); // Need to validate the year here if (year < 2000) { MessageBox.Show("You must enter a year greater than 1999.", "Please Enter a Valid Year", MessageBoxButtons.OK); return; } } uint maxOffset = 1000; if (maskedTextBoxCapMaxOffset.Text != "") { maxOffset = uint.Parse(maskedTextBoxCapMaxOffset.Text); } else { maskedTextBoxCapMaxOffset.Text = "1000"; } uint minOffset = 1; if (maskedTextBoxCapMinOffset.Text != "") { minOffset = uint.Parse(maskedTextBoxCapMinOffset.Text); } else { maskedTextBoxCapMinOffset.Text = "1"; } if (minOffset > maxOffset) { maskedTextBoxCapMinOffset.Focus(); maskedTextBoxCapMinOffset.SelectAll(); return; } generator = new FrameGenerator { FrameType = (FrameType) ((ComboBoxItem) comboBoxMethod.SelectedItem).Reference, EncounterType = EncounterTypeCalc.EncounterString(comboBoxEncounterType.Text), EncounterMod = Objects.EncounterMod.Search, InitialFrame = minOffset, MaxResults = maxOffset }; // Now that each combo box item is a custom object containing the FrameType reference // We can simply retrieve the FrameType from the selected item uint minEfgh = (year - 2000) + minDelay; uint maxEfgh = (year - 2000) + maxDelay; // Build up a FrameComparer IVFilter ivfilter = ivFiltersCapture.IVFilter; List<int> encounterSlots = null; if (comboBoxEncounterSlot.Text != "Any" && comboBoxEncounterSlot.CheckBoxItems.Count > 0) { encounterSlots = new List<int>(); for (int i = 0; i < comboBoxEncounterSlot.CheckBoxItems.Count; i++) { if (comboBoxEncounterSlot.CheckBoxItems[i].Checked) // We have to subtract 1 because this custom control contains a hidden item for text display encounterSlots.Add(i - 1); } } List<uint> natures = null; if (comboBoxNature.Text != "Any" && comboBoxNature.CheckBoxItems.Count > 0) { natures = new List<uint>(); for (int i = 0; i < comboBoxNature.CheckBoxItems.Count; i++) { if (comboBoxNature.CheckBoxItems[i].Checked) natures.Add((uint) (((Nature) comboBoxNature.CheckBoxItems[i].ComboBoxItem).Number)); } } if (((ComboBoxItem) comboBoxMethod.SelectedItem).Reference.Equals(FrameType.Method1) || ((ComboBoxItem) comboBoxMethod.SelectedItem).Reference.Equals(FrameType.ChainedShiny)) { Hour.Visible = true; EncounterMod.Visible = false; EncounterSlot.Visible = false; PID.Visible = true; Shiny.Visible = true; Nature.Visible = true; Ability.Visible = true; CapHP.Visible = true; CapAtk.Visible = true; CapDef.Visible = true; CapSpA.Visible = true; CapSpD.Visible = true; CapSpe.Visible = true; HiddenPower.Visible = true; HiddenPowerPower.Visible = true; f25.Visible = true; f50.Visible = true; f75.Visible = true; f125.Visible = true; frameCompare = new FrameCompare( ivfilter, natures, (int) ((ComboBoxItem) comboBoxAbility.SelectedItem).Reference, checkBoxShinyOnly.Checked, false, false, null, constructGenderFilter(comboBoxCapGender)); } if (((ComboBoxItem) comboBoxMethod.SelectedItem).Reference.Equals(FrameType.MethodJ) || ((ComboBoxItem) comboBoxMethod.SelectedItem).Reference.Equals(FrameType.MethodK)) { Hour.Visible = true; EncounterMod.Visible = true; EncounterSlot.Visible = generator.EncounterType != EncounterType.Stationary; PID.Visible = true; Shiny.Visible = true; Nature.Visible = true; Ability.Visible = true; CapHP.Visible = true; CapAtk.Visible = true; CapDef.Visible = true; CapSpA.Visible = true; CapSpD.Visible = true; CapSpe.Visible = true; HiddenPower.Visible = true; HiddenPowerPower.Visible = true; f25.Visible = true; f50.Visible = true; f75.Visible = true; f125.Visible = true; frameCompare = new FrameCompare( ivFiltersCapture.IVFilter, natures, (int) ((ComboBoxItem) comboBoxAbility.SelectedItem).Reference, checkBoxShinyOnly.Checked, false, false, encounterSlots, constructGenderFilter(comboBoxCapGender)); } if (((ComboBoxItem) comboBoxMethod.SelectedItem).Reference.Equals(FrameType.WondercardIVs)) { Hour.Visible = true; EncounterMod.Visible = false; EncounterSlot.Visible = false; PID.Visible = false; Shiny.Visible = false; Nature.Visible = false; Ability.Visible = false; CapHP.Visible = true; CapAtk.Visible = true; CapDef.Visible = true; CapSpA.Visible = true; CapSpD.Visible = true; CapSpe.Visible = true; HiddenPower.Visible = true; HiddenPowerPower.Visible = true; f25.Visible = false; f50.Visible = false; f75.Visible = false; f125.Visible = false; frameCompare = new FrameCompare( ivfilter, null, -1, false, false, false, null, new NoGenderFilter()); } jobs = new Thread[1]; var hpList = new List<uint>(); var atkList = new List<uint>(); var defList = new List<uint>(); var spaList = new List<uint>(); var spdList = new List<uint>(); var speList = new List<uint>(); for (uint iv = 0; iv <= 31; iv++) { if (frameCompare.CompareIV(ivfilter.hpCompare, iv, ivfilter.hpValue)) hpList.Add(iv); if (frameCompare.CompareIV(ivfilter.atkCompare, iv, ivfilter.atkValue)) atkList.Add(iv); if (frameCompare.CompareIV(ivfilter.defCompare, iv, ivfilter.defValue)) defList.Add(iv); if (frameCompare.CompareIV(ivfilter.spaCompare, iv, ivfilter.spaValue)) spaList.Add(iv); if (frameCompare.CompareIV(ivfilter.spdCompare, iv, ivfilter.spdValue)) spdList.Add(iv); if (frameCompare.CompareIV(ivfilter.speCompare, iv, ivfilter.speValue)) speList.Add(iv); } if (natures == null) { natures = new List<uint>(); for (uint i = 0; i < 25; i++) natures.Add(i); } jobs[0] = new Thread(() => Generate4thGenCapJob(hpList, atkList, defList, spaList, spdList, speList, natures, minEfgh, maxEfgh)); jobs[0].Start(); progressTotal = (ulong) (hpList.Count*atkList.Count*defList.Count*spaList.Count*spdList.Count*speList.Count*natures.Count); var progressJob = new Thread(() => ManageProgress(listBindingCap, dataGridViewCapValues, generator.FrameType, 0)); progressJob.Start(); progressJob.Priority = ThreadPriority.Lowest; buttonCapGenerate.Enabled = false; dataGridViewCapValues.Focus(); }
private void buttonGenerate_Click(object sender, EventArgs e) { int year = DateTime.Now.Year; if (maskedTextBoxYear.Text != "") { year = int.Parse(maskedTextBoxYear.Text); // Need to validate the year here if (year < 2000) { MessageBox.Show("You must enter a year greater than 1999.", "Please Enter a Valid Year", MessageBoxButtons.OK); return; } } // We are going to need to make sure that // this matches the offset that we show // on the main frame screen so that people // will be able to see. // Default to 5, some users might want lower // so we should save this in the registry if (maskedTextBoxMinOffset.Text != "") { maskedTextBoxMaxOffset.Focus(); maskedTextBoxMinOffset.SelectAll(); } uint minOffset = uint.Parse(maskedTextBoxMinOffset.Text); //now with min and max to avoid annoying manual searching //default to single value search though if (maskedTextBoxMaxOffset.Text != "") { maskedTextBoxMaxOffset.Focus(); maskedTextBoxMinOffset.SelectAll(); } uint maxOffset = uint.Parse(maskedTextBoxMaxOffset.Text); if (minOffset > maxOffset) { maskedTextBoxMinOffset.Focus(); maskedTextBoxMinOffset.SelectAll(); return; } // Default these to this value, but save to // the registry so we can not have to redo. uint highdelay = 610; if (maskedTextBoxMaxDelay.Text != "") highdelay = uint.Parse(maskedTextBoxMaxDelay.Text); uint lowdelay = 600; if (maskedTextBoxMinDelay.Text != "") lowdelay = uint.Parse(maskedTextBoxMinDelay.Text); generator = new FrameGenerator(); var parentA = new uint[6]; var parentB = new uint[6]; if (maskedTextBoxHPA.Text == "") maskedTextBoxHPA.Text = "0"; if (maskedTextBoxAtkA.Text == "") maskedTextBoxAtkA.Text = "0"; if (maskedTextBoxDefA.Text == "") maskedTextBoxDefA.Text = "0"; if (maskedTextBoxSpAA.Text == "") maskedTextBoxSpAA.Text = "0"; if (maskedTextBoxSpDA.Text == "") maskedTextBoxSpDA.Text = "0"; if (maskedTextBoxSpeA.Text == "") maskedTextBoxSpeA.Text = "0"; if (maskedTextBoxHPB.Text == "") maskedTextBoxHPB.Text = "0"; if (maskedTextBoxAtkB.Text == "") maskedTextBoxAtkB.Text = "0"; if (maskedTextBoxDefB.Text == "") maskedTextBoxDefB.Text = "0"; if (maskedTextBoxSpAB.Text == "") maskedTextBoxSpAB.Text = "0"; if (maskedTextBoxSpDB.Text == "") maskedTextBoxSpDB.Text = "0"; if (maskedTextBoxSpeB.Text == "") maskedTextBoxSpeB.Text = "0"; uint.TryParse(maskedTextBoxHPA.Text, out parentA[0]); uint.TryParse(maskedTextBoxAtkA.Text, out parentA[1]); uint.TryParse(maskedTextBoxDefA.Text, out parentA[2]); uint.TryParse(maskedTextBoxSpAA.Text, out parentA[3]); uint.TryParse(maskedTextBoxSpDA.Text, out parentA[4]); uint.TryParse(maskedTextBoxSpeA.Text, out parentA[5]); uint.TryParse(maskedTextBoxHPB.Text, out parentB[0]); uint.TryParse(maskedTextBoxAtkB.Text, out parentB[1]); uint.TryParse(maskedTextBoxDefB.Text, out parentB[2]); uint.TryParse(maskedTextBoxSpAB.Text, out parentB[3]); uint.TryParse(maskedTextBoxSpDB.Text, out parentB[4]); uint.TryParse(maskedTextBoxSpeB.Text, out parentB[5]); frameCompare = new FrameCompare( parentA[0], parentA[1], parentA[2], parentA[3], parentA[4], parentA[5], parentB[0], parentB[1], parentB[2], parentB[3], parentB[4], parentB[5], ivFiltersEgg.IVFilter, null, -1, false, true, new NoGenderFilter()); generator.ParentA = parentA; generator.ParentB = parentB; // Toggled based on the users selection if (radioButtonEggDPPt.Checked) { generator.FrameType = FrameType.DPPtBred; Flips.HeaderText = "Flip Sequence"; Flips.DataPropertyName = "Flips"; } else { generator.FrameType = FrameType.HGSSBred; Flips.HeaderText = "Elm Sequence"; Flips.DataPropertyName = "ElmResponses"; } Date.Visible = false; generator.InitialFrame = minOffset; generator.MaxResults = ((maxOffset - minOffset) + 1U); iframesEggIVs = new List<IFrameBreeding>(); listBindingEgg = new BindingSource {DataSource = iframesEggIVs}; dataGridViewEggIVValues.DataSource = listBindingEgg; progressSearched = 0; progressFound = 0; progressTotal = (255*24*(highdelay - lowdelay + 1)*generator.MaxResults); waitHandle = new EventWaitHandle(true, EventResetMode.ManualReset); jobs = new Thread[1]; jobs[0] = new Thread(() => Generate4thGenEggIVsJob(lowdelay, highdelay, (uint) year)); jobs[0].Start(); Thread.Sleep(200); var progressJob = new Thread(() => ManageProgress(listBindingEgg, dataGridViewEggIVValues, generator.FrameType, 0)); progressJob.Start(); progressJob.Priority = ThreadPriority.Lowest; buttonCapGenerate.Enabled = false; buttonShinyGenerate.Enabled = false; buttonEggGenerate.Enabled = false; returnToResultsToolStripMenuItem.Visible = false; dataGridViewEggIVValues.Focus(); }
private void buttonShiny3rdGenerate_Click(object sender, EventArgs e) { // seed used by all Ruby\Sapphire cartridges when the internal battery is dead const uint seed = 0x05A0; if (maskedTextBoxShiny3rdID.Text != "") { id = ushort.Parse(maskedTextBoxShiny3rdID.Text); } if (maskedTextBoxShiny3rdSID.Text != "") { sid = ushort.Parse(maskedTextBoxShiny3rdSID.Text); } var parentA = new uint[6]; var parentB = new uint[6]; uint.TryParse(maskedTextBoxShiny3rdParentA_HP.Text, out parentA[0]); uint.TryParse(maskedTextBoxShiny3rdParentA_Atk.Text, out parentA[1]); uint.TryParse(maskedTextBoxShiny3rdParentA_Def.Text, out parentA[2]); uint.TryParse(maskedTextBoxShiny3rdParentA_SpA.Text, out parentA[3]); uint.TryParse(maskedTextBoxShiny3rdParentA_SpD.Text, out parentA[4]); uint.TryParse(maskedTextBoxShiny3rdParentA_Spe.Text, out parentA[5]); uint.TryParse(maskedTextBoxShiny3rdParentB_HP.Text, out parentB[0]); uint.TryParse(maskedTextBoxShiny3rdParentB_Atk.Text, out parentB[1]); uint.TryParse(maskedTextBoxShiny3rdParentB_Def.Text, out parentB[2]); uint.TryParse(maskedTextBoxShiny3rdParentB_SpA.Text, out parentB[3]); uint.TryParse(maskedTextBoxShiny3rdParentB_SpD.Text, out parentB[4]); uint.TryParse(maskedTextBoxShiny3rdParentB_Spe.Text, out parentB[5]); uint maxHeldFrame; uint maxPickupFrame; uint minHeldFrame; uint minPickupFrame; if (!uint.TryParse(maskedTextBox3rdHeldMinFrame.Text, out minHeldFrame)) { maskedTextBox3rdHeldMinFrame.Focus(); maskedTextBox3rdHeldMinFrame.SelectAll(); return; } if (!uint.TryParse(maskedTextBox3rdPickupMinFrame.Text, out minPickupFrame)) { maskedTextBox3rdPickupMinFrame.Focus(); maskedTextBox3rdPickupMinFrame.SelectAll(); return; } if (!uint.TryParse(maskedTextBox3rdHeldMaxFrame.Text, out maxHeldFrame)) { maskedTextBox3rdHeldMaxFrame.Focus(); maskedTextBox3rdHeldMaxFrame.SelectAll(); return; } if (!uint.TryParse(maskedTextBox3rdPickupMaxFrame.Text, out maxPickupFrame)) { maskedTextBox3rdPickupMaxFrame.Focus(); maskedTextBox3rdPickupMaxFrame.SelectAll(); return; } if (minHeldFrame > maxHeldFrame) { maskedTextBox3rdHeldMinFrame.Focus(); maskedTextBox3rdHeldMinFrame.SelectAll(); return; } if (minPickupFrame > maxPickupFrame) { maskedTextBox3rdPickupMinFrame.Focus(); maskedTextBox3rdPickupMinFrame.SelectAll(); return; } lowerGenerator = new FrameGenerator(); ivGenerator = new FrameGenerator(); if (comboBoxParentCompatibility.SelectedIndex == 1) { lowerGenerator.Compatibility = 50; } else if (comboBoxParentCompatibility.SelectedIndex == 2) { lowerGenerator.Compatibility = 70; } else { lowerGenerator.Compatibility = 20; } lowerGenerator.FrameType = FrameType.RSBredLower; if (radioButtonSplitSpreads.Checked) ivGenerator.FrameType = FrameType.RSBredUpperSplit; else if (radioButtonAltSpreads.Checked) ivGenerator.FrameType = FrameType.RSBredUpperAlt; else ivGenerator.FrameType = FrameType.RSBredUpper; lowerGenerator.InitialFrame = minHeldFrame; ivGenerator.InitialFrame = minPickupFrame; lowerGenerator.MaxResults = maxHeldFrame - minHeldFrame + 1; ivGenerator.MaxResults = maxPickupFrame - minPickupFrame + 1; lowerGenerator.InitialSeed = seed; ivGenerator.InitialSeed = seed; ivGenerator.ParentA = parentA; ivGenerator.ParentB = parentB; List<uint> natures = null; if (comboBoxShiny3rdNature.Text != "Any" && comboBoxShiny3rdNature.CheckBoxItems.Count > 0) { natures = new List<uint>(); for (int i = 0; i < comboBoxShiny3rdNature.CheckBoxItems.Count; i++) { if (comboBoxShiny3rdNature.CheckBoxItems[i].Checked) natures.Add((uint) ((Nature) comboBoxShiny3rdNature.CheckBoxItems[i].ComboBoxItem).Number); } } frameCompare = new FrameCompare( 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, null, -1, false, false, false, null, (GenderFilter) (comboBoxShiny3rdGender.SelectedItem)); subFrameCompare = new FrameCompare( parentA[0], parentA[1], parentA[2], parentA[3], parentA[4], parentA[5], parentB[0], parentB[1], parentB[2], parentB[3], parentB[4], parentB[5], ivFiltersRSEgg.IVFilter, natures, (int) ((ComboBoxItem) comboBoxShiny3rdAbility.SelectedItem).Reference, checkBoxShiny3rdShinyOnly.Checked, true, new NoGenderFilter()); // Here we check the parent IVs // To make sure they even have a chance of producing the desired spread int parentPassCount = 0; for (int i = 0; i < 6; i++) { if (subFrameCompare.CompareIV(i, parentA[i]) || subFrameCompare.CompareIV(i, parentB[i])) { parentPassCount++; } } if (parentPassCount < 3) { MessageBox.Show("The parent IVs you have listed cannot produce your desired search results."); return; } iframesRSEgg = new List<IFrameRSEggPID>(); listBindingEggRS = new BindingSource {DataSource = iframesRSEgg}; dataGridViewShinyRSResults.DataSource = listBindingEggRS; progressSearched = 0; progressFound = 0; progressTotal = 0; waitHandle = new EventWaitHandle(true, EventResetMode.ManualReset); jobs = new Thread[1]; jobs[0] = new Thread(Generate3rdGenRSJob); jobs[0].Start(); Thread.Sleep(200); var progressJob = new Thread( () => ManageProgress(listBindingEggRS, dataGridViewShinyRSResults, lowerGenerator.FrameType, 0)); progressJob.Start(); progressJob.Priority = ThreadPriority.Lowest; buttonShiny3rdGenerate.Enabled = false; }
private void generateAdjacentToolStripMenuItem_Click(object sender, EventArgs e) { var initialiframe = (IFrameBreeding) dataGridViewEggIVValues.SelectedRows[0].DataBoundItem; // We need to display a dialog that is going to let the user // decide which adjacent spreads that we want to show here. var adjacent = new PlatinumTimeAdjacent(initialiframe.Seed, initialiframe.Offset, DateTime.Now.Year); if (adjacent.ShowDialog() == DialogResult.OK) { // Instantiate our Generator and a dummy frame compare record // one time here so we can re-use it for all of our later work var adjacentGenerator = new FrameGenerator(); var parentA = new uint[6]; var parentB = new uint[6]; uint.TryParse(maskedTextBoxHPA.Text, out parentA[0]); uint.TryParse(maskedTextBoxAtkA.Text, out parentA[1]); uint.TryParse(maskedTextBoxDefA.Text, out parentA[2]); uint.TryParse(maskedTextBoxSpAA.Text, out parentA[3]); uint.TryParse(maskedTextBoxSpDA.Text, out parentA[4]); uint.TryParse(maskedTextBoxSpeA.Text, out parentA[5]); uint.TryParse(maskedTextBoxHPB.Text, out parentB[0]); uint.TryParse(maskedTextBoxAtkB.Text, out parentB[1]); uint.TryParse(maskedTextBoxDefB.Text, out parentB[2]); uint.TryParse(maskedTextBoxSpAB.Text, out parentB[3]); uint.TryParse(maskedTextBoxSpDB.Text, out parentB[4]); uint.TryParse(maskedTextBoxSpeB.Text, out parentB[5]); adjacentGenerator.ParentA = parentA; adjacentGenerator.ParentB = parentB; var adjacentFrameCompare = new FrameCompare( 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, null, -1, false, false, false, null, new NoGenderFilter()); var adjacentFrames = new List<IFrameBreeding>(); int matchCount = 0; // Now we need to get the values back from this and run a special generation // with just these variables. We want it to be sorted by date (with delay) // and for items to be put in offset order. foreach (DateTime adjacentTime in adjacent.AdjacentTimeList) { for (uint rdelay = adjacent.ReturnMinDelay; rdelay <= adjacent.ReturnMaxDelay; rdelay++) { // Get the information (year, month, date from the frame) and build // our initial seed to feed to the Frame Generator so that we can uint seed = ((((uint) adjacentTime.Month* (uint) adjacentTime.Day + (uint) adjacentTime.Minute + (uint) adjacentTime.Second)%0x100) << 24) + ((uint) adjacentTime.Hour << 16) + ((uint) adjacentTime.Year - 2000 + rdelay); // Call a generator with a dummy compare object and go // up to the max delay and after this iterate through // the results to include min-max in a new list of frames // to show on the grid. adjacentGenerator.InitialFrame = adjacent.ReturnMinOffset; adjacentGenerator.MaxResults = adjacent.ReturnMaxOffset - adjacent.ReturnMinOffset + 1; adjacentGenerator.InitialSeed = seed; adjacentGenerator.FrameType = initialiframe.FrameType; List<Frame> frames = adjacentGenerator.Generate(adjacentFrameCompare, 0, 0); foreach (Frame frame in frames) { // Create our PlatinumIFrame and then add this to the // master collection that we are going to display to // the user. var iframe = new IFrameBreeding { Seed = seed, Offset = frame.Number, Delay = rdelay, Hp = frame.DisplayHpAlt, Atk = frame.DisplayAtkAlt, Def = frame.DisplayDefAlt, Spa = frame.DisplaySpaAlt, Spd = frame.DisplaySpdAlt, Spe = frame.DisplaySpeAlt, DisplayHpInh = frame.DisplayHp, DisplayAtkInh = frame.DisplayAtk, DisplayDefInh = frame.DisplayDef, DisplaySpaInh = frame.DisplaySpa, DisplaySpdInh = frame.DisplaySpd, DisplaySpeInh = frame.DisplaySpe, SeedTime = adjacentTime, FrameType = adjacentGenerator.FrameType }; if (initialiframe.Seed == iframe.Seed) { if (targetFrameIndex != 0) { if (initialiframe.Offset == iframe.Offset) targetFrameIndex = matchCount; } else targetFrameIndex = matchCount; } adjacentFrames.Add(iframe); matchCount++; } } } Date.Visible = true; dataGridViewEggIVValues.DataSource = adjacentFrames; returnToResultsToolStripMenuItem.Visible = true; // Select the row of the initial frame that was // selected when the adjacent command was run dataGridViewEggIVValues.FirstDisplayedScrollingRowIndex = targetFrameIndex; dataGridViewEggIVValues.Rows[targetFrameIndex].Selected = true; } }
private void buttonGenerateEPIDs_Click(object sender, EventArgs e) { const uint seed = 0x0; if (textEPIDID.Text != "") { ParseInputD(textEPIDID, out id); } if (textEPIDSID.Text != "") { ParseInputD(textEPIDSID, out sid); } uint maxHeldFrame; uint minHeldFrame; uint minRedraw; uint maxRedraw; uint calibration; if (!ParseInputD(textEPIDMinFrame, out minHeldFrame) || !ParseInputD(textEPIDMinFrame, out minHeldFrame) || !ParseInputD(textEPIDMaxFrame, out maxHeldFrame) || !ParseInputD(textEPIDMinRedraws, out minRedraw) || !ParseInputD(textEPIDMaxRedraws, out maxRedraw) || !ParseInputD(textEPIDCalibration, out calibration)) return; if (minHeldFrame > maxHeldFrame) { maskedTextBox3rdHeldMinFrame.Focus(); maskedTextBox3rdHeldMinFrame.SelectAll(); return; } lowerGenerator = new FrameGenerator(); switch (comboEPIDCompatibility.SelectedIndex) { case 1: lowerGenerator.Compatibility = 50; break; case 2: lowerGenerator.Compatibility = 70; break; default: lowerGenerator.Compatibility = 20; break; } lowerGenerator.FrameType = FrameType.EBredPID; lowerGenerator.InitialFrame = minHeldFrame; lowerGenerator.MaxResults = maxHeldFrame - minHeldFrame + 1 + 3*(maxRedraw - minRedraw); lowerGenerator.InitialSeed = seed; List<uint> natures = null; if (comboEPIDNature.Text != "Any" && comboEPIDNature.CheckBoxItems.Count > 0) { natures = new List<uint>(); for (int i = 0; i < comboEPIDNature.CheckBoxItems.Count; i++) { if (comboEPIDNature.CheckBoxItems[i].Checked) natures.Add((uint) ((Nature) comboEPIDNature.CheckBoxItems[i].ComboBoxItem).Number); } } if (comboEPIDEverstone.SelectedIndex != 0) { lowerGenerator.Everstone = true; lowerGenerator.SynchNature = ((Nature) comboEPIDEverstone.SelectedItem).Number; Advances.Visible = true; } else Advances.Visible = false; frameCompare = new FrameCompare( 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, natures, (int) ((ComboBoxItem) comboEPIDAbility.SelectedItem).Reference, checkEPIDShiny.Checked, false, false, null, (GenderFilter) (comboEPIDGender.SelectedItem)); // Here we check the parent IVs // To make sure they even have a chance of producing the desired spread iframesEEgg = new List<IFrameEEggPID>(); listBindingEggEPID = new BindingSource {DataSource = iframesEEgg}; dataGridViewEPIDs.DataSource = listBindingEggEPID; progressSearched = 0; progressFound = 0; progressTotal = 0; waitHandle = new EventWaitHandle(true, EventResetMode.ManualReset); jobs = new Thread[1]; jobs[0] = new Thread(() => Generate3rdGenEPIDJob(calibration, minRedraw, maxRedraw)); jobs[0].Start(); Thread.Sleep(200); var progressJob = new Thread( () => ManageProgress(listBindingEggEPID, dataGridViewEPIDs, lowerGenerator.FrameType, 0)); progressJob.Start(); progressJob.Priority = ThreadPriority.Lowest; buttonShiny3rdGenerate.Enabled = false; }
private void buttonGenerateXD_Click(object sender, EventArgs e) { if (maskedTextBoxMinHP.Text == "") { maskedTextBoxMinHP.Focus(); maskedTextBoxMinHP.SelectAll(); return; } if (maskedTextBoxMinAtk.Text == "") { maskedTextBoxMinAtk.Focus(); maskedTextBoxMinAtk.SelectAll(); return; } if (maskedTextBoxMinDef.Text == "") { maskedTextBoxMinDef.Focus(); maskedTextBoxMinDef.SelectAll(); return; } if (maskedTextBoxMinSpA.Text == "") { maskedTextBoxMinSpA.Focus(); maskedTextBoxMinSpA.SelectAll(); return; } if (maskedTextBoxMinSpD.Text == "") { maskedTextBoxMinSpD.Focus(); maskedTextBoxMinSpD.SelectAll(); return; } if (maskedTextBoxMinSpe.Text == "") { maskedTextBoxMinSpe.Focus(); maskedTextBoxMinSpe.SelectAll(); return; } if (maskedTextBoxMaxHP.Text == "") { maskedTextBoxMaxHP.Focus(); maskedTextBoxMaxHP.SelectAll(); return; } if (maskedTextBoxMaxAtk.Text == "") { maskedTextBoxMaxAtk.Focus(); maskedTextBoxMaxAtk.SelectAll(); return; } if (maskedTextBoxMaxDef.Text == "") { maskedTextBoxMaxDef.Focus(); maskedTextBoxMaxDef.SelectAll(); return; } if (maskedTextBoxMaxSpA.Text == "") { maskedTextBoxMaxSpA.Focus(); maskedTextBoxMaxSpA.SelectAll(); return; } if (maskedTextBoxMaxSpD.Text == "") { maskedTextBoxMaxSpD.Focus(); maskedTextBoxMaxSpD.SelectAll(); return; } if (maskedTextBoxMaxSpe.Text == "") { maskedTextBoxMaxSpe.Focus(); maskedTextBoxMaxSpe.SelectAll(); return; } uint minhp = uint.Parse(maskedTextBoxMinHP.Text); uint minatk = uint.Parse(maskedTextBoxMinAtk.Text); uint mindef = uint.Parse(maskedTextBoxMinDef.Text); uint minspa = uint.Parse(maskedTextBoxMinSpA.Text); uint minspd = uint.Parse(maskedTextBoxMinSpD.Text); uint minspe = uint.Parse(maskedTextBoxMinSpe.Text); uint maxhp = uint.Parse(maskedTextBoxMaxHP.Text); uint maxatk = uint.Parse(maskedTextBoxMaxAtk.Text); uint maxdef = uint.Parse(maskedTextBoxMaxDef.Text); uint maxspa = uint.Parse(maskedTextBoxMaxSpA.Text); uint maxspd = uint.Parse(maskedTextBoxMaxSpD.Text); uint maxspe = uint.Parse(maskedTextBoxMaxSpe.Text); var nature = (uint) comboBoxNatureXD.SelectedIndex; var XDGenerator = new FrameGenerator(); List<Frame> frames = XDGenerator.Generate(minhp, maxhp, minatk, maxatk, mindef, maxdef, minspa, maxspa, minspd, maxspd, minspe, maxspe, nature); var iframes = new List<IFrameCaptureXD>(); foreach (Frame frame in frames) { var iframe = new IFrameCaptureXD {Frame = frame}; // We're calibrating only with shadow Pokémon that are generated first in the party. // There are 375451 frames between the initial seed generation and Pokémon generation, // so we need to reverse the RNG that many frames var reverseRNG = new XdRngR(frame.Seed); for (int i = 0; i < 375450; i++) { reverseRNG.GetNext32BitNumber(); } iframe.Seed = reverseRNG.GetNext32BitNumber(); //iframe.Seed = frame.Seed; iframes.Add(iframe); } dataGridViewXDCalibration.DataSource = iframes; }
private void buttonGenerateEIVs_Click(object sender, EventArgs e) { const uint seed = 0x0; var parentA = new uint[6]; var parentB = new uint[6]; uint.TryParse(textEIVParentA_HP.Text, out parentA[0]); uint.TryParse(textEIVParentA_Atk.Text, out parentA[1]); uint.TryParse(textEIVParentA_Def.Text, out parentA[2]); uint.TryParse(textEIVParentA_SpA.Text, out parentA[3]); uint.TryParse(textEIVParentA_SpD.Text, out parentA[4]); uint.TryParse(textEIVParentA_Spe.Text, out parentA[5]); uint.TryParse(textEIVParentB_HP.Text, out parentB[0]); uint.TryParse(textEIVParentB_Atk.Text, out parentB[1]); uint.TryParse(textEIVParentB_Def.Text, out parentB[2]); uint.TryParse(textEIVParentB_SpA.Text, out parentB[3]); uint.TryParse(textEIVParentB_SpD.Text, out parentB[4]); uint.TryParse(textEIVParentB_Spe.Text, out parentB[5]); uint maxPickupFrame; uint minPickupFrame; if (!ParseInputD(textEIVMinFrame, out minPickupFrame) || !ParseInputD(textEIVMaxFrame, out maxPickupFrame)) return; if (minPickupFrame > maxPickupFrame) { textEIVMinFrame.Focus(); textEIVMinFrame.SelectAll(); return; } ivGenerator = new FrameGenerator(); if (radioButtonEIVSplit.Checked) ivGenerator.FrameType = FrameType.BredSplit; else if (radioButtonEIVAlternate.Checked) ivGenerator.FrameType = FrameType.BredAlternate; else ivGenerator.FrameType = FrameType.Bred; ivGenerator.InitialFrame = minPickupFrame; ivGenerator.MaxResults = maxPickupFrame - minPickupFrame + 1; ivGenerator.InitialSeed = seed; ivGenerator.ParentA = parentA; ivGenerator.ParentB = parentB; subFrameCompare = new FrameCompare( parentA[0], parentA[1], parentA[2], parentA[3], parentA[4], parentA[5], parentB[0], parentB[1], parentB[2], parentB[3], parentB[4], parentB[5], ivFiltersEEgg.IVFilter, null, -1, false, true, new NoGenderFilter()); // Here we check the parent IVs // To make sure they even have a chance of producing the desired spread int parentPassCount = 0; for (int i = 0; i < 6; i++) { if (subFrameCompare.CompareIV(i, parentA[i]) || subFrameCompare.CompareIV(i, parentB[i])) { parentPassCount++; } } if (parentPassCount < 3) { MessageBox.Show("The parent IVs you have listed cannot produce your desired search results."); return; } iframesEEggIV = new List<IFrameEEggPID>(); listBindingEggEIV = new BindingSource {DataSource = iframesEEggIV}; dataGridViewEIVs.DataSource = listBindingEggEIV; progressSearched = 0; progressFound = 0; progressTotal = 0; waitHandle = new EventWaitHandle(true, EventResetMode.ManualReset); jobs = new Thread[1]; jobs[0] = new Thread(Generate3rdGenEIVJob); jobs[0].Start(); Thread.Sleep(200); var progressJob = new Thread( () => ManageProgress(listBindingEggEIV, dataGridViewEIVs, ivGenerator.FrameType, 0)); progressJob.Start(); progressJob.Priority = ThreadPriority.Lowest; buttonShiny3rdGenerate.Enabled = false; }
private void Generate() { var profile = (Profile) comboBoxProfiles.SelectedItem; uint minFrame = uint.Parse(maskedTextBoxCapMinOffset.Text); uint maxFrame = uint.Parse(maskedTextBoxCapMaxOffset.Text); DateTime seedTime = datePicker.Value; iframes = new List<IFrameCapture>(); generator = new FrameGenerator { FrameType = (FrameType) ((ComboBoxItem) comboBoxMethod.SelectedItem).Reference, EncounterType = (EncounterType) ((ComboBoxItem) comboBoxEncounterType.SelectedItem).Reference, EncounterMod = (EncounterMod) ((ComboBoxItem) comboBoxLead.SelectedItem).Reference, SynchNature = -2, InitialFrame = minFrame + (profile.IsBW2() ? 2u : 0), MaxResults = maxFrame - minFrame + 1 }; // Now that each combo box item is a custom object containing the FrameType reference // We can simply retrieve the FrameType from the selected item frameCompare = new FrameCompare( 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, null, -1, false, false, false, null, new NoGenderFilter()); switch (generator.FrameType) { case FrameType.Method5Standard: CapSeed.DefaultCellStyle.Format = "X16"; EncounterSlot.Visible = false; PID.Visible = false; Shiny.Visible = false; Nature.Visible = false; Ability.Visible = false; CapHP.Visible = true; CapAtk.Visible = true; CapDef.Visible = true; CapSpA.Visible = true; CapSpD.Visible = true; CapSpe.Visible = true; f25.Visible = false; f50.Visible = false; f75.Visible = false; f125.Visible = false; break; case FrameType.Method5Natures: CapSeed.DefaultCellStyle.Format = "X16"; if (generator.EncounterType != EncounterType.Stationary && generator.EncounterType != EncounterType.Gift && generator.EncounterType != EncounterType.Roamer && generator.EncounterType != EncounterType.LarvestaEgg) EncounterSlot.Visible = true; else EncounterSlot.Visible = false; PID.Visible = true; Shiny.Visible = true; Nature.Visible = true; Ability.Visible = true; CapHP.Visible = false; CapAtk.Visible = false; CapDef.Visible = false; CapSpA.Visible = false; CapSpD.Visible = false; CapSpe.Visible = false; f25.Visible = true; f50.Visible = true; f75.Visible = true; f125.Visible = true; break; case FrameType.BWBred: generator.FrameType = FrameType.Method5Standard; generator.InitialFrame = 14; generator.MaxResults = 7; CapSeed.DefaultCellStyle.Format = "X16"; EncounterSlot.Visible = false; PID.Visible = false; Shiny.Visible = false; Nature.Visible = false; Ability.Visible = false; CapHP.Visible = true; CapAtk.Visible = true; CapDef.Visible = true; CapSpA.Visible = true; CapSpD.Visible = true; CapSpe.Visible = true; f25.Visible = false; f50.Visible = false; f75.Visible = false; f125.Visible = false; break; case FrameType.Wondercard5thGen: case FrameType.Wondercard5thGenFixed: CapSeed.DefaultCellStyle.Format = "X16"; EncounterSlot.Visible = false; PID.Visible = false; Shiny.Visible = false; Nature.Visible = true; Ability.Visible = false; CapHP.Visible = true; CapAtk.Visible = true; CapDef.Visible = true; CapSpA.Visible = true; CapSpD.Visible = true; CapSpe.Visible = true; f25.Visible = false; f50.Visible = false; f75.Visible = false; f125.Visible = false; break; } for (int seconds = (int) numericUpDownSeconds.Value*-1; seconds <= numericUpDownSeconds.Value; seconds++) { for (uint timer0 = profile.Timer0Min - 1; timer0 <= profile.Timer0Max + 1; timer0++) { ulong seed = Functions.EncryptSeed(seedTime.AddSeconds(seconds), profile.MAC_Address, profile.Version, profile.Language, profile.DSType, profile.SoftReset, profile.VCount, timer0, profile.GxStat, profile.VFrame, buttonValue()); if (seconds == 0 && timer0 == profile.Timer0Min) { seedMatch = seed; } switch (generator.FrameType) { case FrameType.Method5Standard: generator.InitialSeed = seed >> 32; break; case FrameType.Method5Natures: case FrameType.Wondercard5thGen: case FrameType.Wondercard5thGenFixed: generator.InitialSeed = seed; generator.InitialFrame = Functions.initialPIDRNG(seed, profile) + minFrame; break; } List<Frame> frames = generator.Generate(frameCompare, profile.ID, profile.SID); foreach (Frame frame in frames) { var iframe = new IFrameCapture(); frame.DisplayPrep(); iframe.Offset = frame.Number; iframe.Seed = seed; iframe.Frame = frame; iframe.TimeDate = seedTime.AddSeconds(seconds); iframe.Timer0 = timer0; iframes.Add(iframe); } } } listBindingCap = new BindingSource {DataSource = iframes}; dataGridViewCapValues.DataSource = listBindingCap; foreach (DataGridViewRow row in dataGridViewCapValues.Rows) { if ((ulong) row.Cells[0].Value == seedMatch) { dataGridViewCapValues.CurrentCell = row.Cells[0]; dataGridViewCapValues.FirstDisplayedScrollingRowIndex = row.Index; break; } } dataGridViewCapValues.Focus(); }
private void Generate() { // We want to force an early garbage collection // Because the frame lists get very big, very fast if (frames != null) { frames.Clear(); frames = null; } // Nuke the target frame when we generate a new list. This may // end up being controversial need to be revisted, but we can // do this at a later time after we get a complaint. :) SetTargetFrame(-1); // = 0; // Set up generator settings var generator = new FrameGenerator { FrameType = (FrameType) ((ComboBoxItem) comboBoxMethod.SelectedItem).Reference, EncounterMod = currentMod }; var offset = (uint) (checkBoxBW2.Visible && checkBoxBW2.Checked && generator.FrameType != FrameType.Method5Natures && generator.FrameType != FrameType.BWBred && generator.FrameType != FrameType.BWBredInternational ? 2 : 0); if (generator.FrameType == FrameType.BWBred && checkBoxBW2.Checked) generator.FrameType = FrameType.BW2Bred; if (generator.FrameType == FrameType.BWBredInternational && checkBoxBW2.Checked) generator.FrameType = FrameType.BW2BredInternational; if (currentMod == EncounterMod.Synchronize && comboBoxSynchNatures.SelectedIndex == 0) { generator.EncounterMod = EncounterMod.None; } if (currentMod == EncounterMod.CuteCharm) generator.SynchNature = (int) ((ComboBoxItem) comboBoxSynchNatures.SelectedItem).Reference; else generator.SynchNature = ((Nature) comboBoxSynchNatures.SelectedItem).Number; generator.EncounterType = EncounterTypeCalc.EncounterString(comboBoxEncounterType.Text); generator.DittoUsed = checkBoxDittoParent.Checked; generator.MaleOnlySpecies = cbNidoBeat.Checked; generator.ShinyCharm = cbShinyCharm.Checked; // this is for PIDRNG encounter slots generator.isBW2 = checkBoxBW2.Visible && checkBoxBW2.Checked; if (generator.EncounterType == EncounterType.SafariZone || generator.EncounterType == EncounterType.BugCatchingContest && !szWarned) { var warning = new WarningSZ(); warning.ShowDialog(); szWarned = true; } // Build up a FrameComparer List<int> encounterSlots = null; if (comboBoxEncounterSlot.Text != "Any" && comboBoxEncounterSlot.CheckBoxItems.Count > 0) { encounterSlots = new List<int>(); for (int i = 0; i < comboBoxEncounterSlot.CheckBoxItems.Count; i++) { if (comboBoxEncounterSlot.CheckBoxItems[i].Checked) // We have to subtract 1 because this custom control contains a hidden item for text display encounterSlots.Add(i - 1); } } List<uint> natures = null; if (comboBoxNature.Text != "Any" && comboBoxNature.CheckBoxItems.Count > 0) { natures = (from t in comboBoxNature.CheckBoxItems where t.Checked select (uint) ((Nature) t.ComboBoxItem).Number).ToList(); } generator.ParentA = parentA; generator.ParentB = parentB; generator.RNGIVs = rngIVs; FrameCompare frameCompare; // Create separate FrameCompares for methods that don't produce natures or IVs if (generator.FrameType == FrameType.Method5Standard || generator.FrameType == FrameType.Method5CGear || (generator.FrameType == FrameType.WondercardIVs && generator.EncounterType != EncounterType.Manaphy) || generator.FrameType == FrameType.Bred || generator.FrameType == FrameType.BredAlternate || generator.FrameType == FrameType.BredSplit || generator.FrameType == FrameType.RSBredUpper || generator.FrameType == FrameType.RSBredUpperAlt || generator.FrameType == FrameType.RSBredUpperSplit || generator.FrameType == FrameType.DPPtBred || generator.FrameType == FrameType.HGSSBred) { frameCompare = new FrameCompare( ivFilters.IVFilter, null, -1, false, false, false, null, new NoGenderFilter()); } else if (generator.FrameType == FrameType.Method5Natures) { frameCompare = new FrameCompare( 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, natures, (int) ((ComboBoxItem) comboBoxAbility.SelectedItem).Reference, checkBoxShinyOnly.Checked, checkBoxSynchOnly.Checked, false, encounterSlots, (GenderFilter) (comboBoxGender.SelectedItem)); generator.RNGIVs = rngIVs; } else if (generator.FrameType == FrameType.Gen4Normal || generator.FrameType == FrameType.Gen4International) { frameCompare = new FrameCompare( 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, natures, (int) ((ComboBoxItem) comboBoxAbility.SelectedItem).Reference, checkBoxShinyOnly.Checked, false, false, null, (GenderFilter) (comboBoxGender.SelectedItem)); } else if (generator.FrameType == FrameType.Method1 || generator.FrameType == FrameType.Method2 || generator.FrameType == FrameType.Method3 || generator.FrameType == FrameType.Method4 || generator.FrameType == FrameType.ChainedShiny || generator.FrameType == FrameType.ColoXD || generator.FrameType == FrameType.WondercardIVs) { frameCompare = new FrameCompare( ivFilters.IVFilter, natures, (int) ((ComboBoxItem) comboBoxAbility.SelectedItem).Reference, checkBoxShinyOnly.Checked, false, false, null, (GenderFilter) (comboBoxGender.SelectedItem)); } else if (generator.FrameType == FrameType.Wondercard5thGen || generator.FrameType == FrameType.Wondercard5thGenFixed) { frameCompare = new FrameCompare( ivFilters.IVFilter, natures, (int) ((ComboBoxItem) comboBoxAbility.SelectedItem).Reference, checkBoxShinyOnly.Checked, false, false, null, new NoGenderFilter()); } else if (generator.FrameType == FrameType.BWBred || generator.FrameType == FrameType.BWBredInternational || generator.FrameType == FrameType.BW2Bred || generator.FrameType == FrameType.BW2BredInternational) { if (parentA != null && parentB != null && rngIVs != null) { frameCompare = new FrameCompare( ivFilters.IVFilter, natures, (int) ((ComboBoxItem) comboBoxAbility.SelectedItem).Reference, checkBoxShinyOnly.Checked, checkBoxSynchOnly.Checked, checkBoxDreamWorld.Checked, null, (GenderFilter) (comboBoxGender.SelectedItem)); } else { frameCompare = new FrameCompare( 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, natures, (int) ((ComboBoxItem) comboBoxAbility.SelectedItem).Reference, checkBoxShinyOnly.Checked, checkBoxSynchOnly.Checked, checkBoxDreamWorld.Checked, null, (GenderFilter) (comboBoxGender.SelectedItem)); } } else { frameCompare = new FrameCompare( ivFilters.IVFilter, natures, (int) ((ComboBoxItem) comboBoxAbility.SelectedItem).Reference, checkBoxShinyOnly.Checked, checkBoxSynchOnly.Checked, false, encounterSlots, (GenderFilter) (comboBoxGender.SelectedItem)); } ulong seed = 0; if (textBoxSeed.Text != "") { if ((generator.FrameType == FrameType.BWBred || generator.FrameType == FrameType.BWBredInternational || generator.FrameType == FrameType.BW2Bred || generator.FrameType == FrameType.BW2BredInternational || generator.FrameType == FrameType.Method5Natures) && textBoxSeed.Text.Length == 8) { MessageBox.Show("This method requires you to copy the Full Seed from the Time Finder window."); seed = ulong.Parse(textBoxSeed.Text, NumberStyles.HexNumber); } else if (generator.FrameType == FrameType.Method5Standard && textBoxSeed.Text.Length > 8) { seed = ulong.Parse(textBoxSeed.Text.Substring(0, textBoxSeed.Text.Length - 8), NumberStyles.HexNumber); } else { seed = ulong.Parse(textBoxSeed.Text, NumberStyles.HexNumber); } } generator.InitialSeed = seed; // Handle add seed finding activities labelFlipsForSeed.Text = CoinFlips.GetFlips((uint) seed, 10); // 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( (uint) 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 labelElmForSeed.Text = Responses.ElmResponses((uint) seed, 10, information.RngCalls); if (maskedTextBoxStartingFrame.Text != "") { ulong startingFrame; ulong.TryParse(maskedTextBoxStartingFrame.Text, out startingFrame); if (startingFrame > uint.MaxValue) startingFrame = uint.MaxValue - offset; generator.InitialFrame = (uint) startingFrame; generator.InitialFrame += offset; } if (maskedTextBoxMaxFrames.Text != "") { ulong maxFrames; ulong.TryParse(maskedTextBoxMaxFrames.Text, out maxFrames); if (maxFrames > uint.MaxValue) maxFrames = uint.MaxValue; generator.MaxResults = (uint) maxFrames; } // Figure out if we have something good to pass in // for the ID and Secret ID to do shiny calculations. ushort id; ushort sid; ushort.TryParse(maskedTextBoxID.Text, out id); ushort.TryParse(maskedTextBoxSID.Text, out sid); // This is where we actually go ahead and call our // generator for a list of IVs based on parameters // that have been passed in. frames = generator.Generate(frameCompare, id, sid); foreach (Frame frame in frames) { frame.DisplayPrep(); } Frame.DataPropertyName = generator.FrameType == FrameType.BredSplit ? "Name" : "Number"; HP.DataPropertyName = "DisplayHp"; Atk.DataPropertyName = "DisplayAtk"; Def.DataPropertyName = "DisplayDef"; SpA.DataPropertyName = "DisplaySpa"; SpD.DataPropertyName = "DisplaySpd"; Spe.DataPropertyName = "DisplaySpe"; Characteristic.Visible = false; PossibleShakingSpot.Visible = false; if (parentA != null && parentB != null && rngIVs != null) { if (generator.FrameType == FrameType.Bred || generator.FrameType == FrameType.BredSplit || generator.FrameType == FrameType.BredAlternate || generator.FrameType == FrameType.RSBredUpper || generator.FrameType == FrameType.RSBredUpperAlt || generator.FrameType == FrameType.RSBredUpperSplit || generator.FrameType == FrameType.DPPtBred || generator.FrameType == FrameType.HGSSBred) { foreach (Frame frame in frames) { frame.DisplayHpAlt = (frame.DisplayHp == "A" || frame.DisplayHp == "B") ? (frame.DisplayHp == "A" ? Functions.NullIV(parentA[0], "A") : Functions.NullIV(parentB[0], "B")) : frame.DisplayHp; frame.DisplayAtkAlt = (frame.DisplayAtk == "A" || frame.DisplayAtk == "B") ? (frame.DisplayAtk == "A" ? Functions.NullIV(parentA[1], "A") : Functions.NullIV(parentB[1], "B")) : frame.DisplayAtk; frame.DisplayDefAlt = (frame.DisplayDef == "A" || frame.DisplayDef == "B") ? (frame.DisplayDef == "A" ? Functions.NullIV(parentA[2], "A") : Functions.NullIV(parentB[2], "B")) : frame.DisplayDef; frame.DisplaySpaAlt = (frame.DisplaySpa == "A" || frame.DisplaySpa == "B") ? (frame.DisplaySpa == "A" ? Functions.NullIV(parentA[3], "A") : Functions.NullIV(parentB[3], "B")) : frame.DisplaySpa; frame.DisplaySpdAlt = (frame.DisplaySpd == "A" || frame.DisplaySpd == "B") ? (frame.DisplaySpd == "A" ? Functions.NullIV(parentA[4], "A") : Functions.NullIV(parentB[4], "B")) : frame.DisplaySpd; frame.DisplaySpeAlt = (frame.DisplaySpe == "A" || frame.DisplaySpe == "B") ? (frame.DisplaySpe == "A" ? Functions.NullIV(parentA[5], "A") : Functions.NullIV(parentB[5], "B")) : frame.DisplaySpe; } HP.DataPropertyName = "DisplayHpAlt"; Atk.DataPropertyName = "DisplayAtkAlt"; Def.DataPropertyName = "DisplayDefAlt"; SpA.DataPropertyName = "DisplaySpaAlt"; SpD.DataPropertyName = "DisplaySpdAlt"; Spe.DataPropertyName = "DisplaySpeAlt"; } if (generator.FrameType == FrameType.BWBred || generator.FrameType == FrameType.BWBredInternational || generator.FrameType == FrameType.BWBred || generator.FrameType == FrameType.BWBredInternational) { foreach (Frame frame in frames) { frame.DisplayHpAlt = string.IsNullOrEmpty(frame.DisplayHp) ? Functions.NullIV(rngIVs[0]) : (frame.DisplayHp == "Fe" ? Functions.NullIV(parentA[0], "Fe") : Functions.NullIV(parentB[0], "Ma")); frame.DisplayAtkAlt = string.IsNullOrEmpty(frame.DisplayAtk) ? Functions.NullIV(rngIVs[1]) : (frame.DisplayAtk == "Fe" ? Functions.NullIV(parentA[1], "Fe") : Functions.NullIV(parentB[1], "Ma")); frame.DisplayDefAlt = string.IsNullOrEmpty(frame.DisplayDef) ? Functions.NullIV(rngIVs[2]) : (frame.DisplayDef == "Fe" ? Functions.NullIV(parentA[2], "Fe") : Functions.NullIV(parentB[2], "Ma")); frame.DisplaySpaAlt = string.IsNullOrEmpty(frame.DisplaySpa) ? Functions.NullIV(rngIVs[3]) : (frame.DisplaySpa == "Fe" ? Functions.NullIV(parentA[3], "Fe") : Functions.NullIV(parentB[3], "Ma")); frame.DisplaySpdAlt = string.IsNullOrEmpty(frame.DisplaySpd) ? Functions.NullIV(rngIVs[4]) : (frame.DisplaySpd == "Fe" ? Functions.NullIV(parentA[4], "Fe") : Functions.NullIV(parentB[4], "Ma")); frame.DisplaySpeAlt = string.IsNullOrEmpty(frame.DisplaySpe) ? Functions.NullIV(rngIVs[5]) : (frame.DisplaySpe == "Fe" ? Functions.NullIV(parentA[5], "Fe") : Functions.NullIV(parentB[5], "Ma")); if (completeIVs) { var DisplayIVs = new[] { uint.Parse(frame.DisplayHpAlt), uint.Parse(frame.DisplayAtkAlt), uint.Parse(frame.DisplayDefAlt), uint.Parse(frame.DisplaySpeAlt), uint.Parse(frame.DisplaySpaAlt), uint.Parse(frame.DisplaySpdAlt) }; frame.CharacteristicIVs = DisplayIVs; } HP.DataPropertyName = "DisplayHpAlt"; Atk.DataPropertyName = "DisplayAtkAlt"; Def.DataPropertyName = "DisplayDefAlt"; SpA.DataPropertyName = "DisplaySpaAlt"; SpD.DataPropertyName = "DisplaySpdAlt"; Spe.DataPropertyName = "DisplaySpeAlt"; } Characteristic.Visible = completeIVs; } if (generator.FrameType == FrameType.Method5Natures && rngIVsOnly) { // make the characteristic IVs, we need to clone the array because the function moves them uint[] characteristicIVs = Functions.moveSpeFromBack(rngIVs); foreach (Frame frame in frames) { frame.CharacteristicIVs = characteristicIVs; } Characteristic.Visible = true; } } // Hide some columns based on output type if (generator.FrameType == FrameType.RSBredLower) { Frame.Visible = true; Offset.Visible = false; EncounterSlot.Visible = false; ItemCalc.Visible = false; PID.Visible = true; Time.Visible = true; Time.DataPropertyName = "Time"; Shiny.Visible = false; Nature.Visible = false; Ability.Visible = true; Dream.Visible = false; Coin.Visible = false; Elm.Visible = false; Chatot.Visible = false; CaveSpot.Visible = false; HP.Visible = false; Atk.Visible = false; Def.Visible = false; SpA.Visible = false; SpD.Visible = false; Spe.Visible = false; HiddenPower.Visible = false; HiddenPowerPower.Visible = false; f50.Visible = false; f125.Visible = false; f25.Visible = false; f75.Visible = false; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; } // Hide some columns based on output type if (generator.FrameType == FrameType.RSBredUpper || generator.FrameType == FrameType.RSBredUpperSplit) { Frame.Visible = true; Offset.Visible = false; EncounterSlot.Visible = false; ItemCalc.Visible = false; PID.Visible = true; Time.Visible = true; Time.DataPropertyName = "Time"; Shiny.Visible = true; Nature.Visible = true; Ability.Visible = true; Dream.Visible = false; Coin.Visible = false; Elm.Visible = false; Chatot.Visible = false; CaveSpot.Visible = false; HP.Visible = true; Atk.Visible = true; Def.Visible = true; SpA.Visible = true; SpD.Visible = true; Spe.Visible = true; HiddenPower.Visible = false; HiddenPowerPower.Visible = false; f50.Visible = true; f125.Visible = true; f25.Visible = true; f75.Visible = true; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; } // Hide some columns based on output type if (generator.FrameType == FrameType.Bred || generator.FrameType == FrameType.BredSplit || generator.FrameType == FrameType.BredAlternate || generator.FrameType == FrameType.RSBredUpper || generator.FrameType == FrameType.RSBredUpperAlt || generator.FrameType == FrameType.RSBredUpperSplit) { Frame.Visible = true; Offset.Visible = false; EncounterSlot.Visible = false; ItemCalc.Visible = false; PID.Visible = false; Time.Visible = true; Time.DataPropertyName = "Time"; Shiny.Visible = false; Nature.Visible = false; Ability.Visible = false; Dream.Visible = false; Coin.Visible = false; Elm.Visible = false; Chatot.Visible = false; CaveSpot.Visible = false; HP.Visible = true; Atk.Visible = true; Def.Visible = true; SpA.Visible = true; SpD.Visible = true; Spe.Visible = true; HiddenPower.Visible = false; HiddenPowerPower.Visible = false; f50.Visible = false; f125.Visible = false; f25.Visible = false; f75.Visible = false; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; } // Hide some columns based on output type if (generator.FrameType == FrameType.Method5Standard || generator.FrameType == FrameType.Method5CGear) { Frame.Visible = true; Offset.Visible = false; EncounterSlot.Visible = false; ItemCalc.Visible = false; PID.Visible = false; Time.Visible = false; Shiny.Visible = false; Nature.Visible = false; Ability.Visible = false; Dream.Visible = false; Coin.Visible = false; Elm.Visible = false; Chatot.Visible = false; CaveSpot.Visible = false; HP.Visible = true; Atk.Visible = true; Def.Visible = true; SpA.Visible = true; SpD.Visible = true; Spe.Visible = true; HiddenPower.Visible = true; HiddenPowerPower.Visible = true; f50.Visible = false; f125.Visible = false; f25.Visible = false; f75.Visible = false; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; } else if (generator.FrameType == FrameType.DPPtBred) { Frame.Visible = true; Offset.Visible = false; EncounterSlot.Visible = false; ItemCalc.Visible = false; PID.Visible = false; Time.Visible = false; Shiny.Visible = false; Nature.Visible = false; Ability.Visible = false; Dream.Visible = false; Coin.Visible = false; Elm.Visible = false; Chatot.Visible = true; Chatot.DataPropertyName = "Chatot"; CaveSpot.Visible = false; HP.Visible = true; Atk.Visible = true; Def.Visible = true; SpA.Visible = true; SpD.Visible = true; Spe.Visible = true; HiddenPower.Visible = false; HiddenPowerPower.Visible = false; f50.Visible = false; f125.Visible = false; f25.Visible = false; f75.Visible = false; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; } if (generator.FrameType == FrameType.Method5Natures) { Frame.Visible = true; Offset.Visible = false; if (generator.EncounterType != EncounterType.Stationary && generator.EncounterType != EncounterType.Gift && generator.EncounterType != EncounterType.Roamer && generator.EncounterType != EncounterType.LarvestaEgg && generator.EncounterType != EncounterType.Entralink && generator.EncounterType != EncounterType.HiddenGrotto) EncounterSlot.Visible = true; else EncounterSlot.Visible = false; ItemCalc.Visible = false; PID.Visible = true; if (generator.EncounterType == EncounterType.Entralink) { Time.Visible = true; Time.DataPropertyName = "EntralinkTime"; } else { Time.Visible = false; Time.DataPropertyName = "Time"; } Shiny.Visible = true; Nature.Visible = true; Ability.Visible = true; Dream.Visible = false; Coin.Visible = false; Elm.Visible = false; Chatot.Visible = true; Chatot.DataPropertyName = "Chatot64"; if (generator.EncounterType == EncounterType.WildCaveSpot || generator.EncounterType == EncounterType.WildWaterSpot || generator.EncounterType == EncounterType.WildShakerGrass) { CaveSpot.Visible = true; if (generator.EncounterType == EncounterType.WildCaveSpot) CaveSpot.HeaderText = "Cave Spot"; else if (generator.EncounterType == EncounterType.WildWaterSpot) CaveSpot.HeaderText = "Bubble Spot"; else CaveSpot.HeaderText = "Shaking Grass"; } else { CaveSpot.Visible = false; } HP.Visible = false; Atk.Visible = false; Def.Visible = false; SpA.Visible = false; SpD.Visible = false; Spe.Visible = false; HiddenPower.Visible = false; HiddenPowerPower.Visible = false; f50.Visible = true; f125.Visible = true; f25.Visible = true; f75.Visible = true; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; } // Hide some columns based on output type if (generator.FrameType == FrameType.HGSSBred) { Frame.Visible = true; Offset.Visible = false; EncounterSlot.Visible = false; ItemCalc.Visible = false; PID.Visible = false; Time.Visible = false; Shiny.Visible = false; Nature.Visible = false; Ability.Visible = false; Dream.Visible = false; Coin.Visible = false; Elm.Visible = true; Chatot.Visible = true; Chatot.DataPropertyName = "Chatot"; CaveSpot.Visible = false; HP.Visible = true; Atk.Visible = true; Def.Visible = true; SpA.Visible = true; SpD.Visible = true; Spe.Visible = true; HiddenPower.Visible = false; HiddenPowerPower.Visible = false; f50.Visible = false; f125.Visible = false; f25.Visible = false; f75.Visible = false; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; } // Hide some columns based on output type if (generator.FrameType == FrameType.WondercardIVs) { if (generator.EncounterType == EncounterType.Manaphy) { PID.Visible = true; Nature.Visible = true; } else { PID.Visible = false; Nature.Visible = false; } Frame.Visible = true; Offset.Visible = false; EncounterSlot.Visible = false; ItemCalc.Visible = false; Time.Visible = false; Shiny.Visible = false; Ability.Visible = false; Dream.Visible = false; Coin.Visible = false; Elm.Visible = true; Chatot.Visible = true; Chatot.DataPropertyName = "Chatot"; CaveSpot.Visible = false; HP.Visible = true; Atk.Visible = true; Def.Visible = true; SpA.Visible = true; SpD.Visible = true; Spe.Visible = true; HiddenPower.Visible = true; HiddenPowerPower.Visible = true; f50.Visible = false; f125.Visible = false; f25.Visible = false; f75.Visible = false; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; } if (generator.FrameType == FrameType.Gen4Normal || generator.FrameType == FrameType.Gen4International) { // Hide IV columns Frame.Visible = true; Offset.Visible = false; EncounterSlot.Visible = false; ItemCalc.Visible = false; PID.Visible = true; Time.Visible = false; Shiny.Visible = true; Nature.Visible = true; Ability.Visible = true; Dream.Visible = false; Coin.Visible = true; Elm.Visible = false; Chatot.Visible = false; CaveSpot.Visible = false; HP.Visible = false; Atk.Visible = false; Def.Visible = false; SpA.Visible = false; SpD.Visible = false; Spe.Visible = false; HiddenPower.Visible = false; HiddenPowerPower.Visible = false; f50.Visible = true; f125.Visible = true; f25.Visible = true; f75.Visible = true; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; } if (generator.FrameType == FrameType.Method1) { // Show ALL columns Frame.Visible = true; Offset.Visible = false; EncounterSlot.Visible = false; ItemCalc.Visible = false; PID.Visible = true; Time.Visible = true; Time.DataPropertyName = "Time"; Shiny.Visible = true; Nature.Visible = true; Ability.Visible = true; Dream.Visible = false; Coin.Visible = false; Elm.Visible = true; Chatot.Visible = true; Chatot.DataPropertyName = "Chatot"; CaveSpot.Visible = false; HP.Visible = true; Atk.Visible = true; Def.Visible = true; SpA.Visible = true; SpD.Visible = true; Spe.Visible = true; HiddenPower.Visible = true; HiddenPowerPower.Visible = true; f50.Visible = true; f125.Visible = true; f25.Visible = true; f75.Visible = true; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; } if (generator.FrameType == FrameType.Method2 || generator.FrameType == FrameType.Method3 || generator.FrameType == FrameType.Method4 || generator.FrameType == FrameType.ColoXD) { // Show ALL columns Frame.Visible = true; Offset.Visible = false; EncounterSlot.Visible = false; ItemCalc.Visible = false; PID.Visible = true; if (generator.FrameType != FrameType.ColoXD) { Time.Visible = true; Time.DataPropertyName = "Time"; } else { Time.Visible = false; } Shiny.Visible = true; Nature.Visible = true; Ability.Visible = true; Dream.Visible = false; Coin.Visible = false; Elm.Visible = false; Chatot.Visible = false; CaveSpot.Visible = false; HP.Visible = true; Atk.Visible = true; Def.Visible = true; SpA.Visible = true; SpD.Visible = true; Spe.Visible = true; HiddenPower.Visible = true; HiddenPowerPower.Visible = true; f50.Visible = true; f125.Visible = true; f25.Visible = true; f75.Visible = true; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; } if (generator.FrameType == FrameType.MethodJ || generator.FrameType == FrameType.ChainedShiny) { // Show ALL columns Frame.Visible = true; Offset.Visible = true; EncounterSlot.Visible = generator.EncounterType != EncounterType.Stationary; ItemCalc.Visible = false; PID.Visible = true; Time.Visible = false; Shiny.Visible = true; Nature.Visible = true; Ability.Visible = true; Dream.Visible = false; Coin.Visible = false; Elm.Visible = false; Chatot.Visible = true; Chatot.DataPropertyName = "Chatot"; CaveSpot.Visible = false; HP.Visible = true; Atk.Visible = true; Def.Visible = true; SpA.Visible = true; SpD.Visible = true; Spe.Visible = true; HiddenPower.Visible = true; HiddenPowerPower.Visible = true; f50.Visible = true; f125.Visible = true; f25.Visible = true; f75.Visible = true; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; if (generator.FrameType == FrameType.ChainedShiny) { Offset.Visible = false; EncounterSlot.Visible = false; } } if (generator.FrameType == FrameType.MethodK) { Frame.Visible = true; Offset.Visible = true; Elm.Visible = true; EncounterSlot.Visible = generator.EncounterType != EncounterType.Stationary; ItemCalc.Visible = false; PID.Visible = true; Time.Visible = false; Shiny.Visible = true; Nature.Visible = true; Ability.Visible = true; Dream.Visible = false; Coin.Visible = false; Chatot.Visible = true; Chatot.DataPropertyName = "Chatot"; CaveSpot.Visible = false; HP.Visible = true; Atk.Visible = true; Def.Visible = true; SpA.Visible = true; SpD.Visible = true; Spe.Visible = true; HiddenPower.Visible = true; HiddenPowerPower.Visible = true; f50.Visible = true; f125.Visible = true; f25.Visible = true; f75.Visible = true; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; } if (generator.FrameType == FrameType.MethodH1 || generator.FrameType == FrameType.MethodH2 || generator.FrameType == FrameType.MethodH4) { Frame.Visible = true; Offset.Visible = true; EncounterSlot.Visible = true; ItemCalc.Visible = false; PID.Visible = true; Time.Visible = true; Time.DataPropertyName = "Time"; Shiny.Visible = true; Nature.Visible = true; Ability.Visible = true; Dream.Visible = false; Coin.Visible = false; Elm.Visible = false; Chatot.Visible = false; CaveSpot.Visible = false; HP.Visible = true; Atk.Visible = true; Def.Visible = true; SpA.Visible = true; SpD.Visible = true; Spe.Visible = true; HiddenPower.Visible = true; HiddenPowerPower.Visible = true; f50.Visible = true; f125.Visible = true; f25.Visible = true; f75.Visible = true; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; } if (generator.FrameType == FrameType.Wondercard5thGen || generator.FrameType == FrameType.Wondercard5thGenFixed) { Frame.Visible = true; Offset.Visible = false; EncounterSlot.Visible = false; ItemCalc.Visible = false; PID.Visible = false; Time.Visible = false; Shiny.Visible = false; Nature.Visible = true; Ability.Visible = false; Dream.Visible = false; Coin.Visible = false; Elm.Visible = false; Chatot.Visible = true; Chatot.DataPropertyName = "Chatot64"; CaveSpot.Visible = false; HP.Visible = true; Atk.Visible = true; Def.Visible = true; SpA.Visible = true; SpD.Visible = true; Spe.Visible = true; HiddenPower.Visible = true; HiddenPowerPower.Visible = true; f50.Visible = true; f125.Visible = true; f25.Visible = true; f75.Visible = true; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = false; } if (generator.FrameType == FrameType.BWBred || generator.FrameType == FrameType.BWBredInternational || generator.FrameType == FrameType.BW2Bred || generator.FrameType == FrameType.BW2BredInternational) { // Show ALL columns Frame.Visible = true; Offset.Visible = false; EncounterSlot.Visible = false; ItemCalc.Visible = false; PID.Visible = true; Time.Visible = false; Shiny.Visible = true; Nature.Visible = true; Ability.Visible = true; Dream.Visible = true; Coin.Visible = false; Elm.Visible = false; Chatot.Visible = true; Chatot.DataPropertyName = "Chatot64"; CaveSpot.Visible = false; HP.Visible = true; Atk.Visible = true; Def.Visible = true; SpA.Visible = true; SpD.Visible = true; Spe.Visible = true; HiddenPower.Visible = false; HiddenPowerPower.Visible = false; f50.Visible = true; f125.Visible = true; f25.Visible = true; f75.Visible = true; PossibleShakingSpot.Visible = false; MaleOnlySpecies.Visible = true; } if (generator.FrameType == FrameType.BWBred || generator.FrameType == FrameType.BWBredInternational || generator.FrameType == FrameType.BW2Bred || generator.FrameType == FrameType.BW2BredInternational || generator.FrameType == FrameType.DPPtBred || generator.FrameType == FrameType.HGSSBred || generator.FrameType == FrameType.Bred || generator.FrameType == FrameType.BredSplit || generator.FrameType == FrameType.BredAlternate || generator.FrameType == FrameType.RSBredUpper || generator.FrameType == FrameType.RSBredUpperAlt || generator.FrameType == FrameType.RSBredUpperSplit || generator.FrameType == FrameType.Method5Natures) { displayParentsInSearchToolStripMenuItem.Enabled = true; if (generator.FrameType == FrameType.Method5Natures) { displayParentsInSearchToolStripMenuItem.Text = "Display Characteristics in Search..."; resetParentsToolStripMenuItem.Text = "Reset Characteristics"; } else { displayParentsInSearchToolStripMenuItem.Text = "Display Parents in Search..."; resetParentsToolStripMenuItem.Text = "Reset Parents"; } } else { displayParentsInSearchToolStripMenuItem.Enabled = false; } // update frame number for bw2 if (offset > 0) { foreach (Frame frame in frames) { frame.Number -= offset; } } // Bind our returned list of frames to the grid dataGridViewValues.DataSource = frames; }
private void Generate(FrameGenerator generator, IEnumerable<DateTime> possibleDates, uint minFrame, uint maxFrame, Profile profile, uint groupSize, uint calibratedDelay) { const uint incrementFound = 1; List<List<ButtonComboType>> keypresses = profile.GetKeypresses(); foreach (DateTime seedTime in possibleDates) { waitHandle.WaitOne(); foreach (var combo in keypresses) { for (uint timer0 = profile.Timer0Min; timer0 <= profile.Timer0Max; timer0++) { ulong seed = Functions.EncryptSeed(seedTime, profile, timer0, Functions.buttonMashed(combo)); generator.InitialSeed = seed; generator.InitialFrame = Functions.initialPIDRNG(seed, profile) + minFrame; generator.MaxResults = maxFrame - minFrame + 1; List<Frame> frames = generator.Generate(frameCompare, 0, 0); IFrameCapture previous = null; bool previouslyAdded = false; var frameGroup = new List<IFrameCapture>(); // quick check and if it's impossible that this is a match don't waste our time loop // breaks search progress so that needs to get fixed if (frames.Count < groupSize) continue; foreach (Frame frame in frames) { var iframe = new IFrameCapture { Offset = frame.Number, Seed = seed, Frame = frame, TimeDate = seedTime, Timer0 = timer0, Delay = calibratedDelay, KeyPresses = combo }; // Calibrated delay instead of the real delay for correct CGear Times if (previous != null && (iframe.Offset == previous.Offset + 1 || iframe.Offset == previous.Offset + 2)) { if (!previouslyAdded) frameGroup.Add(previous); frameGroup.Add(iframe); previouslyAdded = true; } else { if (frameGroup.Count >= groupSize) { lock (threadLock) { foreach (IFrameCapture t in frameGroup) t.Frame.Synchable = grey; iframes.AddRange(frameGroup); grey = !grey; } refreshQueue = true; progressFound += incrementFound; } frameGroup = new List<IFrameCapture>(); previouslyAdded = false; } previous = iframe; } progressSearched += (uint) frames.Count; if (frameGroup.Count >= groupSize) { lock (threadLock) { for (int i = 0; i < frameGroup.Count; ++i) frameGroup[i].Frame.Synchable = grey; iframes.AddRange(frameGroup); grey = !grey; } refreshQueue = true; progressFound += incrementFound; } } } } }
private void buttonSeedGenerate_Click(object sender, EventArgs e) { if (!ParametersInputCheck()) return; #region Initialize if (comboBoxNature.Text == "Any") { MessageBox.Show("Please select a specific list of natures."); return; } List<uint> natures = (from t in comboBoxNature.CheckBoxItems where t.Checked select (uint) ((Nature) t.ComboBoxItem).Number). ToList(); var profile = (Profile) comboBoxProfiles.SelectedItem; uint mac_partial = (uint) profile.MAC_Address & 0xFFFFFF; uint minFrame = uint.Parse(maskedTextBoxCapMinOffset.Text); uint maxFrame = uint.Parse(maskedTextBoxCapMaxOffset.Text); uint groupSize = uint.Parse(maskedTextBoxGroupSize.Text); uint seedCGear = uint.Parse(textBoxSeed.Text, NumberStyles.HexNumber); int generateYear = int.Parse(maskedTextBoxYear.Text); if (generateYear < 2000 || generateYear > 2099) { MessageBox.Show("Year must be a value between 2000 and 2099, inclusive."); return; } uint frameCGear = uint.Parse(maskedTextBoxCGearFrame.Text); //generate the CGear Seed Times uint ab = seedCGear - mac_partial >> 24; uint cd = (seedCGear - mac_partial & 0x00FF0000) >> 16; uint efgh = seedCGear - mac_partial & 0x0000FFFF; // Get Delay uint delay = efgh + (uint) (2000 - generateYear); // Get Calibration uint calibration = uint.Parse(maskedTextBoxDelayCalibration.Text); // Store the Calibrated Delay and offset uint calibratedDelay = delay + calibration; long offset = -calibratedDelay/60; // 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; } maskedTextBoxDelay.Text = delay.ToString(CultureInfo.InvariantCulture); List<List<ButtonComboType>> keypresses = GetKeypresses(); iframes = new List<IFrameCapture>(); var generator = new FrameGenerator { InitialSeed = seedCGear, FrameType = FrameType.Method5CGear, InitialFrame = frameCGear, MaxResults = 1 }; GenderFilter genderFilter = checkBoxGenderless.Checked ? new GenderFilter("Genderless", 0xFF, GenderCriteria.DontCareGenderless) : new GenderFilter("Gendered", 0, GenderCriteria.DontCareGenderless); var possibleDates = new List<DateTime>(); // 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)) continue; var dateTime = new DateTime(generateYear, month, day, hour, minute, second); // Standard seed time will be the C-Gear seed time, minus the delay // We'll skip seeds that cross over into the next day and cause unwanted advances // Added calibration to the delay to account for the fact that people aren't perfectly fast DateTime possibleDate = dateTime.AddSeconds(offset); if (dateTime.Day == possibleDate.Day) possibleDates.Add(possibleDate); } } } } // Generate the IVs for the corresponding C-Gear seed first var rngIVs = new uint[6]; frameCompare = new FrameCompare( 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, null, -1, false, false, false, null, new NoGenderFilter()); List<Frame> IVs = generator.Generate(frameCompare, 0, 0); if (IVs.Count > 0) { rngIVs[0] = IVs[0].Hp; rngIVs[1] = IVs[0].Atk; rngIVs[2] = IVs[0].Def; rngIVs[3] = IVs[0].Spa; rngIVs[4] = IVs[0].Spd; rngIVs[5] = IVs[0].Spe; } // Now that each combo box item is a custom object containing the FrameType reference // We can simply retrieve the FrameType from the selected item generator.FrameType = FrameType.Method5Natures; generator.EncounterType = EncounterType.Entralink; generator.RNGIVs = rngIVs; generator.InitialFrame = minFrame; generator.MaxResults = maxFrame - minFrame + 1; frameCompare = new FrameCompare( 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, null, -1, false, false, false, null, new NoGenderFilter()); frameCompare = new FrameCompare( 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, natures, -1, false, false, false, null, genderFilter); #endregion waitHandle = new EventWaitHandle(true, EventResetMode.ManualReset); jobs = new Thread[cpus]; //divide the possible times into even groups int split = possibleDates.Count/cpus; for (int i = 0; i < cpus; ++i) { List<DateTime> dates = i < cpus - 1 ? possibleDates.GetRange(i*split, split) : possibleDates.GetRange(i*split, split + possibleDates.Count%cpus); //if the last i make sure we add the remainder as well // technically supposed to copy profile and send in a copy because now the threads are // using a reference to the same profile but that's fine because the profile isn't getting // mutated anyway jobs[i] = new Thread( () => Generate(generator.Clone(), dates, minFrame, maxFrame, profile, groupSize, calibratedDelay)); jobs[i].Start(); } listBindingCap = new BindingSource {DataSource = iframes}; dataGridViewCapValues.DataSource = listBindingCap; progressTotal = (ulong) (maxFrame - minFrame + 1)*(profile.Timer0Max - profile.Timer0Min + 1)*(ulong) keypresses.Count* (ulong) possibleDates.Count; var progressJob = new Thread(() => ManageProgress(listBindingCap, dataGridViewCapValues, generator.FrameType, 0)); progressJob.Start(); progressJob.Priority = ThreadPriority.Lowest; buttonSeedGenerate.Enabled = false; }