diff --git a/PKHeX.Core/Legality/Restrictions/Memories.cs b/PKHeX.Core/Legality/Restrictions/Memories.cs index 459d32555..19fd5fb3b 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories.cs @@ -156,7 +156,17 @@ public static bool GetHasPokeCenterLocation(GameVersion game, int loc) 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 }; - private static readonly Dictionary KeyItemMemoryArgs = new() + internal static readonly Dictionary KeyItemMemoryArgsGen6 = new() + { + {(int) Species.Shaymin, new ushort[] {466}}, // Gracidea + {(int) Species.Tornadus, new ushort[] {638}}, // Reveal Glass + {(int) Species.Thundurus, new ushort[] {638}}, // Reveal Glass + {(int) Species.Landorus, new ushort[] {638}}, // Reveal Glass + {(int) Species.Kyurem, new ushort[] {628, 629}}, // DNA Splicers + {(int) Species.Hoopa, new ushort[] {765}}, // Prison Bottle + }; + + internal static readonly Dictionary KeyItemMemoryArgsGen8 = new() { {(int) Species.Rotom, new ushort[] {1278}}, // Rotom Catalog {(int) Species.Kyurem, new ushort[] {628, 629}}, // DNA Splicers @@ -164,7 +174,7 @@ public static bool GetHasPokeCenterLocation(GameVersion game, int loc) {(int) Species.Calyrex, new ushort[] {1590, 1591}}, // Reigns of Unity }; - public static IEnumerable KeyItemArgValues => KeyItemMemoryArgs.Values.SelectMany(z => z); + public static IEnumerable KeyItemArgValues => KeyItemMemoryArgsGen6.Values.Concat(KeyItemMemoryArgsGen8.Values).SelectMany(z => z).Distinct(); public static MemoryArgType GetMemoryArgType(int memory, int format) { diff --git a/PKHeX.Core/Legality/Verifiers/MemoryPermissions.cs b/PKHeX.Core/Legality/Verifiers/MemoryPermissions.cs index 8fa271ee0..82f9cd4a8 100644 --- a/PKHeX.Core/Legality/Verifiers/MemoryPermissions.cs +++ b/PKHeX.Core/Legality/Verifiers/MemoryPermissions.cs @@ -30,14 +30,29 @@ public static bool CanPlantBerry(int generation, int item) public static bool CanUseItemGeneric(int generation, int item) { + if (generation == 6) + { + // Key Item usage while in party on another species. + if (Memories.KeyItemMemoryArgsGen6.Values.Any(z => z.Contains((ushort) item))) + return true; + } return true; // todo } public static bool CanUseItem(int generation, int item, int species) { + if (IsUsedKeyItem(generation, item, species)) + return true; return true; // todo } + private static bool IsUsedKeyItem(int generation, int item, int species) => generation switch + { + 6 => Memories.KeyItemMemoryArgsGen6.TryGetValue(species, out var value) && value.Contains((ushort) item), + 8 => Memories.KeyItemMemoryArgsGen8.TryGetValue(species, out var value) && value.Contains((ushort) item), + _ => false + }; + public static bool CanBuyItem(int generation, int item) { return true; // todo