diff --git a/PKHeX.Core/Game/GameStrings/MemoryStrings.cs b/PKHeX.Core/Game/GameStrings/MemoryStrings.cs index 67dc5ae82..fa2954531 100644 --- a/PKHeX.Core/Game/GameStrings/MemoryStrings.cs +++ b/PKHeX.Core/Game/GameStrings/MemoryStrings.cs @@ -14,7 +14,7 @@ public sealed class MemoryStrings { private readonly GameStrings s; - public MemoryStrings(GameStrings strings, int format) + public MemoryStrings(GameStrings strings) { s = strings; memories = new Lazy>(GetMemories); @@ -27,9 +27,9 @@ public MemoryStrings(GameStrings strings, int format) specific = new Lazy>(() => Util.GetCBList(s.metXY_00000, Legal.Met_XY_0)); } - private List GetItems(int format) + private List GetItems(int memoryGen) { - var permit = Memories.GetMemoryItemParams(format); + var permit = Memories.GetMemoryItemParams(memoryGen); var asInt = permit.Select(z => (int) z).ToArray(); return Util.GetCBList(s.itemlist, asInt); } diff --git a/PKHeX.Core/Legality/Restrictions/Memories/Memories.cs b/PKHeX.Core/Legality/Restrictions/Memories/Memories.cs index d977e35f0..245801b62 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/Memories.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/Memories.cs @@ -16,12 +16,12 @@ public static class Memories private static readonly HashSet MemoryItem = new() { 5, 15, 26, 34, 40, 51, 84, 88 }; private static readonly HashSet MemorySpecies = new() { 7, 9, 13, 14, 17, 21, 18, 25, 29, 44, 45, 50, 60, 70, 71, 72, 75, 82, 83, 87 }; - public static MemoryArgType GetMemoryArgType(int memory, int format) + public static MemoryArgType GetMemoryArgType(int memory, int memoryGen) { if (MemoryGeneral.Contains(memory)) return MemoryArgType.GeneralLocation; if (MemorySpecific.Contains(memory)) { - if (format == 6) + if (memoryGen <= 7) return MemoryArgType.SpecificLocation; return MemoryArgType.GeneralLocation; } @@ -33,12 +33,12 @@ public static MemoryArgType GetMemoryArgType(int memory, int format) return MemoryArgType.None; } - public static MemoryContext GetContext(int format) => format switch + public static MemoryContext GetContext(int memoryGen) => memoryGen switch { - 6 or 7 => Memory6, + <=7 => Memory6, _ => Memory8, }; - public static IEnumerable GetMemoryItemParams(int format) => GetContext(format).GetMemoryItemParams(); + public static IEnumerable GetMemoryItemParams(int memoryGen) => GetContext(memoryGen).GetMemoryItemParams(); } } diff --git a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6.cs b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6.cs index 6095e2cd0..140ed065f 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6.cs @@ -38,7 +38,7 @@ public override bool CanUseItemGeneric(int item) public override IEnumerable GetMemoryItemParams() => Legal.HeldItem_AO.Distinct() .Concat(GetKeyItemParams()) .Concat(Legal.TMHM_AO.Take(100).Select(z => (ushort)z)) - .Where(z => z < Legal.MaxItemID_6_AO); + .Where(z => z <= Legal.MaxItemID_6_AO); public override bool IsUsedKeyItemUnspecific(int item) => KeyItemUsableObserve6.Contains((ushort)item); public override bool IsUsedKeyItemSpecific(int item, int species) => KeyItemMemoryArgsGen6.TryGetValue(species, out var value) && value.Contains((ushort)item); diff --git a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8.cs b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8.cs index 48285f826..9693632e5 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8.cs @@ -12,7 +12,7 @@ public sealed partial class MemoryContext8 : MemoryContext public override IEnumerable GetMemoryItemParams() => Legal.HeldItem_AO.Concat(Legal.HeldItems_SWSH).Distinct() .Concat(GetKeyItemParams()) .Concat(Legal.TMHM_AO.Take(100).Select(z => (ushort)z)) - .Where(z => z < Legal.MaxItemID_8_R2); + .Where(z => z <= Legal.MaxItemID_8_R2); public override bool CanUseItemGeneric(int item) => true; // todo diff --git a/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs b/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs index 8944941de..2fa58e52a 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs @@ -14,7 +14,7 @@ public MemoryAmie(PKM pk) InitializeComponent(); WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage); pkm = pk; - MemStrings = new MemoryStrings(GameInfo.Strings, pkm.Format); + MemStrings = new MemoryStrings(GameInfo.Strings); PrevCountries = new[] { CB_Country0, CB_Country1, CB_Country2, CB_Country3, CB_Country4 }; PrevRegions = new[] { CB_Region0, CB_Region1, CB_Region2, CB_Region3, CB_Region4 }; string[] arguments = L_Arguments.Text.Split(new[] {" ; "}, StringSplitOptions.None); @@ -235,16 +235,19 @@ private void GetLangStrings() private void UpdateMemoryDisplay(object sender) { - if (sender == CB_CTMemory) + if (sender == CB_OTMemory) { int memoryGen = pkm.Generation; + if (memoryGen < 0) + memoryGen = pkm.Format; + int memory = WinFormsUtil.GetIndex((ComboBox)sender); var memIndex = Memories.GetMemoryArgType(memory, memoryGen); var argvals = MemStrings.GetArgumentStrings(memIndex, memoryGen); - CB_CTVar.InitializeBinding(); - CB_CTVar.DataSource = new BindingSource(argvals, null); - LCTV.Text = TextArgs.GetMemoryCategory(memIndex, pkm.Generation); - LCTV.Visible = CB_CTVar.Visible = CB_CTVar.Enabled = argvals.Count > 1; + CB_OTVar.InitializeBinding(); + CB_OTVar.DataSource = new BindingSource(argvals, null); + LOTV.Text = TextArgs.GetMemoryCategory(memIndex, memoryGen); + LOTV.Visible = CB_OTVar.Visible = CB_OTVar.Enabled = argvals.Count > 1; } else { @@ -252,10 +255,10 @@ private void UpdateMemoryDisplay(object sender) int memory = WinFormsUtil.GetIndex((ComboBox)sender); var memIndex = Memories.GetMemoryArgType(memory, memoryGen); var argvals = MemStrings.GetArgumentStrings(memIndex, memoryGen); - CB_OTVar.InitializeBinding(); - CB_OTVar.DataSource = new BindingSource(argvals, null); - LOTV.Text = TextArgs.GetMemoryCategory(memIndex, pkm.Format); - LOTV.Visible = CB_OTVar.Visible = CB_OTVar.Enabled = argvals.Count > 1; + CB_CTVar.InitializeBinding(); + CB_CTVar.DataSource = new BindingSource(argvals, null); + LCTV.Text = TextArgs.GetMemoryCategory(memIndex, memoryGen); + LCTV.Visible = CB_CTVar.Visible = CB_CTVar.Enabled = argvals.Count > 1; } } @@ -381,10 +384,10 @@ public TextMarkup(string[] args) if (!string.IsNullOrWhiteSpace(args[9])) Location = args[9] + ":"; } - public string GetMemoryCategory(MemoryArgType type, int format) => type switch + public string GetMemoryCategory(MemoryArgType type, int memoryGen) => type switch { MemoryArgType.GeneralLocation => Area, - MemoryArgType.SpecificLocation when format == 6 => Location, + MemoryArgType.SpecificLocation when memoryGen <= 7 => Location, MemoryArgType.Species => Species, MemoryArgType.Move => Move, MemoryArgType.Item => Item,