diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs index 49c089c7f..fb5b4cd01 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs @@ -75,6 +75,24 @@ public EncounterCriteria() IV_SPE = RandomIV, }; + /// + /// Creates a new with random IVs. + /// + public EncounterCriteria ReviseIVsHyperTrainAvailable() => this with + { + IV_HP = ReviseForHyperTrain(IV_HP), + IV_ATK = ReviseForHyperTrain(IV_ATK), + IV_DEF = ReviseForHyperTrain(IV_DEF), + IV_SPA = ReviseForHyperTrain(IV_SPA), + IV_SPD = ReviseForHyperTrain(IV_SPD), + IV_SPE = ReviseForHyperTrain(IV_SPE), + }; + + /// + /// Keeps an IV only if it cannot be overridden in-game to that value (via hyper training). + /// + private static sbyte ReviseForHyperTrain(sbyte current) => current is 31 ? RandomIV : current; + /// /// Checks if the Hidden Power type for the given IVs matches the specified HiddenPowerType. /// diff --git a/PKHeX.Core/Legality/RNG/Methods/Gen9/Encounter9RNG.cs b/PKHeX.Core/Legality/RNG/Methods/Gen9/Encounter9RNG.cs index cd2023207..a2c2ef351 100644 --- a/PKHeX.Core/Legality/RNG/Methods/Gen9/Encounter9RNG.cs +++ b/PKHeX.Core/Legality/RNG/Methods/Gen9/Encounter9RNG.cs @@ -21,7 +21,10 @@ public static bool TryApply32(this TEnc enc, PK9 pk, in ulong init, in Gen { uint seed = (uint)rand.NextInt(uint.MaxValue); if (!enc.CanBeEncountered(seed)) + { + ctr--; // don't consider it an attempt continue; + } if (!GenerateData(pk, param, criteria, seed, param.IVs.IsSpecified)) continue; diff --git a/PKHeX.WinForms/Subforms/SAV_Encounters.Designer.cs b/PKHeX.WinForms/Subforms/SAV_Encounters.Designer.cs index 343b6d629..ca2937ae0 100644 --- a/PKHeX.WinForms/Subforms/SAV_Encounters.Designer.cs +++ b/PKHeX.WinForms/Subforms/SAV_Encounters.Designer.cs @@ -34,7 +34,7 @@ private void InitializeComponent() Menu_Close = new System.Windows.Forms.ToolStripMenuItem(); Menu_Exit = new System.Windows.Forms.ToolStripMenuItem(); P_Results = new System.Windows.Forms.Panel(); - EncounterPokeGrid = new Controls.PokeGrid(); + EncounterPokeGrid = new PKHeX.WinForms.Controls.PokeGrid(); B_Search = new System.Windows.Forms.Button(); B_Reset = new System.Windows.Forms.Button(); L_Count = new System.Windows.Forms.Label(); @@ -45,8 +45,6 @@ private void InitializeComponent() mnuView = new System.Windows.Forms.ToolStripMenuItem(); TC_SearchOptions = new System.Windows.Forms.TabControl(); Tab_General = new System.Windows.Forms.TabPage(); - Tab_Advanced = new System.Windows.Forms.TabPage(); - B_Add = new System.Windows.Forms.Button(); TLP_Filters = new System.Windows.Forms.TableLayoutPanel(); Label_Species = new System.Windows.Forms.Label(); CB_Species = new System.Windows.Forms.ComboBox(); @@ -65,13 +63,15 @@ private void InitializeComponent() CHK_IsEgg = new System.Windows.Forms.CheckBox(); FLP_Egg = new System.Windows.Forms.FlowLayoutPanel(); CHK_Shiny = new System.Windows.Forms.CheckBox(); + Tab_Advanced = new System.Windows.Forms.TabPage(); + B_Add = new System.Windows.Forms.Button(); menuStrip1.SuspendLayout(); P_Results.SuspendLayout(); mnu.SuspendLayout(); TC_SearchOptions.SuspendLayout(); Tab_General.SuspendLayout(); - Tab_Advanced.SuspendLayout(); TLP_Filters.SuspendLayout(); + Tab_Advanced.SuspendLayout(); SuspendLayout(); // // SCR_Box @@ -91,7 +91,7 @@ private void InitializeComponent() menuStrip1.Location = new System.Drawing.Point(0, 0); menuStrip1.Name = "menuStrip1"; menuStrip1.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2); - menuStrip1.Size = new System.Drawing.Size(670, 24); + menuStrip1.Size = new System.Drawing.Size(670, 25); menuStrip1.TabIndex = 65; menuStrip1.Text = "menuStrip1"; // @@ -99,7 +99,7 @@ private void InitializeComponent() // Menu_Close.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { Menu_Exit }); Menu_Close.Name = "Menu_Close"; - Menu_Close.Size = new System.Drawing.Size(37, 20); + Menu_Close.Size = new System.Drawing.Size(39, 21); Menu_Close.Text = "File"; // // Menu_Exit @@ -108,7 +108,7 @@ private void InitializeComponent() Menu_Exit.Name = "Menu_Exit"; Menu_Exit.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E; Menu_Exit.ShowShortcutKeys = false; - Menu_Exit.Size = new System.Drawing.Size(96, 22); + Menu_Exit.Size = new System.Drawing.Size(100, 22); Menu_Exit.Text = "&Close"; Menu_Exit.Click += Menu_Exit_Click; // @@ -175,7 +175,7 @@ private void InitializeComponent() L_Viewed.Location = new System.Drawing.Point(10, 445); L_Viewed.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); L_Viewed.Name = "L_Viewed"; - L_Viewed.Size = new System.Drawing.Size(89, 15); + L_Viewed.Size = new System.Drawing.Size(99, 17); L_Viewed.TabIndex = 117; L_Viewed.Text = "Last Viewed: {0}"; L_Viewed.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -186,7 +186,7 @@ private void InitializeComponent() RTB_Instructions.Location = new System.Drawing.Point(0, 48); RTB_Instructions.Margin = new System.Windows.Forms.Padding(0); RTB_Instructions.Name = "RTB_Instructions"; - RTB_Instructions.Size = new System.Drawing.Size(298, 313); + RTB_Instructions.Size = new System.Drawing.Size(298, 311); RTB_Instructions.TabIndex = 119; RTB_Instructions.Text = ""; // @@ -194,13 +194,13 @@ private void InitializeComponent() // mnu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuView }); mnu.Name = "contextMenuStrip1"; - mnu.Size = new System.Drawing.Size(100, 26); + mnu.Size = new System.Drawing.Size(104, 26); // // mnuView // mnuView.Image = Properties.Resources.other; mnuView.Name = "mnuView"; - mnuView.Size = new System.Drawing.Size(99, 22); + mnuView.Size = new System.Drawing.Size(103, 22); mnuView.Text = "View"; mnuView.Click += ClickView; // @@ -219,39 +219,15 @@ private void InitializeComponent() // Tab_General // Tab_General.Controls.Add(TLP_Filters); - Tab_General.Location = new System.Drawing.Point(4, 24); + Tab_General.Location = new System.Drawing.Point(4, 26); Tab_General.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); Tab_General.Name = "Tab_General"; Tab_General.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); - Tab_General.Size = new System.Drawing.Size(300, 364); + Tab_General.Size = new System.Drawing.Size(300, 362); Tab_General.TabIndex = 0; Tab_General.Text = "General"; Tab_General.UseVisualStyleBackColor = true; // - // Tab_Advanced - // - Tab_Advanced.Controls.Add(B_Add); - Tab_Advanced.Controls.Add(RTB_Instructions); - Tab_Advanced.Location = new System.Drawing.Point(4, 24); - Tab_Advanced.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - Tab_Advanced.Name = "Tab_Advanced"; - Tab_Advanced.Size = new System.Drawing.Size(300, 364); - Tab_Advanced.TabIndex = 1; - Tab_Advanced.Text = "Advanced"; - Tab_Advanced.UseVisualStyleBackColor = true; - // - // B_Add - // - B_Add.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - B_Add.Location = new System.Drawing.Point(230, -1); - B_Add.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - B_Add.Name = "B_Add"; - B_Add.Size = new System.Drawing.Size(66, 27); - B_Add.TabIndex = 122; - B_Add.Text = "Add"; - B_Add.UseVisualStyleBackColor = true; - B_Add.Click += B_Add_Click; - // // TLP_Filters // TLP_Filters.AutoScroll = true; @@ -300,17 +276,17 @@ private void InitializeComponent() TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 23F)); - TLP_Filters.Size = new System.Drawing.Size(292, 358); + TLP_Filters.Size = new System.Drawing.Size(292, 356); TLP_Filters.TabIndex = 120; // // Label_Species // Label_Species.Anchor = System.Windows.Forms.AnchorStyles.Right; Label_Species.AutoSize = true; - Label_Species.Location = new System.Drawing.Point(27, 23); + Label_Species.Location = new System.Drawing.Point(21, 25); Label_Species.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); Label_Species.Name = "Label_Species"; - Label_Species.Size = new System.Drawing.Size(49, 15); + Label_Species.Size = new System.Drawing.Size(55, 17); Label_Species.TabIndex = 90; Label_Species.Text = "Species:"; Label_Species.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -321,17 +297,18 @@ private void InitializeComponent() CB_Species.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; CB_Species.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; CB_Species.FormattingEnabled = true; - CB_Species.Location = new System.Drawing.Point(80, 19); + CB_Species.Location = new System.Drawing.Point(80, 21); CB_Species.Margin = new System.Windows.Forms.Padding(0); CB_Species.Name = "CB_Species"; - CB_Species.Size = new System.Drawing.Size(142, 23); + CB_Species.Size = new System.Drawing.Size(142, 25); CB_Species.TabIndex = 67; + CB_Species.SelectedIndexChanged += CB_Species_SelectedIndexChanged; // // FLP_Level // FLP_Level.Anchor = System.Windows.Forms.AnchorStyles.Left; FLP_Level.AutoSize = true; - FLP_Level.Location = new System.Drawing.Point(80, 42); + FLP_Level.Location = new System.Drawing.Point(80, 46); FLP_Level.Margin = new System.Windows.Forms.Padding(0); FLP_Level.Name = "FLP_Level"; FLP_Level.Size = new System.Drawing.Size(0, 0); @@ -341,10 +318,10 @@ private void InitializeComponent() // L_Move1.Anchor = System.Windows.Forms.AnchorStyles.Right; L_Move1.AutoSize = true; - L_Move1.Location = new System.Drawing.Point(27, 46); + L_Move1.Location = new System.Drawing.Point(21, 50); L_Move1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); L_Move1.Name = "L_Move1"; - L_Move1.Size = new System.Drawing.Size(49, 15); + L_Move1.Size = new System.Drawing.Size(55, 17); L_Move1.TabIndex = 105; L_Move1.Text = "Move 1:"; L_Move1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -355,20 +332,20 @@ private void InitializeComponent() CB_Move1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; CB_Move1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; CB_Move1.FormattingEnabled = true; - CB_Move1.Location = new System.Drawing.Point(80, 42); + CB_Move1.Location = new System.Drawing.Point(80, 46); CB_Move1.Margin = new System.Windows.Forms.Padding(0); CB_Move1.Name = "CB_Move1"; - CB_Move1.Size = new System.Drawing.Size(142, 23); + CB_Move1.Size = new System.Drawing.Size(142, 25); CB_Move1.TabIndex = 71; // // L_Move2 // L_Move2.Anchor = System.Windows.Forms.AnchorStyles.Right; L_Move2.AutoSize = true; - L_Move2.Location = new System.Drawing.Point(27, 69); + L_Move2.Location = new System.Drawing.Point(21, 75); L_Move2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); L_Move2.Name = "L_Move2"; - L_Move2.Size = new System.Drawing.Size(49, 15); + L_Move2.Size = new System.Drawing.Size(55, 17); L_Move2.TabIndex = 106; L_Move2.Text = "Move 2:"; L_Move2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -379,20 +356,20 @@ private void InitializeComponent() CB_Move2.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; CB_Move2.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; CB_Move2.FormattingEnabled = true; - CB_Move2.Location = new System.Drawing.Point(80, 65); + CB_Move2.Location = new System.Drawing.Point(80, 71); CB_Move2.Margin = new System.Windows.Forms.Padding(0); CB_Move2.Name = "CB_Move2"; - CB_Move2.Size = new System.Drawing.Size(142, 23); + CB_Move2.Size = new System.Drawing.Size(142, 25); CB_Move2.TabIndex = 72; // // L_Move3 // L_Move3.Anchor = System.Windows.Forms.AnchorStyles.Right; L_Move3.AutoSize = true; - L_Move3.Location = new System.Drawing.Point(27, 92); + L_Move3.Location = new System.Drawing.Point(21, 100); L_Move3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); L_Move3.Name = "L_Move3"; - L_Move3.Size = new System.Drawing.Size(49, 15); + L_Move3.Size = new System.Drawing.Size(55, 17); L_Move3.TabIndex = 107; L_Move3.Text = "Move 3:"; L_Move3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -403,20 +380,20 @@ private void InitializeComponent() CB_Move3.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; CB_Move3.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; CB_Move3.FormattingEnabled = true; - CB_Move3.Location = new System.Drawing.Point(80, 88); + CB_Move3.Location = new System.Drawing.Point(80, 96); CB_Move3.Margin = new System.Windows.Forms.Padding(0); CB_Move3.Name = "CB_Move3"; - CB_Move3.Size = new System.Drawing.Size(142, 23); + CB_Move3.Size = new System.Drawing.Size(142, 25); CB_Move3.TabIndex = 73; // // L_Move4 // L_Move4.Anchor = System.Windows.Forms.AnchorStyles.Right; L_Move4.AutoSize = true; - L_Move4.Location = new System.Drawing.Point(27, 115); + L_Move4.Location = new System.Drawing.Point(21, 125); L_Move4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); L_Move4.Name = "L_Move4"; - L_Move4.Size = new System.Drawing.Size(49, 15); + L_Move4.Size = new System.Drawing.Size(55, 17); L_Move4.TabIndex = 108; L_Move4.Text = "Move 4:"; L_Move4.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -427,10 +404,10 @@ private void InitializeComponent() CB_Move4.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; CB_Move4.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; CB_Move4.FormattingEnabled = true; - CB_Move4.Location = new System.Drawing.Point(80, 111); + CB_Move4.Location = new System.Drawing.Point(80, 121); CB_Move4.Margin = new System.Windows.Forms.Padding(0); CB_Move4.Name = "CB_Move4"; - CB_Move4.Size = new System.Drawing.Size(142, 23); + CB_Move4.Size = new System.Drawing.Size(142, 25); CB_Move4.TabIndex = 74; // // CB_GameOrigin @@ -438,20 +415,20 @@ private void InitializeComponent() CB_GameOrigin.Anchor = System.Windows.Forms.AnchorStyles.Left; CB_GameOrigin.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; CB_GameOrigin.FormattingEnabled = true; - CB_GameOrigin.Location = new System.Drawing.Point(80, 134); + CB_GameOrigin.Location = new System.Drawing.Point(80, 153); CB_GameOrigin.Margin = new System.Windows.Forms.Padding(0); CB_GameOrigin.Name = "CB_GameOrigin"; - CB_GameOrigin.Size = new System.Drawing.Size(142, 23); + CB_GameOrigin.Size = new System.Drawing.Size(142, 25); CB_GameOrigin.TabIndex = 121; // // L_Version // L_Version.Anchor = System.Windows.Forms.AnchorStyles.Right; L_Version.AutoSize = true; - L_Version.Location = new System.Drawing.Point(11, 138); + L_Version.Location = new System.Drawing.Point(22, 149); L_Version.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); L_Version.Name = "L_Version"; - L_Version.Size = new System.Drawing.Size(65, 15); + L_Version.Size = new System.Drawing.Size(54, 34); L_Version.TabIndex = 122; L_Version.Text = "OT Version:"; L_Version.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -459,10 +436,10 @@ private void InitializeComponent() // TypeFilters // TypeFilters.Dock = System.Windows.Forms.DockStyle.Fill; - TypeFilters.Location = new System.Drawing.Point(84, 160); + TypeFilters.Location = new System.Drawing.Point(84, 189); TypeFilters.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); TypeFilters.Name = "TypeFilters"; - TypeFilters.Size = new System.Drawing.Size(204, 195); + TypeFilters.Size = new System.Drawing.Size(204, 164); TypeFilters.TabIndex = 123; // // CHK_IsEgg @@ -474,7 +451,7 @@ private void InitializeComponent() CHK_IsEgg.Location = new System.Drawing.Point(80, 0); CHK_IsEgg.Margin = new System.Windows.Forms.Padding(0); CHK_IsEgg.Name = "CHK_IsEgg"; - CHK_IsEgg.Size = new System.Drawing.Size(46, 19); + CHK_IsEgg.Size = new System.Drawing.Size(50, 21); CHK_IsEgg.TabIndex = 125; CHK_IsEgg.Text = "Egg"; CHK_IsEgg.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -485,7 +462,7 @@ private void InitializeComponent() // FLP_Egg.Anchor = System.Windows.Forms.AnchorStyles.Left; FLP_Egg.AutoSize = true; - FLP_Egg.Location = new System.Drawing.Point(0, 257); + FLP_Egg.Location = new System.Drawing.Point(0, 271); FLP_Egg.Margin = new System.Windows.Forms.Padding(0); FLP_Egg.Name = "FLP_Egg"; FLP_Egg.Size = new System.Drawing.Size(0, 0); @@ -497,16 +474,40 @@ private void InitializeComponent() CHK_Shiny.AutoSize = true; CHK_Shiny.Checked = true; CHK_Shiny.CheckState = System.Windows.Forms.CheckState.Indeterminate; - CHK_Shiny.Location = new System.Drawing.Point(25, 0); + CHK_Shiny.Location = new System.Drawing.Point(23, 0); CHK_Shiny.Margin = new System.Windows.Forms.Padding(0); CHK_Shiny.Name = "CHK_Shiny"; - CHK_Shiny.Size = new System.Drawing.Size(55, 19); + CHK_Shiny.Size = new System.Drawing.Size(57, 21); CHK_Shiny.TabIndex = 126; CHK_Shiny.Text = "Shiny"; CHK_Shiny.TextAlign = System.Drawing.ContentAlignment.MiddleRight; CHK_Shiny.ThreeState = true; CHK_Shiny.UseVisualStyleBackColor = true; // + // Tab_Advanced + // + Tab_Advanced.Controls.Add(B_Add); + Tab_Advanced.Controls.Add(RTB_Instructions); + Tab_Advanced.Location = new System.Drawing.Point(4, 26); + Tab_Advanced.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + Tab_Advanced.Name = "Tab_Advanced"; + Tab_Advanced.Size = new System.Drawing.Size(300, 362); + Tab_Advanced.TabIndex = 1; + Tab_Advanced.Text = "Advanced"; + Tab_Advanced.UseVisualStyleBackColor = true; + // + // B_Add + // + B_Add.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + B_Add.Location = new System.Drawing.Point(230, -1); + B_Add.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + B_Add.Name = "B_Add"; + B_Add.Size = new System.Drawing.Size(66, 27); + B_Add.TabIndex = 122; + B_Add.Text = "Add"; + B_Add.UseVisualStyleBackColor = true; + B_Add.Click += B_Add_Click; + // // SAV_Encounters // AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; @@ -534,9 +535,9 @@ private void InitializeComponent() TC_SearchOptions.ResumeLayout(false); Tab_General.ResumeLayout(false); Tab_General.PerformLayout(); - Tab_Advanced.ResumeLayout(false); TLP_Filters.ResumeLayout(false); TLP_Filters.PerformLayout(); + Tab_Advanced.ResumeLayout(false); ResumeLayout(false); PerformLayout(); } diff --git a/PKHeX.WinForms/Subforms/SAV_Encounters.cs b/PKHeX.WinForms/Subforms/SAV_Encounters.cs index e562f9527..16211aae3 100644 --- a/PKHeX.WinForms/Subforms/SAV_Encounters.cs +++ b/PKHeX.WinForms/Subforms/SAV_Encounters.cs @@ -103,6 +103,8 @@ public SAV_Encounters(PKMEditor f1, TrainerDatabase db) L_Count.Text = "Ready..."; CenterToParent(); + CB_Species.Select(); + CheckIsSearchDisallowed(); } private void GetTypeFilters() @@ -121,6 +123,15 @@ private void GetTypeFilters() { TypeFilters.Controls.Add(chk); TypeFilters.SetFlowBreak(chk, true); + chk.Click += (_, _) => + { + if ((ModifierKeys & Keys.Shift) != 0) + { + foreach (var c in TypeFilters.Controls.OfType()) + c.Checked = c == chk; + } + }; + chk.CheckStateChanged += (_, _) => CheckIsSearchDisallowed(); } } @@ -182,7 +193,7 @@ private void ClickView(object sender, EventArgs e) FillPKXBoxes(SCR_Box.Value); } - private EncounterCriteria GetCriteria(ISpeciesForm enc, EncounterDatabaseSettings settings) + private EncounterCriteria GetCriteria(IEncounterTemplate enc, EncounterDatabaseSettings settings) { if (!settings.UseTabsAsCriteria) return EncounterCriteria.Unrestricted; @@ -202,6 +213,8 @@ private EncounterCriteria GetCriteria(ISpeciesForm enc, EncounterDatabaseSetting var criteria = EncounterCriteria.GetCriteria(set, editor.PersonalInfo, mutations); if (!isInChain) criteria = criteria with { Gender = Gender.Random }; // Genderless tabs and a gendered enc -> let's play safe. + if (editor.Context.IsHyperTrainingAvailable(100)) + criteria = criteria.ReviseIVsHyperTrainAvailable(); return criteria; } @@ -261,7 +274,7 @@ private IEnumerable SearchDatabase(CancellationToken token) var settings = GetSearchSettings(); // If nothing is specified, instead of just returning all possible encounters, just return nothing. - if (settings is { Species: 0, Moves.Count: 0 } && Main.Settings.EncounterDb.ReturnNoneIfEmptySearch) + if (DisallowSearch(settings)) return []; var pk = SAV.BlankPKM; @@ -299,6 +312,13 @@ private IEnumerable SearchDatabase(CancellationToken token) return results; } + private bool DisallowSearch(SearchSettings settings) + { + if (TypeFilters.Controls.OfType().All(z => !z.Checked)) + return false; // no types selected + return settings is { Species: 0, Moves.Count: 0 } && Main.Settings.EncounterDb.ReturnNoneIfEmptySearch; + } + private static IEnumerable GetFullRange(int max) { for (ushort i = 1; i <= max; i++) @@ -513,4 +533,12 @@ private void B_Add_Click(object sender, EventArgs e) tb.AppendText(Environment.NewLine); tb.AppendText(s); } + + private void CB_Species_SelectedIndexChanged(object sender, EventArgs e) => CheckIsSearchDisallowed(); + + private void CheckIsSearchDisallowed() + { + var settings = GetSearchSettings(); + B_Search.Enabled = !DisallowSearch(settings); + } }