diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs index f0274aa52..26e1319b4 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs @@ -1,6 +1,6 @@ namespace PKHeX.Core { - public sealed class EncounterSlot4 : EncounterSlot, IMagnetStatic, INumberedSlot + public sealed class EncounterSlot4 : EncounterSlot, IMagnetStatic, INumberedSlot, IEncounterTypeTile { public override int Generation => 4; public EncounterType TypeEncounter => ((EncounterArea4)Area).TypeEncounter; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/IEncounterTypeTile.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/IEncounterTypeTile.cs new file mode 100644 index 000000000..0ef556a60 --- /dev/null +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/IEncounterTypeTile.cs @@ -0,0 +1,16 @@ +namespace PKHeX.Core +{ + public interface IEncounterTypeTile + { + EncounterType TypeEncounter { get; } + } + + public static class EncounterTypeTileExtensions + { + /// + /// Gets if the resulting will still have a value depending on the current . + /// + /// Generation 6 no longer stores this value. + public static bool HasTypeEncounter(this IEncounterTypeTile _, int format) => format == 4 || format == 5; + } +} diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticTyped.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticTyped.cs index 438bb2d76..a16c28fca 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticTyped.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticTyped.cs @@ -3,7 +3,7 @@ namespace PKHeX.Core { - public sealed class EncounterStaticTyped : EncounterStatic4 + public sealed class EncounterStaticTyped : EncounterStatic4, IEncounterTypeTile { public bool Roaming { get; set; } @@ -33,7 +33,7 @@ protected override void SetMetData(PKM pk, int level, DateTime today) pk.MetDate = today; } - private int[] GetRoamLocations(int species, int type) + private static int[] GetRoamLocations(int species, int type) { switch (species) { diff --git a/PKHeX.Core/Legality/Encounters/Information/EncounterSuggestion.cs b/PKHeX.Core/Legality/Encounters/Information/EncounterSuggestion.cs index f28ef3831..fb6b995b5 100644 --- a/PKHeX.Core/Legality/Encounters/Information/EncounterSuggestion.cs +++ b/PKHeX.Core/Legality/Encounters/Information/EncounterSuggestion.cs @@ -241,5 +241,7 @@ public EncounterSuggestionData(PKM pkm, int met, int lvl) public int LevelMax { get; } public int GetSuggestedMetLevel(PKM pkm) => EncounterSuggestion.GetSuggestedMetLevel(pkm, LevelMin); + public int GetSuggestedEncounterType() => Encounter is IEncounterTypeTile t ? t.TypeEncounter.GetIndex() : 0; + public bool HasEncounterType(int format) => Encounter is IEncounterTypeTile t && t.HasTypeEncounter(format); } } diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index b64fadba3..538036fa6 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -792,7 +792,10 @@ private bool SetSuggestedMetLocation(bool silent = false) minlvl = level; if (Entity.CurrentLevel >= minlvl && Entity.Met_Level == level && Entity.Met_Location == location) - return false; + { + if (!encounter.HasEncounterType(Entity.Format) || WinFormsUtil.GetIndex(CB_EncounterType) == encounter.GetSuggestedEncounterType()) + return false; + } if (minlvl < level) minlvl = level; @@ -813,6 +816,9 @@ private bool SetSuggestedMetLocation(bool silent = false) TB_MetLevel.Text = encounter.GetSuggestedMetLevel(Entity).ToString(); CB_MetLocation.SelectedValue = location; + if (encounter.HasEncounterType(Entity.Format)) + CB_EncounterType.SelectedValue = encounter.GetSuggestedEncounterType(); + if (Entity.Gen6 && Entity.WasEgg && ModifyPKM) Entity.SetHatchMemory6(); }