diff --git a/PKHeX.Core/Editing/Bulk/BatchEditing.cs b/PKHeX.Core/Editing/Bulk/BatchEditing.cs index b4833a8e2..0d19567a9 100644 --- a/PKHeX.Core/Editing/Bulk/BatchEditing.cs +++ b/PKHeX.Core/Editing/Bulk/BatchEditing.cs @@ -31,6 +31,7 @@ public static class BatchEditing public static readonly List CustomProperties = new() { PROP_LEGAL, PROP_TYPENAME, PROP_RIBBONS, PROP_CONTESTSTATS, PROP_MOVEMASTERY, + PROP_TYPE1, PROP_TYPE2, PROP_TYPEEITHER, IdentifierContains, nameof(ISlotInfo.Slot), nameof(SlotInfoBox.Box), }; @@ -70,6 +71,9 @@ public static class BatchEditing internal const string PROP_LEGAL = "Legal"; internal const string PROP_TYPENAME = "ObjectType"; + internal const string PROP_TYPEEITHER = "HasType"; + internal const string PROP_TYPE1 = "PersonalType1"; + internal const string PROP_TYPE2 = "PersonalType2"; internal const string PROP_RIBBONS = "Ribbons"; internal const string PROP_EVS = "EVs"; internal const string PROP_CONTESTSTATS = "ContestStats"; diff --git a/PKHeX.Core/Editing/Bulk/BatchFilters.cs b/PKHeX.Core/Editing/Bulk/BatchFilters.cs index 7920bac5c..902167d4f 100644 --- a/PKHeX.Core/Editing/Bulk/BatchFilters.cs +++ b/PKHeX.Core/Editing/Bulk/BatchFilters.cs @@ -20,6 +20,18 @@ public static class BatchFilters new ComplexFilter(PROP_TYPENAME, (pk, cmd) => cmd.Comparer.IsCompareEquivalence(pk.GetType().Name == cmd.PropertyValue), (info, cmd) => cmd.Comparer.IsCompareEquivalence(info.Entity.GetType().Name == cmd.PropertyValue)), + + new ComplexFilter(PROP_TYPE1, + (pk, cmd) => byte.TryParse(cmd.PropertyValue, out var b) && cmd.Comparer.IsCompareEquivalence(b == pk.PersonalInfo.Type1), + (info, cmd) => byte.TryParse(cmd.PropertyValue, out var b) && cmd.Comparer.IsCompareEquivalence(b == info.Entity.PersonalInfo.Type1)), + + new ComplexFilter(PROP_TYPE2, + (pk, cmd) => byte.TryParse(cmd.PropertyValue, out var b) && cmd.Comparer.IsCompareEquivalence(b == pk.PersonalInfo.Type2), + (info, cmd) => byte.TryParse(cmd.PropertyValue, out var b) && cmd.Comparer.IsCompareEquivalence(b == info.Entity.PersonalInfo.Type2)), + + new ComplexFilter(PROP_TYPEEITHER, + (pk, cmd) => byte.TryParse(cmd.PropertyValue, out var b) && cmd.Comparer.IsCompareEquivalence(pk.PersonalInfo.IsType(b)), + (info, cmd) => byte.TryParse(cmd.PropertyValue, out var b) && cmd.Comparer.IsCompareEquivalence(info.Entity.PersonalInfo.IsType(b))), }; /// diff --git a/PKHeX.Core/Game/GameStrings/GameStrings.cs b/PKHeX.Core/Game/GameStrings/GameStrings.cs index eb4e82e23..d193f0972 100644 --- a/PKHeX.Core/Game/GameStrings/GameStrings.cs +++ b/PKHeX.Core/Game/GameStrings/GameStrings.cs @@ -236,8 +236,8 @@ private void SanitizeItemNames() itemlist[878] += " (GP/GE)"; // Lift Key (Elevator Key=700) itemlist[479] += " (HG/SS)"; // Lost Item (Dropped Item=636) - // Append Z-Crystal flagging - foreach (var i in Legal.Pouch_ZCrystal_USUM) + // Append Z-Crystal Key Item differentiator + foreach (var i in ItemStorage7USUM.Pouch_ZCrystal_USUM) itemlist[i] += " [Z]"; itemlist[0121] += " (1)"; // Pokémon Box Link diff --git a/PKHeX.Core/Items/ItemStorage1.cs b/PKHeX.Core/Items/ItemStorage1.cs new file mode 100644 index 000000000..3881b4a1a --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage1.cs @@ -0,0 +1,30 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage1 : IItemStorage +{ + public static readonly ItemStorage1 Instance = new(); + private ItemStorage1() { } + + private static ReadOnlySpan Pouch_Items_RBY => new ushort[] + { + 000,001,002,003,004,005,006, 010,011,012,013,014,015, + 016,017,018,019,020, 029,030,031, + 032,033,034,035,036,037,038,039,040,041,042,043, 045,046,047, + 048,049, 051,052,053,054,055,056,057,058, 060,061,062,063, + 064,065,066,067,068,069,070,071,072,073,074,075,076,077,078,079, + 080,081,082,083, + + // ... + + 196,197,198,199,200,201,202,203,204,205,206,207, + 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, + 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, + 240,241,242,243,244,245,246,247,248,249,250, + }; + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; + + public ReadOnlySpan GetItems(InventoryType type) => Pouch_Items_RBY; +} diff --git a/PKHeX.Core/Items/ItemStorage2.cs b/PKHeX.Core/Items/ItemStorage2.cs new file mode 100644 index 000000000..735e73c95 --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage2.cs @@ -0,0 +1,82 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage2 : IItemStorage +{ + public static readonly ItemStorage2 InstanceGS = new(false); + public static readonly ItemStorage2 InstanceC = new(true); + + private readonly bool Crystal; + private ItemStorage2(bool crystal) => Crystal = crystal; + + private static ReadOnlySpan Pouch_Items_GSC => new ushort[] + { + 003, 008, 009, + 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, + 020, 021, 022, 023, 024, 026, 027, 028, 029, + 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, + 040, 041, 042, 043, 044, 046, 047, 048, 049, + 051, 052, 053, 057, + 060, 062, 063, 064, 065, + 072, 073, 074, 075, 076, 077, 078, 079, + 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, + 091, 092, 093, 094, 095, 096, 097, 098, 099, + 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 113, 114, 117, 118, 119, + 121, 122, 123, 124, 125, 126, + 131, 132, 138, 139, + 140, 143, 144, 146, + 150, 151, 152, 156, 158, + 163, 167, 168, 169, + 170, 172, 173, 174, + 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, + }; + + private static ReadOnlySpan Pouch_Ball_GSC => new ushort[] + { + 1, 2, 4, 5, 157, 159, 160, 161, 164, 165, 166, + }; + + private static ReadOnlySpan Pouch_Key_GS => new ushort[] + { + 7, 54, 55, 58, 59, 61, 66, 67, 68, 69, 71, 127, 128, 130, 133, 134, 175, 178, + }; + + private const int ExtraKeyCrystal = 4; + + private static ReadOnlySpan Pouch_Key_C => new ushort[] + { + 007, 054, 055, 058, 059, 061, 066, 067, 068, 069, 071, 127, 128, 130, 133, 134, 175, 178, + 070, 115, 116, 129, + }; + + private static ReadOnlySpan Pouch_TMHM_GSC => new ushort[] + { + 191, 192, 193, 194, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, + 221, 222, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, + }; + + public static ushort[] GetAllHeld() => ArrayUtil.ConcatAll(Pouch_Items_GSC, Pouch_Ball_GSC, Pouch_TMHM_GSC); + + private static readonly ushort[] PCItemsC = ArrayUtil.ConcatAll(Pouch_Items_GSC, Pouch_Ball_GSC, Pouch_TMHM_GSC, Pouch_Key_C); + + private static ReadOnlySpan PCItemsGS => PCItemsC.AsSpan(..^ExtraKeyCrystal); + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + + InventoryType.Items => Pouch_Items_GSC, + InventoryType.KeyItems => Crystal ? Pouch_Key_C : Pouch_Key_GS, + InventoryType.TMHMs => Pouch_TMHM_GSC, + InventoryType.Balls => Pouch_Ball_GSC, + InventoryType.PCItems => Crystal ? PCItemsC : PCItemsGS, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage3Colo.cs b/PKHeX.Core/Items/ItemStorage3Colo.cs new file mode 100644 index 000000000..0d97fa101 --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage3Colo.cs @@ -0,0 +1,39 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage3Colo : IItemStorage +{ + public static readonly ItemStorage3Colo Instance = new(); + + private static ReadOnlySpan Pouch_Cologne_COLO => new ushort[] { 543, 544, 545 }; + + private static ReadOnlySpan Pouch_Items_COLO => new ushort[] + { + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 93, 94, 95, 96, 97, 98, 103, 104, 106, 107, 108, 109, 110, 111, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 254, 255, 256, 257, 258, + + 537, // Time Flute + }; + + private static ReadOnlySpan Pouch_Key_COLO => new ushort[] + { + 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, + 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, + 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, + 530, 531, 532, 533, 534, 535, 536, 538, 539, + 540, 541, 542, 546, 547, + }; + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + InventoryType.Items => Pouch_Items_COLO, + InventoryType.KeyItems => Pouch_Key_COLO, + InventoryType.Balls => ItemStorage3RS.Pouch_Ball_RS, + InventoryType.TMHMs => ItemStorage3RS.Pouch_TM_RS, + InventoryType.Berries => ItemStorage3RS.Pouch_Berries_RS, + InventoryType.Medicine => Pouch_Cologne_COLO, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage3E.cs b/PKHeX.Core/Items/ItemStorage3E.cs new file mode 100644 index 000000000..c628ee15f --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage3E.cs @@ -0,0 +1,34 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage3E : IItemStorage +{ + public static readonly ItemStorage3E Instance = new(); + + private static ReadOnlySpan Pouch_Key_E => new ushort[] + { + // R/S + 259, 260, 261, 262, 263, 264, 265, 266, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, + // FR/LG + 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + // E + 375, 376, + }; + + private static readonly ushort[] PCItems = ArrayUtil.ConcatAll(ItemStorage3RS.Pouch_Items_RS, Pouch_Key_E, + ItemStorage3RS.Pouch_Ball_RS, ItemStorage3RS.Pouch_TMHM_RS, ItemStorage3RS.Pouch_Berries_RS); + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + InventoryType.Items => ItemStorage3RS.Pouch_Items_RS, + InventoryType.KeyItems => Pouch_Key_E, + InventoryType.Balls => ItemStorage3RS.Pouch_Ball_RS, + InventoryType.TMHMs => ItemStorage3RS.Pouch_TMHM_RS, + InventoryType.Berries => ItemStorage3RS.Pouch_Berries_RS, + InventoryType.PCItems => PCItems, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage3FRLG.cs b/PKHeX.Core/Items/ItemStorage3FRLG.cs new file mode 100644 index 000000000..03ea39770 --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage3FRLG.cs @@ -0,0 +1,32 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage3FRLG : IItemStorage +{ + public static readonly ItemStorage3FRLG Instance = new(); + + private static ReadOnlySpan Pouch_Key_FRLG => new ushort[] + { + // R/S + 259, 260, 261, 262, 263, 264, 265, 266, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, + // FR/LG + 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + }; + + private static readonly ushort[] PCItems = ArrayUtil.ConcatAll(ItemStorage3RS.Pouch_Items_RS, Pouch_Key_FRLG, + ItemStorage3RS.Pouch_Ball_RS, ItemStorage3RS.Pouch_TMHM_RS, ItemStorage3RS.Pouch_Berries_RS); + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + InventoryType.Items => ItemStorage3RS.Pouch_Items_RS, + InventoryType.KeyItems => Pouch_Key_FRLG, + InventoryType.Balls => ItemStorage3RS.Pouch_Ball_RS, + InventoryType.TMHMs => ItemStorage3RS.Pouch_TMHM_RS, + InventoryType.Berries => ItemStorage3RS.Pouch_Berries_RS, + InventoryType.PCItems => PCItems, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage3RS.cs b/PKHeX.Core/Items/ItemStorage3RS.cs new file mode 100644 index 000000000..f1a6edcbd --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage3RS.cs @@ -0,0 +1,71 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage3RS : IItemStorage +{ + public static readonly ItemStorage3RS Instance = new(); + + internal static ReadOnlySpan Pouch_Items_RS => new ushort[] + { + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 93, 94, 95, 96, 97, 98, 103, 104, 106, 107, 108, 109, 110, 111, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 254, 255, 256, 257, 258, + }; + + private static ReadOnlySpan Pouch_Key_RS => new ushort[] + { + 259, 260, 261, 262, 263, 264, 265, 266, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, + }; + + private const int COUNT_TM = 50; + private const int COUNT_HM = 8; + + internal static ReadOnlySpan Pouch_TMHM_RS => new ushort[] + { + 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, + 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, + 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, + + // HMs + 339, 340, 341, 342, 343, 344, 345, 346, + }; + + internal static ReadOnlySpan Pouch_TM_RS => Pouch_TMHM_RS[..COUNT_TM]; + + public static bool IsTMHM(ushort itemID) => (uint)(itemID - 289) < COUNT_TM + COUNT_HM; + public static bool IsTM(ushort itemID) => (uint)(itemID - 289) < COUNT_TM; + public static bool IsHM(ushort itemID) => (uint)(itemID - 339) < COUNT_HM; + + internal static ReadOnlySpan Pouch_Berries_RS => new ushort[] + { + 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, + }; + + internal static ReadOnlySpan Pouch_Ball_RS => new ushort[] + { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + }; + + internal static ReadOnlySpan Unreleased => new ushort[] { 005 }; // Safari Ball + + public static ushort[] GetAllHeld() + { + return ArrayUtil.ConcatAll(Pouch_Items_RS, Pouch_Ball_RS, Pouch_Berries_RS, Pouch_TMHM_RS[..^COUNT_HM]); + } + + private static readonly ushort[] PCItems = ArrayUtil.ConcatAll(Pouch_Items_RS, Pouch_Key_RS, Pouch_Ball_RS, Pouch_TMHM_RS, Pouch_Berries_RS); + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + InventoryType.Items => Pouch_Items_RS, + InventoryType.KeyItems => Pouch_Key_RS, + InventoryType.Balls => Pouch_Ball_RS, + InventoryType.TMHMs => Pouch_TMHM_RS, + InventoryType.Berries => Pouch_Berries_RS, + InventoryType.PCItems => PCItems, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage3XD.cs b/PKHeX.Core/Items/ItemStorage3XD.cs new file mode 100644 index 000000000..40df0d71d --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage3XD.cs @@ -0,0 +1,51 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage3XD : IItemStorage +{ + public static readonly ItemStorage3XD Instance = new(); + + private static ReadOnlySpan Pouch_Cologne_XD => new ushort[] { 513, 514, 515 }; + private static ReadOnlySpan Pouch_Items_XD => new ushort[] + { + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 93, 94, 95, 96, 97, 98, 103, 104, 106, 107, 108, 109, 110, 111, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 254, 255, 256, 257, 258, + + // XD Additions + 511, // Poké Snack + }; + + private static ReadOnlySpan Pouch_Key_XD => new ushort[] + { + 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, + 510, 512, 516, 517, 518, 519, + 523, 524, 525, 526, 527, 528, 529, + 530, 531, 532, 533, + }; + + private static ReadOnlySpan Pouch_Disc_XD => new ushort[] + { + 534, 535, 536, 537, 538, 539, + 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, + 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, + 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, + 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, + 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, + 590, 591, 592, 593, + }; + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + + InventoryType.Items => Pouch_Items_XD, + InventoryType.KeyItems => Pouch_Key_XD, + InventoryType.Balls => ItemStorage3RS.Pouch_Ball_RS, + InventoryType.TMHMs => ItemStorage3RS.Pouch_TM_RS, + InventoryType.Berries => ItemStorage3RS.Pouch_Berries_RS, + InventoryType.Medicine => Pouch_Cologne_XD, + InventoryType.BattleItems => Pouch_Disc_XD, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage4.cs b/PKHeX.Core/Items/ItemStorage4.cs new file mode 100644 index 000000000..89026e5eb --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage4.cs @@ -0,0 +1,73 @@ +using System; + +namespace PKHeX.Core; + +public abstract class ItemStorage4 +{ + private protected static ReadOnlySpan Pouch_Items_DP => new ushort[] + { + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 135, 136, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, + }; + + private protected static ReadOnlySpan Pouch_Items_Pt => new ushort[] + { + // Adds Griseous Orb + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 135, 136, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, + }; + + private protected static ReadOnlySpan Pouch_Key_DP => new ushort[] + { + 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, + }; + + private protected static ReadOnlySpan Pouch_TMHM_DP => new ushort[] + { + 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, + 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, + 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, + 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, + }; + + private protected static ReadOnlySpan Pouch_Mail_DP => new ushort[] + { + 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, + }; + + private protected static ReadOnlySpan Pouch_Medicine_DP => new ushort[] + { + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + }; + + private protected static ReadOnlySpan Pouch_Berries_DP => new ushort[] + { + 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, + }; + + private protected static ReadOnlySpan Pouch_Ball_DP => new ushort[] + { + 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + }; + + private protected static ReadOnlySpan Pouch_Battle_DP => new ushort[] + { + // Stat Ups + 55, 56, 57, 58, 59, 60, 61, 62, + + // In-Battle Use + 63, 64, 65, 66, 67, + }; + + internal static ReadOnlySpan Unreleased => new ushort[] + { + 005, // Safari Ball + 016, // Cherish Ball + 147, // Mosaic Mail + 499, // Sport Ball + 500, // Park Ball + }; +} diff --git a/PKHeX.Core/Items/ItemStorage4DP.cs b/PKHeX.Core/Items/ItemStorage4DP.cs new file mode 100644 index 000000000..d266cb054 --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage4DP.cs @@ -0,0 +1,28 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage4DP : ItemStorage4, IItemStorage +{ + public static readonly ItemStorage4DP Instance = new(); + + public static ushort[] GetAllHeld() + { + return ArrayUtil.ConcatAll(Pouch_Items_DP, Pouch_Mail_DP, Pouch_Medicine_DP, Pouch_Berries_DP, Pouch_Ball_DP, Pouch_TMHM_DP[..^8]); + } + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + InventoryType.Items => Pouch_Items_DP, + InventoryType.KeyItems => Pouch_Key_DP, + InventoryType.TMHMs => Pouch_TMHM_DP, + InventoryType.MailItems => Pouch_Mail_DP, + InventoryType.Medicine => Pouch_Medicine_DP, + InventoryType.Berries => Pouch_Berries_DP, + InventoryType.Balls => Pouch_Ball_DP, + InventoryType.BattleItems => Pouch_Battle_DP, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null) + }; +} diff --git a/PKHeX.Core/Items/ItemStorage4HGSS.cs b/PKHeX.Core/Items/ItemStorage4HGSS.cs new file mode 100644 index 000000000..dce74b43f --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage4HGSS.cs @@ -0,0 +1,33 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage4HGSS : ItemStorage4, IItemStorage +{ + public static readonly ItemStorage4HGSS Instance = new(); + + private static ReadOnlySpan Pouch_Key_HGSS => new ushort[] + { + 434, 435, 437, 444, 445, 446, 447, 450, 456, 464, 465, 466, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 501, 502, 503, 504, 532, 533, 534, 535, 536, + }; + + private static ReadOnlySpan Pouch_Ball_HGSS => new ushort[] + { + 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 492, 493, 494, 495, 496, 497, 498, 499, 500, + }; + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + InventoryType.Items => Pouch_Items_DP, + InventoryType.KeyItems => Pouch_Key_HGSS, + InventoryType.TMHMs => Pouch_TMHM_DP, + InventoryType.MailItems => Pouch_Mail_DP, + InventoryType.Medicine => Pouch_Medicine_DP, + InventoryType.Berries => Pouch_Berries_DP, + InventoryType.Balls => Pouch_Ball_HGSS, + InventoryType.BattleItems => Pouch_Battle_DP, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null) + }; +} diff --git a/PKHeX.Core/Items/ItemStorage4Pt.cs b/PKHeX.Core/Items/ItemStorage4Pt.cs new file mode 100644 index 000000000..64aa5b682 --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage4Pt.cs @@ -0,0 +1,33 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage4Pt : ItemStorage4, IItemStorage +{ + public static readonly ItemStorage4Pt Instance = new(); + + private static ReadOnlySpan Pouch_Key_Pt => new ushort[] + { + 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, + }; + + public static ushort[] GetAllHeld() + { + return ArrayUtil.ConcatAll(Pouch_Items_Pt, Pouch_Mail_DP, Pouch_Medicine_DP, Pouch_Berries_DP, Pouch_Ball_DP, Pouch_TMHM_DP[..^8]); + } + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + InventoryType.Items => Pouch_Items_DP, + InventoryType.KeyItems => Pouch_Key_Pt, + InventoryType.TMHMs => Pouch_TMHM_DP, + InventoryType.MailItems => Pouch_Mail_DP, + InventoryType.Medicine => Pouch_Medicine_DP, + InventoryType.Berries => Pouch_Berries_DP, + InventoryType.Balls => Pouch_Ball_DP, + InventoryType.BattleItems => Pouch_Battle_DP, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null) + }; +} diff --git a/PKHeX.Core/Items/ItemStorage5.cs b/PKHeX.Core/Items/ItemStorage5.cs new file mode 100644 index 000000000..802090287 --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage5.cs @@ -0,0 +1,73 @@ +using System; + +namespace PKHeX.Core; + +public abstract class ItemStorage5 +{ + private protected static ReadOnlySpan Pouch_Items_BW => new ushort[] + { + 01, 02, 03, 04, 05, 06, 07, 08, 09, + 10, 11, 12, 13, 14, 15, 16, + + 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 116, 117, 118, 119, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 492, 493, 494, 495, 496, 497, 498, 499, 500, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 571, 572, 573, 575, 576, 577, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, + }; + + private protected static ReadOnlySpan Pouch_TMHM_BW => new ushort[] + { + 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, + 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, + 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, + 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, + 418, 419, // 01-92 + + 618, 619, 620, // 93-95 + + 420, 421, 422, 423, 424, 425, + }; + + private protected static ReadOnlySpan Pouch_Medicine_BW => new ushort[] + { + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 134, 504, 565, 566, 567, 568, 569, 570, 591, + }; + + private protected static ReadOnlySpan Pouch_Berries_BW => new ushort[] + { + 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, + }; + + public static ReadOnlySpan Unreleased => new ushort[] + { + 005, // Safari Ball + 016, // Cherish Ball + 260, // Red Scarf + 261, // Blue Scarf + 262, // Pink Scarf + 263, // Green Scarf + 264, // Yellow Scarf + 492, // Fast Ball + 493, // Level Ball + 494, // Lure Ball + 495, // Heavy Ball + 496, // Love Ball + 497, // Friend Ball + 498, // Moon Ball + 499, // Sport Ball + 500, // Park Ball + 576, // Dream Ball + }; + + public static ushort[] GetAllHeld() + { + return ArrayUtil.ConcatAll(Pouch_Items_BW, Pouch_Medicine_BW, Pouch_Berries_BW); + } +} diff --git a/PKHeX.Core/Items/ItemStorage5B2W2.cs b/PKHeX.Core/Items/ItemStorage5B2W2.cs new file mode 100644 index 000000000..f9357707f --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage5B2W2.cs @@ -0,0 +1,26 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage5B2W2 : ItemStorage5, IItemStorage +{ + public static readonly ItemStorage5B2W2 Instance = new(); + private static ReadOnlySpan Pouch_Key_B2W2 => new ushort[] + { + 437, 442, 447, 450, 453, 458, 465, 466, 471, + 504, 578, + 616, 617, 621, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, + }; + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + InventoryType.Items => Pouch_Items_BW, + InventoryType.KeyItems => Pouch_Key_B2W2, + InventoryType.TMHMs => Pouch_TMHM_BW, + InventoryType.Medicine => Pouch_Medicine_BW, + InventoryType.Berries => Pouch_Berries_BW, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage5BW.cs b/PKHeX.Core/Items/ItemStorage5BW.cs new file mode 100644 index 000000000..83ba18d02 --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage5BW.cs @@ -0,0 +1,27 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage5BW : ItemStorage5, IItemStorage +{ + public static readonly ItemStorage5BW Instance = new(); + + private static ReadOnlySpan Pouch_Key_BW => new ushort[] + { + 437, 442, 447, 450, 465, 466, 471, + 504, 533, 574, 578, 579, + 616, 617, 621, 623, 624, 625, 626, + }; + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + InventoryType.Items => Pouch_Items_BW, + InventoryType.KeyItems => Pouch_Key_BW, + InventoryType.TMHMs => Pouch_TMHM_BW, + InventoryType.Medicine => Pouch_Medicine_BW, + InventoryType.Berries => Pouch_Berries_BW, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage6AO.cs b/PKHeX.Core/Items/ItemStorage6AO.cs new file mode 100644 index 000000000..c32aeeccd --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage6AO.cs @@ -0,0 +1,101 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage6AO : IItemStorage +{ + public static readonly ItemStorage6AO Instance = new(); + + internal static ReadOnlySpan Pouch_TMHM_AO => new ushort[] + { + 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, + 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, + 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, + 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, + 418, 419, // 01-92 + + 618, 619, 620, // 93-95 + 690, 691, 692, 693, 694, // 96-100 + + 420, 421, 422, 423, 424, + + // OR/AS + 425, 737, + }; + + private static ReadOnlySpan Pouch_Items_AO => new ushort[] + { + // Flutes moved to the Medicine pouch. + 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056, + 057, 058, 059, 060, 061, 062, 063, 064, 068, 069, 070, 071, 072, 073, 074, 075, + 076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, 090, 091, 092, 093, 094, + 099, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 116, 117, 118, 119, 135, 136, + 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, + 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, + 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, + 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, + 492, 493, 494, 495, 496, 497, 498, 499, 500, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, + 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 571, + 572, 573, 576, 577, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 639, 640, 644, 646, + 647, 648, 649, 650, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, + 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, + 699, 704, 710, 711, 715, + + // OR/AS Additions + 534, 535, + 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 767, 768, 769, 770, + }; + + private static ReadOnlySpan Pouch_Key_AO => new ushort[] + { + 216, 445, 446, 447, 465, 466, 471, 628, + 629, 631, 632, 638, 697, + + // Illegal + // 716, 717, 723, 745, 746, 747, 748, 749, 750, 766, + + // ORAS + 457, 474, 503, + + 718, 719, + 720, 721, 722, 724, 725, 726, 727, 728, 729, + 730, 731, 732, 733, 734, 735, 736, 738, 739, + 740, 741, 742, 743, 744, + 751, + 765, 771, 772, 774, 775, + }; + + private static ReadOnlySpan Pouch_Medicine_AO => new ushort[] + { + 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, + 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051, + 052, 053, 054, 134, 504, 565, 566, 567, 568, 569, 570, 571, 591, 645, 708, 709, + + // OR/AS -- Moved from Items pouch. + 065, 066, 067, + }; + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) + { + if (type is InventoryType.KeyItems) + return true; + return ItemStorage6XY.Unreleased.BinarySearch((ushort)itemIndex) < 0; + } + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + InventoryType.Items => Pouch_Items_AO, + InventoryType.KeyItems => Pouch_Key_AO, + InventoryType.TMHMs => Pouch_TMHM_AO, + InventoryType.Medicine => Pouch_Medicine_AO, + InventoryType.Berries => ItemStorage6XY.Pouch_Berry_XY, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage6XY.cs b/PKHeX.Core/Items/ItemStorage6XY.cs new file mode 100644 index 000000000..4f2ba70ed --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage6XY.cs @@ -0,0 +1,151 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage6XY : IItemStorage +{ + public static readonly ItemStorage6XY Instance = new(); + + private static ReadOnlySpan Pouch_Items_XY => new ushort[] + { + 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056, + 057, 058, 059, 060, 061, 062, 063, 064, 065, 066, 067, 068, 069, 070, 071, 072, 073, 074, 075, + 076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, 090, 091, 092, 093, 094, + 099, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 116, 117, 118, 119, 135, 136, + 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, + 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, + 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, + 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, + 492, 493, 494, 495, 496, 497, 498, 499, 500, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, + 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 571, + 572, 573, 576, 577, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 639, 640, 644, 646, + 647, 648, 649, 650, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, + 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, + 699, 704, 710, 711, 715, + }; + + private static ReadOnlySpan Pouch_Key_XY => new ushort[] + { + 216, 431, 442, 445, 446, 447, 450, 465, 466, 471, 628, + 629, 631, 632, 638, 641, 642, 643, 651, 689, 695, 696, 697, 698, + 700, 701, 702, 703, 705, 712, 713, 714, + + // Illegal + // 716, 717, 706, 707, + }; + + private static ReadOnlySpan Pouch_TMHM_XY => new ushort[] + { + 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, + 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, + 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, + 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, + 418, 419, // 01-92 + + 618, 619, 620, // 93-95 + 690, 691, 692, 693, 694, // 96-100 + + 420, 421, 422, 423, 424, + }; + + private static ReadOnlySpan Pouch_Medicine_XY => new ushort[] + { + 017, 018, 019, + 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, + 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, + 040, 041, 042, 043, 044, 045, 046, 047, 048, 049, + 050, 051, 052, 053, 054, + + 134, + 504, + 565, 566, 567, 568, 569, + 570, 571, + 591, + 645, + 708, 709, + }; + + public static ReadOnlySpan Pouch_Berry_XY => new ushort[] + { + 149, // Cheri Berry + 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, + 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, + 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + 210, 211, 212, + + 686, // Roseli Berry + 687, // Kee Berry + 688, // Maranga Berry + }; + + public static ushort[] GetAllHeld() + { + return ArrayUtil.ConcatAll(Pouch_Items_XY, Pouch_Medicine_XY, Pouch_Berry_XY); + } + + internal static ReadOnlySpan Unreleased => new ushort[] + { + 005, // Safari Ball + 016, // Cherish Ball + 492, // Fast Ball + 493, // Level Ball + 494, // Lure Ball + 495, // Heavy Ball + 496, // Love Ball + 497, // Friend Ball + 498, // Moon Ball + 499, // Sport Ball + 500, // Park Ball + 548, // Fire Gem + 549, // Water Gem + 550, // Electric Gem + 551, // Grass Gem + 552, // Ice Gem + 553, // Fighting Gem + 554, // Poison Gem + 555, // Ground Gem + 556, // Flying Gem + 557, // Psychic Gem + 558, // Bug Gem + 559, // Rock Gem + 560, // Ghost Gem + 561, // Dragon Gemt + 562, // Dark Gem + 563, // Steel Gem + 576, // Dream Ball + 584, // Relic Copper + 585, // Relic Silver + 587, // Relic Vase + 588, // Relic Band + 589, // Relic Statue + 590, // Relic Crown + 715, // Fairy Gem + }; + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) + { + if (type is InventoryType.KeyItems) + return true; + return Unreleased.BinarySearch((ushort)itemIndex) < 0; + } + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + InventoryType.Items => Pouch_Items_XY, + InventoryType.KeyItems => Pouch_Key_XY, + InventoryType.TMHMs => Pouch_TMHM_XY, + InventoryType.Medicine => Pouch_Medicine_XY, + InventoryType.Berries => Pouch_Berry_XY, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage7GG.cs b/PKHeX.Core/Items/ItemStorage7GG.cs new file mode 100644 index 000000000..e4ad9994d --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage7GG.cs @@ -0,0 +1,130 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage7GG : IItemStorage +{ + public static readonly ItemStorage7GG Instance = new(); + + private static ReadOnlySpan Pouch_Candy_GG_Regular => new ushort[] + { + 050, // Rare Candy + 960, 961, 962, 963, 964, 965, // S + 966, 967, 968, 969, 970, 971, // L + 972, 973, 974, 975, 976, 977, // XL + }; + + private static ReadOnlySpan Pouch_Candy_GG_Species => new ushort[] + { + 978, 979, + 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, + 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, + 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, + 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, + 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, + 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, + 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, + 1050, 1051, 1052, 1053, 1054, 1055, 1056, + 1057, + }; + + private static readonly ushort[] Pouch_Candy_GG = ArrayUtil.ConcatAll(Pouch_Candy_GG_Regular, Pouch_Candy_GG_Species); + + private static ReadOnlySpan Pouch_Medicine_GG => new ushort[] + { + 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 038, 039, 040, 041, 709, 903, + }; + + private static ReadOnlySpan Pouch_TM_GG => new ushort[] + { + 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, + 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, + }; + + private static ReadOnlySpan Pouch_PowerUp_GG => new ushort[] + { + 051, 053, 081, 082, 083, 084, 085, + 849, + }; + + private static ReadOnlySpan Pouch_Catching_GG => new ushort[] + { + 001, 002, 003, 004, 012, 164, 166, 168, + 861, 862, 863, 864, 865, 866, + }; + + private static ReadOnlySpan Pouch_Battle_GG => new ushort[] + { + 055, 056, 057, 058, 059, 060, 061, 062, + 656, 659, 660, 661, 662, 663, 671, 672, 675, 676, 678, 679, + 760, 762, 770, 773, + }; + + private static ReadOnlySpan Pouch_Regular_GG => new ushort[] + { + 076, 077, 078, 079, 086, 087, 088, 089, + 090, 091, 092, 093, 101, 102, 103, 113, 115, + 121, 122, 123, 124, 125, 126, 127, 128, + 442, + 571, + 632, 651, + 795, 796, + 872, 873, 874, 875, 876, 877, 878, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 900, 901, 902, + }; + + internal static ReadOnlySpan Pouch_Regular_GG_Key => new ushort[] + { + 113, // Tea + 115, // Autograph + 121, // Pokémon Box + 122, // Medicine Pocket + 123, // TM Case + 124, // Candy Jar + 125, // Power-Up Pocket + 126, // Clothing Trunk + 127, // Catching Pocket + 128, // Battle Pocket + 442, // Town Map + 632, // Shiny Charm + 651, // Poké Flute + + 872, // Secret Key + 873, // S.S. Ticket + 874, // Silph Scope + 875, // Parcel + 876, // Card Key + 877, // Gold Teeth + 878, // Lift Key + 885, // Stretchy Spring + 886, // Chalky Stone + 887, // Marble + 888, // Lone Earring + 889, // Beach Glass + 890, // Gold Leaf + 891, // Silver Leaf + 892, // Polished Mud Ball + 893, // Tropical Shell + 894, // Leaf Letter (P) + 895, // Leaf Letter (E) + 896, // Small Bouquet + }; + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + + InventoryType.Medicine => Pouch_Medicine_GG, + InventoryType.TMHMs => Pouch_TM_GG, + InventoryType.Balls => Pouch_Catching_GG, + InventoryType.Items => Pouch_Regular_GG, + InventoryType.BattleItems => Pouch_Battle_GG, + InventoryType.ZCrystals => Pouch_PowerUp_GG, + InventoryType.Candy => Pouch_Candy_GG, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage7SM.cs b/PKHeX.Core/Items/ItemStorage7SM.cs new file mode 100644 index 000000000..59baed90d --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage7SM.cs @@ -0,0 +1,224 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage7SM : IItemStorage +{ + public static readonly ItemStorage7SM Instance = new(); + + internal static ReadOnlySpan Pouch_Regular_SM => new ushort[] + { + 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, + 055, 056, 057, 058, 059, 060, 061, 062, 063, 064, + 068, 069, + 070, 071, 072, 073, 074, 075, 076, 077, 078, 079, + 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, + 090, 091, 092, 093, 094, 099, + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 116, 117, 118, 119, + 135, 136, 137, + 213, 214, 215, 217, 218, 219, + 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, + 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, + 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, + 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, + 320, 321, 322, 323, 324, 325, 326, 327, + + 492, 493, 494, 495, 496, 497, 498, + 499, 534, 535, 537, 538, 539, + 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, + 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, + 560, 561, 562, 563, 564, + 571, 572, 573, 576, 577, // Poké Toy + 580, 581, 582, 583, + 584, 585, 586, 587, 588, 589, 590, + 639, + 640, 644, 646, 647, 648, 649, + 650, 656, 657, 658, 659, + 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, + 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, + 680, 681, 682, 683, 684, 685, + 699, + 704, + 710, 711, 715, + 752, 753, 754, 755, 756, 757, 758, 759, + 760, 761, 762, 763, 764, 767, 768, 769, + 770, + 795, 796, 844, 846, 849, + 851, 853, 854, 855, 856, 879, + 880, 881, 882, + 883, 884, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, + }; + + private static ReadOnlySpan Pouch_Key_SM => new ushort[] + { + 216, + 465, 466, 628, 629, 631, 632, 638, + 705, 706, 765, 773, 797, + 841, 842, 843, 845, 847, 850, 857, 858, 860, + }; + + internal static ReadOnlySpan Pouch_TMHM_SM => new ushort[] + { + 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, + 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, + 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, + 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, + 418, 419, // 01-92 + + 618, 619, 620, // 93-95 + 690, 691, 692, 693, 694, // 96-100 + }; + + internal static ReadOnlySpan Pouch_Medicine_SM => new ushort[] + { + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 65, 66, 67, 134, + 504, 565, 566, 567, 568, 569, 570, 591, 645, 708, 709, + 852, + }; + + internal static ReadOnlySpan Pouch_Berries_SM => new ushort[] + { + 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, + 686, 687, 688, + }; + + private static ReadOnlySpan Pouch_ZCrystal_SM => new ushort[] + { + 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, + }; + + private static ReadOnlySpan Pouch_ZCrystalHeld_SM => new ushort[] + { + // SM + 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 798, 799, 800, 801, 802, 803, 804, 805, 806, 836, + }; + + internal static ReadOnlySpan Unreleased => new ushort[] + { + 005, // Safari Ball + 016, // Cherish Ball + 064, // Fluffy Tail + 065, // Blue Flute + 066, // Yellow Flute + 067, // Red Flute + 068, // Black Flute + 069, // White Flute + 070, // Shoal Salt + 071, // Shoal Shell + 103, // Old Amber + 111, // Odd Keystone + 164, // Razz Berry + 166, // Nanab Berry + 167, // Wepear Berry + 175, // Cornn Berry + 176, // Magost Berry + 177, // Rabuta Berry + 178, // Nomel Berry + 179, // Spelon Berry + 180, // Pamtre Berry + 181, // Watmel Berry + 182, // Durin Berry + 183, // Belue Berry + //208, // Enigma Berry + //209, // Micle Berry + //210, // Custap Berry + //211, // Jaboca Berry + //212, // Rowap Berry + 215, // Macho Brace + 260, // Red Scarf + 261, // Blue Scarf + 262, // Pink Scarf + 263, // Green Scarf + 264, // Yellow Scarf + 499, // Sport Ball + 548, // Fire Gem + 549, // Water Gem + 550, // Electric Gem + 551, // Grass Gem + 552, // Ice Gem + 553, // Fighting Gem + 554, // Poison Gem + 555, // Ground Gem + 556, // Flying Gem + 557, // Psychic Gem + 558, // Bug Gem + 559, // Rock Gem + 560, // Ghost Gem + 561, // Dragon Gem + 562, // Dark Gem + 563, // Steel Gem + 576, // Dream Ball + 584, // Relic Copper + 585, // Relic Silver + 587, // Relic Vase + 588, // Relic Band + 589, // Relic Statue + 590, // Relic Crown + 699, // Discount Coupon + 715, // Fairy Gem + }; + + public static ushort[] GetAllHeld() + { + return ArrayUtil.ConcatAll(Pouch_Regular_SM, Pouch_Berries_SM, Pouch_Medicine_SM, Pouch_ZCrystalHeld_SM); + } + + public static bool GetCrystalHeld(ushort itemKey, out ushort itemHeld) + { + var index = Pouch_ZCrystal_SM.IndexOf(itemKey); + if (index < 0) + { + itemHeld = 0; + return false; + } + itemHeld = Pouch_ZCrystalHeld_SM[index]; + return true; + } + + public static bool GetCrystalKey(ushort itemHeld, out ushort itemKey) + { + var index = Pouch_ZCrystalHeld_SM.IndexOf(itemHeld); + if (index < 0) + { + itemKey = 0; + return false; + } + itemKey = Pouch_ZCrystal_SM[index]; + return true; + } + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) + { + if (type is InventoryType.KeyItems or InventoryType.ZCrystals) + return true; + + var items = GetItems(type); + if (items.BinarySearch((ushort)itemIndex) < 0) + return false; + + return Unreleased.BinarySearch((ushort)itemIndex) >= 0; + } + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + InventoryType.Medicine => Pouch_Medicine_SM, + InventoryType.Items => Pouch_Regular_SM, + InventoryType.TMHMs => Pouch_TMHM_SM, + InventoryType.Berries => Pouch_Berries_SM, + InventoryType.KeyItems => Pouch_Key_SM, + InventoryType.ZCrystals => Pouch_ZCrystal_SM, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage7USUM.cs b/PKHeX.Core/Items/ItemStorage7USUM.cs new file mode 100644 index 000000000..de4dd31d7 --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage7USUM.cs @@ -0,0 +1,89 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage7USUM : IItemStorage +{ + public static readonly ItemStorage7USUM Instance = new(); + + private static ReadOnlySpan Pouch_Key_USUM => new ushort[] + { + 216, + 440, // US/UM + 465, 466, 628, 629, 631, 632, 638, + 705, 706, 765, 773, 797, + 841, 842, 843, 845, 847, 850, 857, 858, 860, + // US/UM + 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, + }; + + private static ReadOnlySpan Pouch_Roto_USUM => new ushort[] + { + 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, + }; + + internal static ReadOnlySpan Pouch_ZCrystal_USUM => new ushort[] + { + // SM + 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, + // US/UM + 927, 928, 929, 930, 931, 932, + }; + + private static ReadOnlySpan Pouch_ZCrystalHeld_USUM => new ushort[] + { + // SM + 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 798, 799, 800, 801, 802, 803, 804, 805, 806, 836, + // US/UM Additions + 921, 922, 923, 924, 925, 926, + }; + + public static ushort[] GetAllHeld() => ArrayUtil.ConcatAll(ItemStorage7SM.Pouch_Regular_SM, ItemStorage7SM.Pouch_Berries_SM, ItemStorage7SM.Pouch_Medicine_SM, Pouch_ZCrystalHeld_USUM, Pouch_Roto_USUM); + + public static bool GetCrystalHeld(ushort itemKey, out ushort itemHeld) + { + var index = Pouch_ZCrystal_USUM.IndexOf(itemKey); + if (index < 0) + { + itemHeld = 0; + return false; + } + itemHeld = Pouch_ZCrystalHeld_USUM[index]; + return true; + } + + public static bool GetCrystalKey(ushort itemHeld, out ushort itemKey) + { + var index = Pouch_ZCrystalHeld_USUM.IndexOf(itemHeld); + if (index < 0) + { + itemKey = 0; + return false; + } + itemKey = Pouch_ZCrystal_USUM[index]; + return true; + } + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) + { + if (type is InventoryType.KeyItems or InventoryType.ZCrystals) + return true; + + var items = GetItems(type); + if (items.BinarySearch((ushort)itemIndex) < 0) + return false; + + return ItemStorage7SM.Unreleased.BinarySearch((ushort)itemIndex) < 0; + } + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + InventoryType.Medicine => ItemStorage7SM.Pouch_Medicine_SM, + InventoryType.Items => ItemStorage7SM.Pouch_Regular_SM, + InventoryType.TMHMs => ItemStorage7SM.Pouch_TMHM_SM, + InventoryType.Berries => ItemStorage7SM.Pouch_Berries_SM, + InventoryType.KeyItems => Pouch_Key_USUM, + InventoryType.ZCrystals => Pouch_ZCrystal_USUM, + InventoryType.BattleItems => Pouch_Roto_USUM, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage8BDSP.cs b/PKHeX.Core/Items/ItemStorage8BDSP.cs new file mode 100644 index 000000000..f3c49edcb --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage8BDSP.cs @@ -0,0 +1,180 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage8BDSP : IItemStorage +{ + public static readonly ItemStorage8BDSP Instance = new(); + + private static ReadOnlySpan Pouch_Regular_BS => new ushort[] + { + 045, 046, 047, 048, 049, 050, 051, 052, 053, 072, 073, 074, 075, 076, 077, 078, + 079, 080, 081, 082, 083, 084, 085, 093, 094, 107, 108, 109, 110, 111, 112, 135, + 136, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, + 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, + 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, + 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, + 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, + 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 537, 565, 566, 567, 568, 569, 570, 644, 645, 849, + + 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, + 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1606, + }; + + private static ReadOnlySpan Pouch_Ball_BS => new ushort[] + { + 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, + 492, 493, 494, 495, 496, 497, 498, 499, 500, + 576, + 851, + }; + + private static ReadOnlySpan Pouch_Battle_BS => new ushort[] + { + 055, 056, 057, 058, 059, 060, 061, 062, 063, + }; + + public static ReadOnlySpan Unreleased => new ushort[] + { + 005, // Safari Ball + 016, // Cherish Ball + 044, // Sacred Ash + 499, // Sport Ball + 500, // Park Ball + 537, // Prism Scale + 565, // Health Feather + 566, // Muscle Feather + 567, // Resist Feather + 568, // Genius Feather + 569, // Clever Feather + 570, // Swift Feather + 576, // Dream Ball + 849, // Ice Stone + 851, // Beast Ball + + // new BDSP items, but they can't be held + 1808, // Mysterious Shard S + 1809, // Mysterious Shard L + 1810, // Digger Drill + 1811, // Kanto Slate + 1812, // Johto Slate + 1813, // Soul Slate + 1814, // Rainbow Slate + 1815, // Squall Slate + 1816, // Oceanic Slate + 1817, // Tectonic Slate + 1818, // Stratospheric Slate + 1819, // Genome Slate + 1820, // Discovery Slate + 1821, // Distortion Slate + }; + + private static ReadOnlySpan Pouch_Key_BS => new ushort[] + { + 428, 431, 432, 433, 438, 439, 440, 443, 445, 446, 447, 448, 449, 450, 451, 452, + 453, 454, 455, 459, 460, 461, 462, 463, 464, 466, 467, 631, 632, + + 1267, 1278, 1822, + }; + + private static ReadOnlySpan Pouch_Medicine_BS => new ushort[] + { + 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, + 038, 039, 040, 041, 042, 043, 044, 054, + + // 134 Sweet Heart (future event item?) + }; + + private static ReadOnlySpan Pouch_Berries_BS => new ushort[] + { + 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, + 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, + 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, + 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, + 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, + 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, + 209, 210, 211, 212, 686, + }; + + private static ReadOnlySpan Pouch_Treasure_BS => new ushort[] + { + 086, 087, 088, 089, 090, 091, 092, 099, 100, 101, 102, 103, 104, 105, 106, 795, 796, + + 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, + }; + + private static ReadOnlySpan Pouch_TMHM_BS => new ushort[] // TM01-TM100 + { + 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, + 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, + 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, + 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, + 418, 419, + 420, 421, 422, 423, 424, 425, 426, 427, // Previously called HM0X, in BDSP they're now called TM93-TM100 + }; + + public int GetMax(InventoryType type) => type switch + { + InventoryType.Items => 999, + InventoryType.KeyItems => 1, + InventoryType.TMHMs => 999, + InventoryType.Medicine => 999, + InventoryType.Berries => 999, + InventoryType.Balls => 999, + InventoryType.BattleItems => 999, + InventoryType.Treasure => 999, + _ => throw new ArgumentOutOfRangeException(nameof(type)), + }; + + public ReadOnlySpan GetItems(InventoryType type) => GetLegal(type); + + public static ReadOnlySpan GetLegal(InventoryType type) => type switch + { + InventoryType.Items => Pouch_Regular_BS, + InventoryType.KeyItems => Pouch_Key_BS, + InventoryType.TMHMs => Pouch_TMHM_BS, + InventoryType.Medicine => Pouch_Medicine_BS, + InventoryType.Berries => Pouch_Berries_BS, + InventoryType.Balls => Pouch_Ball_BS, + InventoryType.BattleItems => Pouch_Battle_BS, + InventoryType.Treasure => Pouch_Treasure_BS, + _ => throw new ArgumentOutOfRangeException(nameof(type)), + }; + + internal static ReadOnlySpan ValidTypes => new[] + { + InventoryType.Items, InventoryType.KeyItems, InventoryType.TMHMs, InventoryType.Medicine, + InventoryType.Berries, InventoryType.Balls, InventoryType.BattleItems, InventoryType.Treasure, + }; + + public static ushort[] GetAll() + { + return ArrayUtil.ConcatAll(Pouch_Regular_BS, Pouch_Ball_BS, Pouch_Battle_BS, Pouch_Berries_BS, Pouch_TMHM_BS, Pouch_Medicine_BS, Pouch_Treasure_BS); + } + + public static InventoryType GetInventoryPouch(ushort itemIndex) + { + foreach (var type in ValidTypes) + { + var legal = GetLegal(type); + if (legal.Contains(itemIndex)) + return type; + } + return InventoryType.None; + } + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) + { + if (type is InventoryType.KeyItems) + return true; + + return Unreleased.BinarySearch((ushort)itemIndex) < 0; + } +} diff --git a/PKHeX.Core/Items/ItemStorage8LA.cs b/PKHeX.Core/Items/ItemStorage8LA.cs new file mode 100644 index 000000000..a3eed594b --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage8LA.cs @@ -0,0 +1,76 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage8LA : IItemStorage +{ + public static readonly ItemStorage8LA Instance = new(); + + private static ReadOnlySpan Pouch_Items_LA => new ushort[] + { + 017, 023, 024, 025, 026, 027, 028, 029, 039, 041, + 050, 054, 072, 073, 075, 080, 081, 082, 083, 084, + 085, 090, 091, 092, 107, 108, 109, 110, 149, 150, + 151, 152, 153, 154, 155, 157, 158, 159, 160, 161, + 162, 163, 164, 166, 168, 233, 252, 321, 322, 323, + 324, 325, 326, 327, 583, 849, + + 1125, 1126, 1127, 1128, 1231, 1232, 1233, 1234, 1235, 1236, + 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, + 1247, 1248, 1249, 1250, 1251, + + 1611, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, + 1628, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, + 1651, 1679, 1681, 1682, 1684, 1686, 1687, 1688, 1689, 1690, + 1691, 1692, 1693, 1694, 1695, 1696, 1699, 1700, 1701, 1702, + 1703, 1704, 1705, 1706, 1707, 1708, 1709, 1710, 1711, 1712, + 1713, 1716, 1717, 1720, 1724, 1725, 1726, 1727, 1728, 1732, + 1733, 1734, 1735, 1736, 1738, 1739, 1740, 1741, 1742, 1746, + 1747, 1748, 1749, 1750, 1754, 1755, 1756, 1757, 1758, 1759, + 1760, 1761, 1762, 1764, 1785, + }; + + private static ReadOnlySpan Pouch_Recipe_LA => new ushort[] + { + 1640, 1641, 1642, 1643, 1644, 1646, 1647, 1648, 1649, + 1650, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, + 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669, + 1670, 1671, 1673, 1674, 1675, 1676, 1677, + + 1729, + 1730, 1731, + + 1751, 1752, 1753, + + 1783, 1784, + }; + + private static ReadOnlySpan Pouch_Key_LA => new ushort[] + { + 111, + 298, 299, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 313, + 441, 455, 466, + 632, 638, 644, + 1608, 1609, 1610, 1612, 1622, 1624, 1625, 1626, 1627, 1629, + 1639, 1678, 1721, 1722, 1723, 1737, 1743, 1744, 1745, 1763, + 1765, 1766, 1767, 1768, 1769, 1771, 1776, 1777, 1778, 1779, + 1780, 1782, 1786, 1787, 1788, 1789, 1790, 1792, 1793, 1794, + 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, + 1805, 1806, 1807, + 1828, + }; + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => GetItems(type).BinarySearch((ushort)itemIndex) >= 0; + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + + InventoryType.Items => Pouch_Items_LA, + InventoryType.KeyItems => Pouch_Key_LA, + InventoryType.PCItems => Pouch_Items_LA, + InventoryType.Treasure => Pouch_Recipe_LA, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage8SWSH.cs b/PKHeX.Core/Items/ItemStorage8SWSH.cs new file mode 100644 index 000000000..45db0d00f --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage8SWSH.cs @@ -0,0 +1,503 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage8SWSH : IItemStorage +{ + public static readonly ItemStorage8SWSH Instance = new(); + + private static ReadOnlySpan Pouch_Regular_SWSH => new ushort[] + { + 045, 046, 047, 048, 049, 050, 051, 052, 053, 076, 077, 079, 080, 081, 082, 083, 084, 085, 107, 108, 109, + 110, 112, 116, 117, 118, 119, 135, 136, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 228, + 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, + 250, 251, 252, 253, 254, 255, 257, 258, 259, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, + 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, + 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 324, 325, 326, 485, 486, 487, 488, 489, 490, 491, 537, 538, 539, 540, 541, 542, + 543, 544, 545, 546, 547, 564, 565, 566, 567, 568, 569, 570, 639, 640, 644, 645, 646, 647, 648, 649, 650, + 846, 849, 879, 880, 881, 882, 883, 884, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, + 917, 918, 919, 920, 1103, 1104, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, + 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, + 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, + + 1279, + 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, + 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, + 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, + 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, + 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, + 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, + 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, + 1406, 1407, 1408, 1409, 1410, 1411, 1412, 1413, 1414, 1415, 1416, 1417, 1418, 1419, 1420, 1421, 1422, 1423, + 1424, 1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, + 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, + 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, + 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, + 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, + 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, + 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, + 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, + 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1581, 1582, 1588, + + // DLC 2 + 1592, 1604, 1606, + }; + + private static ReadOnlySpan Pouch_Ball_SWSH => new ushort[] + { + 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, + 492, 493, 494, 495, 496, 497, 498, 499, 500, + 576, + 851, + }; + + private static ReadOnlySpan Pouch_Battle_SWSH => new ushort[] + { + 055, 056, 057, 058, 059, 060, 061, 062, 063, 1580, + }; + + private static ReadOnlySpan Pouch_Key_SWSH => new ushort[] + { + 078, + 628, 629, 631, 632, 638, + 703, + 847, + 943, 944, 945, 946, + 1074, 1075, 1076, 1077, 1080, 1081, 1100, 1255, 1266, 1267, + 1269, 1270, 1271, 1278, 1583, 1584, 1585, 1586, 1587, 1589, + + // DLC 2 + 1590, 1591, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1605, 1607, + }; + + private static ReadOnlySpan Pouch_TMTR_SWSH => new ushort[] + { + 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, + 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, + 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, + 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, + 418, 419, // 01-92 + + 618, 619, 620, // 93-95 + 690, 691, 692, 693, // 96-99 + + // TR + 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, + 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, + 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, + 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, + 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, + 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, + 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, + 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, + 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, + 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, + + 1230, // TM00 + }; + + private const int COUNT_TR = 100; + private static ReadOnlySpan Pouch_TR_SWSH => Pouch_TMTR_SWSH.Slice(99, COUNT_TR); + public static bool IsTechRecord(ushort itemID) => (uint)(itemID - 1130) < COUNT_TR; + + private static ReadOnlySpan Pouch_Medicine_SWSH => new ushort[] + { + 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, + 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, + 037, 038, 039, 040, 041, 042, 043, 054, + 134, + 504, 591, + 708, 709, + 852, 903, + 1579, + }; + + private static ReadOnlySpan Pouch_Berries_SWSH => new ushort[] + { + 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, + 159, 160, 161, 162, 163, 169, 170, 171, 172, 173, + 174, 184, 185, 186, 187, 188, 189, 190, 191, 192, + 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, + 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, + 686, 687, 688, + }; + + private static ReadOnlySpan Pouch_Ingredients_SWSH => new ushort[] + { + 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, + 1094, 1095, 1096, 1097, 1098, 1099, 1256, 1257, 1258, 1259, + 1260, 1261, 1262, 1263, 1264, + }; + + private static ReadOnlySpan Pouch_Treasure_SWSH => new ushort[] + { + 086, 087, 088, 089, 090, 091, 092, 094, 106, + 571, 580, 581, 582, 583, + 795, 796, + 1105, 1106, 1107, 1108, + }; + + internal static ReadOnlySpan Unreleased => new ushort[] + { + 016, // Cherish Ball + 298, // Flame Plate + 299, // Splash Plate + 300, // Zap Plate + 301, // Meadow Plate + 302, // Icicle Plate + 303, // Fist Plate + 304, // Toxic Plate + 305, // Earth Plate + 306, // Sky Plate + 307, // Mind Plate + 308, // Insect Plate + 309, // Stone Plate + 310, // Spooky Plate + 311, // Draco Plate + 312, // Dread Plate + 313, // Iron Plate + + 500, // Park Ball + // 644, // Pixie Plate + + 1279, // ★And458 (Jangmo-o) + 1280, // ★And15 (Larvitar) + 1281, // ★And337 (Corviknight) + 1282, // ★And603 (Eiscue) + 1283, // ★And390 (Stonjourner) + 1284, // ★Sgr6879 (Copperajah) + 1285, // ★Sgr6859 (Centiskorch) + 1286, // ★Sgr6913 (Flapple/Appletun) + 1287, // ★Sgr7348 (Sandaconda) + 1288, // ★Sgr7121 (Duraludon) + 1289, // ★Sgr6746 (Pikachu) + 1290, // ★Sgr7194 (Eevee) + 1291, // ★Sgr7337 + 1292, // ★Sgr7343 + 1293, // ★Sgr6812 + 1294, // ★Sgr7116 + 1295, // ★Sgr7264 + 1296, // ★Sgr7597 + 1297, // ★Del7882 + 1298, // ★Del7906 + 1299, // ★Del7852 + 1300, // ★Psc596 + 1301, // ★Psc361 + 1302, // ★Psc510 + 1303, // ★Psc437 + 1304, // ★Psc8773 + 1305, // ★Lep1865 + 1306, // ★Lep1829 + 1307, // ★Boo5340 + 1308, // ★Boo5506 + 1309, // ★Boo5435 + 1310, // ★Boo5602 + 1311, // ★Boo5733 + 1312, // ★Boo5235 + 1313, // ★Boo5351 + 1314, // ★Hya3748 + 1315, // ★Hya3903 + 1316, // ★Hya3418 + 1317, // ★Hya3482 + 1318, // ★Hya3845 + 1319, // ★Eri1084 + 1320, // ★Eri472 + 1321, // ★Eri1666 + 1322, // ★Eri897 + 1323, // ★Eri1231 + 1324, // ★Eri874 + 1325, // ★Eri1298 + 1326, // ★Eri1325 + 1327, // ★Eri984 + 1328, // ★Eri1464 + 1329, // ★Eri1393 + 1330, // ★Eri850 + 1331, // ★Tau1409 + 1332, // ★Tau1457 + 1333, // ★Tau1165 + 1334, // ★Tau1791 + 1335, // ★Tau1910 + 1336, // ★Tau1346 + 1337, // ★Tau1373 + 1338, // ★Tau1412 + 1339, // ★CMa2491 + 1340, // ★CMa2693 + 1341, // ★CMa2294 + 1342, // ★CMa2827 + 1343, // ★CMa2282 + 1344, // ★CMa2618 + 1345, // ★CMa2657 + 1346, // ★CMa2646 + 1347, // ★UMa4905 + 1348, // ★UMa4301 + 1349, // ★UMa5191 + 1350, // ★UMa5054 + 1351, // ★UMa4295 + 1352, // ★UMa4660 + 1353, // ★UMa4554 + 1354, // ★UMa4069 + 1355, // ★UMa3569 + 1356, // ★UMa3323 + 1357, // ★UMa4033 + 1358, // ★UMa4377 + 1359, // ★UMa4375 + 1360, // ★UMa4518 + 1361, // ★UMa3594 + 1362, // ★Vir5056 + 1363, // ★Vir4825 + 1364, // ★Vir4932 + 1365, // ★Vir4540 + 1366, // ★Vir4689 + 1367, // ★Vir5338 + 1368, // ★Vir4910 + 1369, // ★Vir5315 + 1370, // ★Vir5359 + 1371, // ★Vir5409 + 1372, // ★Vir5107 + 1373, // ★Ari617 + 1374, // ★Ari553 + 1375, // ★Ari546 + 1376, // ★Ari951 + 1377, // ★Ori1713 + 1378, // ★Ori2061 + 1379, // ★Ori1790 + 1380, // ★Ori1903 + 1381, // ★Ori1948 + 1382, // ★Ori2004 + 1383, // ★Ori1852 + 1384, // ★Ori1879 + 1385, // ★Ori1899 + 1386, // ★Ori1543 + 1387, // ★Cas21 + 1388, // ★Cas168 + 1389, // ★Cas403 + 1390, // ★Cas153 + 1391, // ★Cas542 + 1392, // ★Cas219 + 1393, // ★Cas265 + 1394, // ★Cnc3572 + 1395, // ★Cnc3208 + 1396, // ★Cnc3461 + 1397, // ★Cnc3449 + 1398, // ★Cnc3429 + 1399, // ★Cnc3627 + 1400, // ★Cnc3268 + 1401, // ★Cnc3249 + 1402, // ★Com4968 + 1403, // ★Crv4757 + 1404, // ★Crv4623 + 1405, // ★Crv4662 + 1406, // ★Crv4786 + 1407, // ★Aur1708 + 1408, // ★Aur2088 + 1409, // ★Aur1605 + 1410, // ★Aur2095 + 1411, // ★Aur1577 + 1412, // ★Aur1641 + 1413, // ★Aur1612 + 1414, // ★Pav7790 + 1415, // ★Cet911 + 1416, // ★Cet681 + 1417, // ★Cet188 + 1418, // ★Cet539 + 1419, // ★Cet804 + 1420, // ★Cep8974 + 1421, // ★Cep8162 + 1422, // ★Cep8238 + 1423, // ★Cep8417 + 1424, // ★Cen5267 + 1425, // ★Cen5288 + 1426, // ★Cen551 + 1427, // ★Cen5459 + 1428, // ★Cen5460 + 1429, // ★CMi2943 + 1430, // ★CMi2845 + 1431, // ★Equ8131 + 1432, // ★Vul7405 + 1433, // ★UMi424 + 1434, // ★UMi5563 + 1435, // ★UMi5735 + 1436, // ★UMi6789 + 1437, // ★Crt4287 + 1438, // ★Lyr7001 + 1439, // ★Lyr7178 + 1440, // ★Lyr7106 + 1441, // ★Lyr7298 + 1442, // ★Ara6585 + 1443, // ★Sco6134 + 1444, // ★Sco6527 + 1445, // ★Sco6553 + 1446, // ★Sco5953 + 1447, // ★Sco5984 + 1448, // ★Sco6508 + 1449, // ★Sco6084 + 1450, // ★Sco5944 + 1451, // ★Sco6630 + 1452, // ★Sco6027 + 1453, // ★Sco6247 + 1454, // ★Sco6252 + 1455, // ★Sco5928 + 1456, // ★Sco6241 + 1457, // ★Sco6165 + 1458, // ★Tri544 + 1459, // ★Leo3982 + 1460, // ★Leo4534 + 1461, // ★Leo4357 + 1462, // ★Leo4057 + 1463, // ★Leo4359 + 1464, // ★Leo4031 + 1465, // ★Leo3852 + 1466, // ★Leo3905 + 1467, // ★Leo3773 + 1468, // ★Gru8425 + 1469, // ★Gru8636 + 1470, // ★Gru8353 + 1471, // ★Lib5685 + 1472, // ★Lib5531 + 1473, // ★Lib5787 + 1474, // ★Lib5603 + 1475, // ★Pup3165 + 1476, // ★Pup3185 + 1477, // ★Pup3045 + 1478, // ★Cyg7924 + 1479, // ★Cyg7417 + 1480, // ★Cyg7796 + 1481, // ★Cyg8301 + 1482, // ★Cyg7949 + 1483, // ★Cyg7528 + 1484, // ★Oct7228 + 1485, // ★Col1956 + 1486, // ★Col2040 + 1487, // ★Col2177 + 1488, // ★Gem2990 + 1489, // ★Gem2891 + 1490, // ★Gem2421 + 1491, // ★Gem2473 + 1492, // ★Gem2216 + 1493, // ★Gem2777 + 1494, // ★Gem2650 + 1495, // ★Gem2286 + 1496, // ★Gem2484 + 1497, // ★Gem2930 + 1498, // ★Peg8775 + 1499, // ★Peg8781 + 1500, // ★Peg39 + 1501, // ★Peg8308 + 1502, // ★Peg8650 + 1503, // ★Peg8634 + 1504, // ★Peg8684 + 1505, // ★Peg8450 + 1506, // ★Peg8880 + 1507, // ★Peg8905 + 1508, // ★Oph6556 + 1509, // ★Oph6378 + 1510, // ★Oph6603 + 1511, // ★Oph6149 + 1512, // ★Oph6056 + 1513, // ★Oph6075 + 1514, // ★Ser5854 + 1515, // ★Ser7141 + 1516, // ★Ser5879 + 1517, // ★Her6406 + 1518, // ★Her6148 + 1519, // ★Her6410 + 1520, // ★Her6526 + 1521, // ★Her6117 + 1522, // ★Her6008 + 1523, // ★Per936 + 1524, // ★Per1017 + 1525, // ★Per1131 + 1526, // ★Per1228 + 1527, // ★Per834 + 1528, // ★Per941 + 1529, // ★Phe99 + 1530, // ★Phe338 + 1531, // ★Vel3634 + 1532, // ★Vel3485 + 1533, // ★Vel3734 + 1534, // ★Aqr8232 + 1535, // ★Aqr8414 + 1536, // ★Aqr8709 + 1537, // ★Aqr8518 + 1538, // ★Aqr7950 + 1539, // ★Aqr8499 + 1540, // ★Aqr8610 + 1541, // ★Aqr8264 + 1542, // ★Cru4853 + 1543, // ★Cru4730 + 1544, // ★Cru4763 + 1545, // ★Cru4700 + 1546, // ★Cru4656 + 1547, // ★PsA8728 + 1548, // ★TrA6217 + 1549, // ★Cap7776 + 1550, // ★Cap7754 + 1551, // ★Cap8278 + 1552, // ★Cap8322 + 1553, // ★Cap7773 + 1554, // ★Sge7479 + 1555, // ★Car2326 + 1556, // ★Car3685 + 1557, // ★Car3307 + 1558, // ★Car3699 + 1559, // ★Dra5744 + 1560, // ★Dra5291 + 1561, // ★Dra6705 + 1562, // ★Dra6536 + 1563, // ★Dra7310 + 1564, // ★Dra6688 + 1565, // ★Dra4434 + 1566, // ★Dra6370 + 1567, // ★Dra7462 + 1568, // ★Dra6396 + 1569, // ★Dra6132 + 1570, // ★Dra6636 + 1571, // ★CVn4915 + 1572, // ★CVn4785 + 1573, // ★CVn4846 + 1574, // ★Aql7595 + 1575, // ★Aql7557 + 1576, // ★Aql7525 + 1577, // ★Aql7602 + 1578, // ★Aql7235 + }; + + public static bool IsItemLegal(ushort item) + { + if (Legal.IsDynamaxCrystal(item)) + return Legal.IsDynamaxCrystalAvailable(item); + return Unreleased.BinarySearch(item) < 0; + } + + public static ushort[] GetAllHeld() + { + return ArrayUtil.ConcatAll(Pouch_Regular_SWSH, Pouch_Ball_SWSH, Pouch_Battle_SWSH, Pouch_Berries_SWSH, Pouch_Medicine_SWSH, Pouch_TR_SWSH, Pouch_Treasure_SWSH, Pouch_Ingredients_SWSH); + } + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) + { + if (type is InventoryType.KeyItems) + return true; + return IsItemLegal((ushort)itemIndex); + } + + public ReadOnlySpan GetItems(InventoryType type) => type switch + { + InventoryType.Medicine => Pouch_Medicine_SWSH, + InventoryType.Balls => Pouch_Ball_SWSH, + InventoryType.BattleItems => Pouch_Battle_SWSH, + InventoryType.Berries => Pouch_Berries_SWSH, + InventoryType.Items => Pouch_Regular_SWSH, + InventoryType.TMHMs => Pouch_TMTR_SWSH, + InventoryType.Treasure => Pouch_Treasure_SWSH, + InventoryType.Candy => Pouch_Ingredients_SWSH, + InventoryType.KeyItems => Pouch_Key_SWSH, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +} diff --git a/PKHeX.Core/Items/ItemStorage9SV.cs b/PKHeX.Core/Items/ItemStorage9SV.cs new file mode 100644 index 000000000..125d60133 --- /dev/null +++ b/PKHeX.Core/Items/ItemStorage9SV.cs @@ -0,0 +1,304 @@ +using System; + +namespace PKHeX.Core; + +public sealed class ItemStorage9SV : IItemStorage +{ + public static readonly ItemStorage9SV Instance = new(); + + private static ReadOnlySpan Pouch_Medicine_SV => new ushort[] + { + 0017, 0018, 0019, 0020, 0021, 0022, 0023, 0024, 0025, 0026, + 0027, 0028, 0029, 0030, 0031, 0032, 0033, 0034, 0035, 0036, + 0037, 0038, 0039, 0040, 0041, 0708, 0709, + }; + + private static ReadOnlySpan Pouch_Ball_SV => new ushort[] + { + 0001, 0002, 0003, 0004, 0005, 0006, 0007, 0008, 0009, 0010, + 0011, 0012, 0013, 0014, 0015, 0016, 0492, 0493, 0494, 0495, + 0496, 0497, 0498, 0499, 0500, 0576, 0851, 1785, + }; + + private static ReadOnlySpan Pouch_Battle_SV => new ushort[] + { + 0055, 0056, 0057, 0058, 0059, 0060, 0061, 0062, 0063, + }; + + private static ReadOnlySpan Pouch_Berries_SV => new ushort[] + { + 0149, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0158, + 0159, 0160, 0161, 0162, 0163, 0169, 0170, 0171, 0172, 0173, + 0174, 0184, 0185, 0186, 0187, 0188, 0189, 0190, 0191, 0192, + 0193, 0194, 0195, 0196, 0197, 0198, 0199, 0200, 0201, 0202, + 0203, 0204, 0205, 0206, 0207, 0208, 0209, 0210, 0211, 0212, + 0686, 0687, 0688, + }; + + private static ReadOnlySpan Pouch_Other_SV => new ushort[] + { + 0045, 0046, 0047, 0048, 0049, 0050, 0051, 0052, 0053, 0080, + 0081, 0082, 0083, 0084, 0085, 0107, 0108, 0109, 0110, 0111, + 0112, 0135, 0136, 0213, 0214, 0217, 0218, 0219, 0220, 0221, + 0222, 0223, 0224, 0228, 0229, 0230, 0231, 0232, 0233, 0234, + 0236, 0237, 0238, 0239, 0240, 0241, 0242, 0243, 0244, 0245, + 0246, 0247, 0248, 0249, 0250, 0251, 0253, 0265, 0266, 0267, + 0268, 0269, 0270, 0271, 0272, 0273, 0275, 0276, 0277, 0278, + 0279, 0280, 0281, 0282, 0283, 0284, 0285, 0286, 0287, 0288, + 0289, 0290, 0291, 0292, 0293, 0294, 0295, 0296, 0297, 0298, + 0299, 0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, 0308, + 0309, 0310, 0311, 0312, 0313, 0326, 0485, 0486, 0487, 0488, + 0489, 0490, 0491, 0538, 0539, 0540, 0541, 0542, 0543, 0544, + 0545, 0546, 0547, 0564, 0565, 0566, 0567, 0568, 0569, 0570, + 0639, 0640, 0644, 0645, 0648, 0649, 0650, 0795, 0796, 0846, + 0849, 0853, 0854, 0855, 0856, 0879, 0880, 0881, 0882, 0883, + 0884, 1103, 1104, 1116, 1117, 1118, 1119, 1120, 1121, 1122, + 1123, 1124, 1125, 1126, 1127, 1128, 1231, 1232, 1233, 1234, + 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, + 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1253, 1254, 1582, + 1592, 1606, 1777, 1778, 1779, 1861, 1862, 1863, 1864, 1865, + 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, + 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, + 1886, 2344, 2345, + }; + + private static ReadOnlySpan Pouch_TM_SV => new ushort[] + { + 0328, 0329, 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, + 0338, 0339, 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, + 0348, 0349, 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, + 0358, 0359, 0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367, + 0368, 0369, 0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377, + 0378, 0379, 0380, 0381, 0382, 0383, 0384, 0385, 0386, 0387, + 0388, 0389, 0390, 0391, 0392, 0393, 0394, 0395, 0396, 0397, + 0398, 0399, 0400, 0401, 0402, 0403, 0404, 0405, 0406, 0407, + 0408, 0409, 0410, 0411, 0412, 0413, 0414, 0415, 0416, 0417, + 0418, 0419, 0618, 0619, 0620, 0690, 0691, 0692, 0693, 1230, + 2160, 2161, 2162, 2163, 2164, 2165, 2166, 2167, 2168, 2169, + 2170, 2171, 2172, 2173, 2174, 2175, 2176, 2177, 2178, 2179, + 2180, 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189, + 2190, 2191, 2192, 2193, 2194, 2195, 2196, 2197, 2198, 2199, + 2200, 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, + 2210, 2211, 2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219, + 2220, 2221, 2222, 2223, 2224, 2225, 2226, 2227, 2228, 2229, + 2230, 2231, + }; + + private static ReadOnlySpan Pouch_Treasure_SV => new ushort[] + { + 0086, 0087, 0088, 0089, 0090, 0091, 0092, 0094, 0106, 0571, + 0580, 0581, 0582, 0583, 1842, 1843, + }; + + private static ReadOnlySpan Pouch_Picnic_SV => new ushort[] + { + 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, + 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, + 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, + 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, + 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, + 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, + 2311, 2313, + 2314, 2315, 2316, 2317, 2318, 2319, 2320, 2321, 2322, 2323, + 2324, 2325, 2326, 2327, 2329, 2330, 2331, 2332, 2333, 2334, + 2335, 2336, 2337, 2338, 2339, 2340, 2341, 2342, 2348, 2349, + 2350, 2351, 2352, 2353, 2354, 2355, 2356, 2357, 2358, 2359, + 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369, + 2370, 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, + 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, + 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, + 2400, + + // Item data is present, but the items have no associated text or sprites, so they do not appear in the bag. + // 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, + }; + + private static ReadOnlySpan Pouch_Event_SV => new ushort[] + { + 0632, 0638, 0703, 0765, 1278, 1590, 1591, 1829, 1830, 1831, + 1832, 1833, 1834, 1835, 1836, 1857, 1858, + + // Item data is present, but the items have no associated text or sprites, so they do not appear in the bag. + // 0078, 0466, 0631, 1267, 1587, 1589, 1837, 1838, 1839, 1840, 1841, + }; + + private static ReadOnlySpan Pouch_Material_SV => new ushort[] + { + 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, + 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, + 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, + 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, + 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, + 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, + 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, + 2036, 2037, 2038, 2039, 2040, 2041, 2042, 2043, 2044, 2045, + 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, + 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2064, 2065, + 2066, 2067, 2068, 2069, 2070, 2071, 2072, 2073, 2074, 2075, + 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085, + 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, + 2096, 2097, 2098, 2099, 2103, 2104, 2105, + 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, + 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2126, 2127, + 2128, 2129, 2130, 2131, 2132, 2133, 2134, 2135, 2136, 2137, + + 2156, 2157, + 2158, 2159, + + // Item data is present, but the items have no associated text or sprites, so they do not appear in the bag. + // 2100, 2101, 2102, + // 2138, 2139, 2140, 2141, 2142, 2143, 2144, 2145, 2146, 2147, + // 2148, 2149, 2150, 2151, 2152, 2153, 2154, 2155, + }; + + internal static ReadOnlySpan ValidTypes => new[] + { + InventoryType.Items, InventoryType.KeyItems, + InventoryType.TMHMs, + InventoryType.Medicine, InventoryType.Berries, InventoryType.Balls, InventoryType.BattleItems, + InventoryType.Treasure, + InventoryType.Ingredients, InventoryType.Candy, + }; + + private static ReadOnlySpan ValidHeldTypes => new[] + { + InventoryType.Items, + InventoryType.TMHMs, + InventoryType.Medicine, InventoryType.Berries, InventoryType.Balls, InventoryType.BattleItems, + InventoryType.Treasure, + }; + + // [AUCTION] Porto Marinada specialty auctioneer, locked behind HOME in 2023. + public static ReadOnlySpan Unreleased => new ushort[] + { + 0005, // Safari Ball + 0016, // Cherish Ball + + 0111, // Odd Keystone + 0112, // [AUCTION] Griseous Orb + 0135, // [AUCTION] Adamant Orb + 0136, // [AUCTION] Lustrous Orb + + 0208, // Enigma Berry + 0209, // Micle Berry + 0210, // Custap Berry + 0211, // Jaboca Berry + 0212, // Rowap Berry + + 0298, // [AUCTION] Flame Plate + 0299, // [AUCTION] Splash Plate + 0300, // [AUCTION] Zap Plate + 0301, // [AUCTION] Meadow Plate + 0302, // [AUCTION] Icicle Plate + 0303, // [AUCTION] Fist Plate + 0304, // [AUCTION] Toxic Plate + 0305, // [AUCTION] Earth Plate + 0306, // [AUCTION] Sky Plate + 0307, // [AUCTION] Mind Plate + 0308, // [AUCTION] Insect Plate + 0309, // [AUCTION] Stone Plate + 0310, // [AUCTION] Spooky Plate + 0311, // [AUCTION] Draco Plate + 0312, // [AUCTION] Dread Plate + 0313, // [AUCTION] Iron Plate + + 0485, // Red Apricorn + 0486, // Blue Apricorn + 0487, // Yellow Apricorn + 0488, // Green Apricorn + 0489, // Pink Apricorn + 0490, // White Apricorn + 0491, // Black Apricorn + + 0499, // Sport Ball + 0500, // Park Ball + 0644, // [AUCTION] Pixie Plate + 0708, // Lumiose Galette + 0709, // Shalour Sable + + 1103, // [AUCTION] Rusted Sword + 1104, // [AUCTION] Rusted Shield + + 1230, // TM00 - Mega Punch (Nothing learns, not obtainable even though it is assigned a move.) + + 1582, // [AUCTION] Galarica Cuff + 1592, // [AUCTION] Galarica Wreath + + 1777, // [AUCTION] Adamant Crystal + 1778, // [AUCTION] Lustrous Globe + 1779, // [AUCTION] Griseous Core + + 1785, // Strange Ball + }; + + public int GetMax(InventoryType type) => type switch + { + InventoryType.Items => 999, + InventoryType.KeyItems => 1, + InventoryType.TMHMs => 999, + InventoryType.Medicine => 999, + InventoryType.Berries => 999, + InventoryType.Balls => 999, + InventoryType.BattleItems => 999, + InventoryType.Treasure => 999, + InventoryType.Ingredients => 999, // 999 + InventoryType.Candy => 999, // 999 + _ => throw new ArgumentOutOfRangeException(nameof(type)), + }; + + public bool IsLegal(InventoryType type, int itemIndex, int itemCount) + { + return Unreleased.BinarySearch((ushort)itemIndex) < 0; + } + + public ReadOnlySpan GetItems(InventoryType type) => GetLegal(type); + + public static ReadOnlySpan GetLegal(InventoryType type) => type switch + { + InventoryType.Items => Pouch_Other_SV, + InventoryType.KeyItems => Pouch_Event_SV, + InventoryType.TMHMs => Pouch_TM_SV, + InventoryType.Medicine => Pouch_Medicine_SV, + InventoryType.Berries => Pouch_Berries_SV, + InventoryType.Balls => Pouch_Ball_SV, + InventoryType.BattleItems => Pouch_Battle_SV, + InventoryType.Treasure => Pouch_Treasure_SV, + InventoryType.Ingredients => Pouch_Picnic_SV, + InventoryType.Candy => Pouch_Material_SV, + _ => throw new ArgumentOutOfRangeException(nameof(type)), + }; + + public static ushort[] GetAllHeld() + { + var valid = ValidHeldTypes; + var sum = 0; + foreach (var type in valid) + sum += GetLegal(type).Length; + + var result = new ushort[sum]; + LoadAllHeld(valid, result); + return result; + } + + private static void LoadAllHeld(ReadOnlySpan valid, Span dest) + { + foreach (var type in valid) + { + var legal = GetLegal(type); + legal.CopyTo(dest); + dest = dest[legal.Length..]; + } + } + + public static InventoryType GetInventoryPouch(ushort itemIndex) + { + foreach (var type in ValidTypes) + { + var legal = GetLegal(type); + if (legal.Contains(itemIndex)) + return type; + } + return InventoryType.None; + } +} diff --git a/PKHeX.Core/Legality/Areas/EncounterArea6XY.cs b/PKHeX.Core/Legality/Areas/EncounterArea6XY.cs index 5fc749577..3a0d53bae 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea6XY.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea6XY.cs @@ -43,30 +43,7 @@ private EncounterSlot6XY[] LoadSafariSlots() const int SpeciesFormSlots = 4; // Single form species - Span species = stackalloc ushort[] - { - 002, 005, 008, 012, 014, 016, 021, 025, 027, 035, - 038, 039, 043, 044, 046, 049, 049, 051, 056, 058, - 061, 063, 067, 077, 082, 083, 084, 087, 089, 091, - 095, 096, 098, 101, 105, 112, 113, 114, 125, 126, - 127, 130, 131, 132, 133, 148, 163, 165, 168, 175, - 178, 184, 190, 191, 194, 195, 202, 203, 205, 206, - 209, 213, 214, 215, 215, 216, 218, 219, 221, 222, - 224, 225, 227, 231, 235, 236, 247, 262, 267, 268, - 274, 281, 284, 286, 290, 294, 297, 299, 302, 303, - 303, 307, 310, 313, 314, 317, 323, 326, 328, 332, - 336, 342, 352, 353, 356, 357, 359, 361, 363, 372, - 375, 400, 404, 415, 417, 419, 423, 426, 437, 442, - 444, 447, 452, 454, 459, 506, 510, 511, 513, 515, - 517, 520, 523, 525, 527, 530, 531, 536, 538, 539, - 541, 544, 548, 551, 556, 557, 561, 569, 572, 575, - 578, 581, 586, 587, 596, 597, 600, 608, 611, 614, - 618, 619, 621, 623, 624, 627, 629, 636, 651, 654, - 657, 660, 662, 662, 668, 673, 674, 677, 682, 684, - 686, 689, 694, 701, 702, 702, 705, 707, 708, 710, - 712, 714, - }; - + var species = AllSpecies; var slots = new EncounterSlot6XY[species.Length + SpeciesFormSlots]; int i = 0; for (; i < species.Length; i++) @@ -82,6 +59,32 @@ private EncounterSlot6XY[] LoadSafariSlots() return slots; } + private static ReadOnlySpan AllSpecies => new ushort[] + { + 002, 005, 008, 012, 014, 016, 021, 025, 027, 035, + 038, 039, 043, 044, 046, 049, 049, 051, 056, 058, + 061, 063, 067, 077, 082, 083, 084, 087, 089, 091, + 095, 096, 098, 101, 105, 112, 113, 114, 125, 126, + 127, 130, 131, 132, 133, 148, 163, 165, 168, 175, + 178, 184, 190, 191, 194, 195, 202, 203, 205, 206, + 209, 213, 214, 215, 215, 216, 218, 219, 221, 222, + 224, 225, 227, 231, 235, 236, 247, 262, 267, 268, + 274, 281, 284, 286, 290, 294, 297, 299, 302, 303, + 303, 307, 310, 313, 314, 317, 323, 326, 328, 332, + 336, 342, 352, 353, 356, 357, 359, 361, 363, 372, + 375, 400, 404, 415, 417, 419, 423, 426, 437, 442, + 444, 447, 452, 454, 459, 506, 510, 511, 513, 515, + 517, 520, 523, 525, 527, 530, 531, 536, 538, 539, + 541, 544, 548, 551, 556, 557, 561, 569, 572, 575, + 578, 581, 586, 587, 596, 597, 600, 608, 611, 614, + 618, 619, 621, 623, 624, 627, 629, 636, 651, 654, + 657, 660, 662, 662, 668, 673, 674, 677, 682, 684, + 686, 689, 694, 701, 702, 702, 705, 707, 708, 710, + 712, 714, + + // Handle Floette (670) and Vivillon (666) separately + }; + private EncounterSlot6XY[] ReadSlots(ReadOnlySpan data) { const int size = 4; diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen12/Encounters2.cs b/PKHeX.Core/Legality/Encounters/Data/Gen12/Encounters2.cs index 9c0fc5c51..55a98fd66 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen12/Encounters2.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen12/Encounters2.cs @@ -102,7 +102,7 @@ internal static class Encounters2 }; private static readonly EncounterStatic2[] Encounter_GS = ArrayUtil.ConcatAll(Encounter_GSC_Common, Encounter_GS_Exclusive, Encounter_GSC_Roam); - private static readonly EncounterStatic2[] Encounter_C = ArrayUtil.ConcatAll(Encounter_GSC_Common, Encounter_C_Exclusive, Encounter_GSC_Roam.AsSpan(0, 2)); + private static readonly EncounterStatic2[] Encounter_C = ArrayUtil.ConcatAll(Encounter_GSC_Common, Encounter_C_Exclusive, Encounter_GSC_Roam.AsSpan(0, 2)); private static readonly EncounterStatic2[] Encounter_GSC = ArrayUtil.ConcatAll(Encounter_GSC_Common, Encounter_GS_Exclusive, Encounter_C_Exclusive, Encounter_GSC_Roam); internal static readonly EncounterTrade2[] TradeGift_GSC = diff --git a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6.cs b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6.cs index 75ea94b7c..2d4d68b98 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6.cs @@ -42,13 +42,13 @@ public override bool CanUseItemGeneric(int item) public override IEnumerable GetMemoryItemParams() => Legal.HeldItem_AO.Distinct() .Concat(GetKeyItemParams()) - .Concat(Legal.Pouch_TMHM_AO.Take(100)) + .Concat(ItemStorage6AO.Pouch_TMHM_AO[..100].ToArray()) .Where(z => z <= Legal.MaxItemID_6_AO); public override bool IsUsedKeyItemUnspecific(int item) => KeyItemUsableObserve6.Contains((ushort)item); public override bool IsUsedKeyItemSpecific(int item, ushort species) => KeyItemMemoryArgsGen6.TryGetValue(species, out var value) && value.Contains((ushort)item); - public override bool CanPlantBerry(int item) => Legal.Pouch_Berry_XY.Contains((ushort)item); + public override bool CanPlantBerry(int item) => ItemStorage6XY.Pouch_Berry_XY.Contains((ushort)item); public override bool CanHoldItem(int item) => Legal.HeldItem_AO.Contains((ushort)item); public override bool CanObtainMemoryOT(GameVersion pkmVersion, byte memory) => pkmVersion switch diff --git a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8.cs b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8.cs index 233daa825..fedc17c55 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8.cs @@ -14,7 +14,7 @@ public sealed partial class MemoryContext8 : MemoryContext public override IEnumerable GetMemoryItemParams() => Legal.HeldItem_AO.Concat(Legal.HeldItems_SWSH).Distinct() .Concat(GetKeyItemParams()) - .Concat(Legal.Pouch_TMHM_AO.Take(100)) + .Concat(ItemStorage6AO.Pouch_TMHM_AO[..100].ToArray()) .Where(z => z <= Legal.MaxItemID_8_R2); public override bool CanUseItemGeneric(int item) => true; // todo @@ -63,7 +63,7 @@ public override bool IsInvalidMiscMemory(byte memory, ushort variable) { 1085 => version is GameVersion.SW or GameVersion.Any, // Bob's Food Tin 1086 => version is GameVersion.SH or GameVersion.Any, // Bach's Food Tin - _ => PurchaseableItemSWSH.Contains((ushort)item), + _ => ItemStorage8SWSH.IsTechRecord((ushort)item) || PurchaseItemsNoTR.BinarySearch((ushort)item) >= 0, }; private static bool IsInvalidGenLoc8(byte memory, int loc, int egg, ushort variable, PKM pk, IEncounterTemplate enc) diff --git a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8Data.cs b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8Data.cs index 40eef5d23..e4b599947 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8Data.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8Data.cs @@ -51,7 +51,10 @@ public partial class MemoryContext8 {(int) Species.Calyrex, new ushort[] {1590, 1591}}, // Reigns of Unity }; - private static readonly HashSet PurchaseableItemSWSH = new(Legal.Pouch_TR_SWSH) + /// + /// Includes all purchase-able items except for TRs (separate span). + /// + private static ReadOnlySpan PurchaseItemsNoTR => new ushort[] { 0002, 0003, 0004, 0006, 0007, 0008, 0009, 0010, 0011, 0013, 0014, 0015, 0017, 0018, 0019, 0020, 0021, 0022, 0023, 0024, diff --git a/PKHeX.Core/Legality/Tables/Tables1.cs b/PKHeX.Core/Legality/Tables/Tables1.cs index a3090a6db..c197a9349 100644 --- a/PKHeX.Core/Legality/Tables/Tables1.cs +++ b/PKHeX.Core/Legality/Tables/Tables1.cs @@ -6,21 +6,4 @@ public static partial class Legal internal const int MaxMoveID_1 = 165; internal const int MaxItemID_1 = 255; internal const int MaxAbilityID_1 = 0; - - internal static readonly ushort[] Pouch_Items_RBY = - { - 000,001,002,003,004,005,006, 010,011,012,013,014,015, - 016,017,018,019,020, 029,030,031, - 032,033,034,035,036,037,038,039,040,041,042,043, 045,046,047, - 048,049, 051,052,053,054,055,056,057,058, 060,061,062,063, - 064,065,066,067,068,069,070,071,072,073,074,075,076,077,078,079, - 080,081,082,083, - - // ... - - 196,197,198,199,200,201,202,203,204,205,206,207, - 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, - 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, - 240,241,242,243,244,245,246,247,248,249,250, - }; } diff --git a/PKHeX.Core/Legality/Tables/Tables2.cs b/PKHeX.Core/Legality/Tables/Tables2.cs index ae9d4182d..13d7d06bd 100644 --- a/PKHeX.Core/Legality/Tables/Tables2.cs +++ b/PKHeX.Core/Legality/Tables/Tables2.cs @@ -7,25 +7,7 @@ public static partial class Legal internal const int MaxItemID_2 = 255; internal const int MaxAbilityID_2 = 0; - internal static readonly ushort[] Pouch_Items_GSC = { - 3, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 51, 52, 53, 57, 60, 62, 63, 64, 65, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 117, 118, 119, 121, 122, 123, 124, 125, 126, 131, 132, 138, 139, 140, 143, 144, 146, 150, 151, 152, 156, 158, 163, 167, 168, 169, 170, 172, 173, 174, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, - }; - - internal static readonly ushort[] Pouch_Ball_GSC = { - 1, 2, 4, 5, 157, 159, 160, 161, 164, 165, 166, - }; - - internal static readonly ushort[] Pouch_Key_GS = { - 7, 54, 55, 58, 59, 61, 66, 67, 68, 69, 71, 127, 128, 130, 133, 134, 175, 178, - }; - - internal static readonly ushort[] Pouch_Key_C = ArrayUtil.ConcatAll(Pouch_Key_GS, stackalloc ushort[] {70, 115, 116, 129}); - - internal static readonly ushort[] Pouch_TMHM_GSC = { - 191, 192, 193, 194, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, - }; - - internal static readonly ushort[] HeldItems_GSC = ArrayUtil.ConcatAll(Pouch_Items_GSC, Pouch_Ball_GSC, Pouch_TMHM_GSC); + internal static readonly ushort[] HeldItems_GSC = ItemStorage2.GetAllHeld(); internal static readonly bool[] ReleasedHeldItems_2 = GetPermitList(MaxItemID_2, HeldItems_GSC); } diff --git a/PKHeX.Core/Legality/Tables/Tables3.cs b/PKHeX.Core/Legality/Tables/Tables3.cs index 88a57f80a..c852a9bac 100644 --- a/PKHeX.Core/Legality/Tables/Tables3.cs +++ b/PKHeX.Core/Legality/Tables/Tables3.cs @@ -15,74 +15,12 @@ public static partial class Legal internal const int MaxGameID_3 = 15; // CXD #region RS - internal static readonly ushort[] Pouch_Items_RS = { - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 93, 94, 95, 96, 97, 98, 103, 104, 106, 107, 108, 109, 110, 111, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 254, 255, 256, 257, 258, - }; - internal static readonly ushort[] Pouch_Key_RS = { - 259, 260, 261, 262, 263, 264, 265, 266, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, - }; - - internal static readonly ushort[] Pouch_TM_RS = { - 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, - }; - - public static readonly ushort[] Pouch_HM_RS = { - 339, 340, 341, 342, 343, 344, 345, 346, - }; - - internal static readonly ushort[] Pouch_Berries_RS = { - 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, - }; - - internal static readonly ushort[] Pouch_Ball_RS = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, - }; - - internal static readonly ushort[] Pouch_Key_FRLG = ArrayUtil.ConcatAll(Pouch_Key_RS, stackalloc ushort[] { 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374 }); - internal static readonly ushort[] Pouch_Key_E = ArrayUtil.ConcatAll(Pouch_Key_FRLG, stackalloc ushort[] { 375, 376 }); - - internal static readonly ushort[] Pouch_TMHM_RS = ArrayUtil.ConcatAll(Pouch_TM_RS, Pouch_HM_RS); - internal static readonly ushort[] HeldItems_RS = ArrayUtil.ConcatAll(Pouch_Items_RS, Pouch_Ball_RS, Pouch_Berries_RS, Pouch_TM_RS); + internal static readonly ushort[] HeldItems_RS = ItemStorage3RS.GetAllHeld(); #endregion - internal static readonly ushort[] Pouch_Cologne_COLO = {543, 544, 545}; - internal static readonly ushort[] Pouch_Items_COLO = ArrayUtil.ConcatAll(Pouch_Items_RS, stackalloc ushort[] {537}); // Time Flute - internal static readonly ushort[] HeldItems_COLO = ArrayUtil.ConcatAll(Pouch_Items_COLO, Pouch_Ball_RS, Pouch_Berries_RS, Pouch_TM_RS); - internal static readonly ushort[] Pouch_Key_COLO = - { - 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, - 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, - 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, - 530, 531, 532, 533, 534, 535, 536, 538, 539, - 540, 541, 542, 546, 547, - }; - - internal static readonly ushort[] Pouch_Cologne_XD = {513, 514, 515}; - internal static readonly ushort[] Pouch_Items_XD = ArrayUtil.ConcatAll(Pouch_Items_RS, stackalloc ushort[] {511}); // Poké Snack - internal static readonly ushort[] HeldItems_XD = ArrayUtil.ConcatAll(Pouch_Items_XD, Pouch_Ball_RS, Pouch_Berries_RS, Pouch_TM_RS); - - internal static readonly ushort[] Pouch_Key_XD = - { - 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, - 510, 512, 516, 517, 518, 519, - 523, 524, 525, 526, 527, 528, 529, - 530, 531, 532, 533, - }; - - internal static readonly ushort[] Pouch_Disc_XD = - { - 534, 535, 536, 537, 538, 539, - 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, - 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, - 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, - 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, - 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, - 590, 591, 592, 593, - }; - - internal static readonly bool[] ReleasedHeldItems_3 = GetPermitList(MaxItemID_3, HeldItems_RS, stackalloc ushort[] {005}); // Safari Ball + internal static readonly bool[] ReleasedHeldItems_3 = GetPermitList(MaxItemID_3, HeldItems_RS, ItemStorage3RS.Unreleased); // Safari Ball // 064 is an unused location for Meteor Falls // 084 is Inside of a truck, no possible pokemon can be hatched there diff --git a/PKHeX.Core/Legality/Tables/Tables4.cs b/PKHeX.Core/Legality/Tables/Tables4.cs index 694f3f467..be3a06e53 100644 --- a/PKHeX.Core/Legality/Tables/Tables4.cs +++ b/PKHeX.Core/Legality/Tables/Tables4.cs @@ -14,90 +14,11 @@ public static partial class Legal internal const int MaxBallID_4 = 0x18; internal const int MaxGameID_4 = 15; // CXD - #region DP - internal static readonly ushort[] Pouch_Items_DP = { - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 135, 136, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, - }; + internal static readonly ushort[] HeldItems_DP = ItemStorage4DP.GetAllHeld(); + internal static readonly ushort[] HeldItems_Pt = ItemStorage4Pt.GetAllHeld(); // Griseous Orb Added + internal static readonly ushort[] HeldItems_HGSS = HeldItems_Pt; - internal static readonly ushort[] Pouch_Key_DP = { - 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, - }; - - internal static readonly ushort[] Pouch_TMHM_DP = { - 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, - }; - - internal static readonly ushort[] Pouch_Mail_DP = { - 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, - }; - - internal static readonly ushort[] Pouch_Medicine_DP = { - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - }; - - internal static readonly ushort[] Pouch_Berries_DP = { - 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - }; - - internal static readonly ushort[] Pouch_Ball_DP = { - 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - }; - - internal static readonly ushort[] Pouch_Battle_DP = { - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - }; - - internal static readonly ushort[] HeldItems_DP = ArrayUtil.ConcatAll(Pouch_Items_DP, Pouch_Mail_DP, Pouch_Medicine_DP, Pouch_Berries_DP, Pouch_Ball_DP, Pouch_TMHM_DP.Slice(0, Pouch_TMHM_DP.Length - 8)); - #endregion - - #region Pt - internal static readonly ushort[] Pouch_Items_Pt = { - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 135, 136, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, - }; - - internal static readonly ushort[] Pouch_Key_Pt = { - 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, - }; - - internal static readonly ushort[] Pouch_TMHM_Pt = Pouch_TMHM_DP; - internal static readonly ushort[] Pouch_Mail_Pt = Pouch_Mail_DP; - internal static readonly ushort[] Pouch_Medicine_Pt = Pouch_Medicine_DP; - internal static readonly ushort[] Pouch_Berries_Pt = Pouch_Berries_DP; - internal static readonly ushort[] Pouch_Ball_Pt = Pouch_Ball_DP; - internal static readonly ushort[] Pouch_Battle_Pt = Pouch_Battle_DP; - - internal static readonly ushort[] HeldItems_Pt = ArrayUtil.ConcatAll(Pouch_Items_Pt, Pouch_Mail_Pt, Pouch_Medicine_Pt, Pouch_Berries_Pt, Pouch_Ball_Pt, Pouch_TMHM_Pt.Slice(0, Pouch_TMHM_Pt.Length - 8)); - #endregion - - #region HGSS - internal static readonly ushort[] Pouch_Items_HGSS = Pouch_Items_Pt; - - internal static readonly ushort[] Pouch_Key_HGSS = { - 434, 435, 437, 444, 445, 446, 447, 450, 456, 464, 465, 466, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 501, 502, 503, 504, 532, 533, 534, 535, 536, - }; - - internal static readonly ushort[] Pouch_TMHM_HGSS = Pouch_TMHM_DP; - internal static readonly ushort[] Pouch_Mail_HGSS = Pouch_Mail_DP; - internal static readonly ushort[] Pouch_Medicine_HGSS = Pouch_Medicine_DP; - internal static readonly ushort[] Pouch_Berries_HGSS = Pouch_Berries_DP; - - internal static readonly ushort[] Pouch_Ball_HGSS = { - 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 492, 493, 494, 495, 496, 497, 498, 499, 500, - }; - - internal static readonly ushort[] Pouch_Battle_HGSS = Pouch_Battle_DP; - - internal static readonly ushort[] HeldItems_HGSS = ArrayUtil.ConcatAll(Pouch_Items_HGSS, Pouch_Mail_HGSS, Pouch_Medicine_HGSS, Pouch_Berries_HGSS, Pouch_Ball_Pt, Pouch_TMHM_HGSS.Slice(0, Pouch_TMHM_HGSS.Length - 8)); - #endregion - - internal static readonly bool[] ReleasedHeldItems_4 = GetPermitList(MaxItemID_4_HGSS, HeldItems_HGSS, stackalloc ushort[] - { - 005, // Safari Ball - 016, // Cherish Ball - 147, // Mosaic Mail - 499, // Sport Ball - 500, // Park Ball - }); + internal static readonly bool[] ReleasedHeldItems_4 = GetPermitList(MaxItemID_4_HGSS, HeldItems_HGSS, ItemStorage4.Unreleased); internal static readonly HashSet ValidMet_DP = new() { diff --git a/PKHeX.Core/Legality/Tables/Tables5.cs b/PKHeX.Core/Legality/Tables/Tables5.cs index 375ff450f..78408d100 100644 --- a/PKHeX.Core/Legality/Tables/Tables5.cs +++ b/PKHeX.Core/Legality/Tables/Tables5.cs @@ -12,52 +12,9 @@ public static partial class Legal internal const int MaxBallID_5 = 0x19; internal const int MaxGameID_5 = 23; // B2 - internal static readonly ushort[] Pouch_Items_BW = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 116, 117, 118, 119, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 492, 493, 494, 495, 496, 497, 498, 499, 500, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 571, 572, 573, 575, 576, 577, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, - }; + internal static readonly ushort[] HeldItems_BW = ItemStorage5.GetAllHeld(); - internal static readonly ushort[] Pouch_Key_BW = { - 437, 442, 447, 450, 465, 466, 471, 504, 533, 574, 578, 579, 616, 617, 621, 623, 624, 625, 626, - }; - - internal static readonly ushort[] Pouch_TMHM_BW = { - 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 618, 619, 620, 420, 421, 422, 423, 424, 425, - }; - - internal static readonly ushort[] Pouch_Medicine_BW = { - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 134, 504, 565, 566, 567, 568, 569, 570, 591, - }; - - internal static readonly ushort[] Pouch_Berries_BW = { - 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - }; - - internal static readonly ushort[] HeldItems_BW = ArrayUtil.ConcatAll(Pouch_Items_BW, Pouch_Medicine_BW, Pouch_Berries_BW); - - internal static readonly ushort[] Pouch_Key_B2W2 = { - 437, 442, 447, 450, 453, 458, 465, 466, 471, 504, 578, 616, 617, 621, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, - }; - - internal static readonly bool[] ReleasedHeldItems_5 = GetPermitList(MaxItemID_5_B2W2, HeldItems_BW, stackalloc ushort[] - { - 005, // Safari Ball - 016, // Cherish Ball - 260, // Red Scarf - 261, // Blue Scarf - 262, // Pink Scarf - 263, // Green Scarf - 264, // Yellow Scarf - 492, // Fast Ball - 493, // Level Ball - 494, // Lure Ball - 495, // Heavy Ball - 496, // Love Ball - 497, // Friend Ball - 498, // Moon Ball - 499, // Sport Ball - 500, // Park Ball - 576, // Dream Ball - }); + internal static readonly bool[] ReleasedHeldItems_5 = GetPermitList(MaxItemID_5_B2W2, HeldItems_BW, ItemStorage5.Unreleased); internal static readonly HashSet ValidMet_BW = new() { diff --git a/PKHeX.Core/Legality/Tables/Tables6.cs b/PKHeX.Core/Legality/Tables/Tables6.cs index 908d1f25b..ad303263c 100644 --- a/PKHeX.Core/Legality/Tables/Tables6.cs +++ b/PKHeX.Core/Legality/Tables/Tables6.cs @@ -14,138 +14,7 @@ public static partial class Legal internal const int MaxBallID_6 = 0x19; internal const int MaxGameID_6 = 27; // OR - #region Inventory Pouch - - internal static readonly ushort[] Pouch_Items_XY = - { - 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056, - 057, 058, 059, 060, 061, 062, 063, 064, 065, 066, 067, 068, 069, 070, 071, 072, 073, 074, 075, - 076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, 090, 091, 092, 093, 094, - 099, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 116, 117, 118, 119, 135, 136, - 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, - 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, - 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, - 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, - 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, - 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, - 492, 493, 494, 495, 496, 497, 498, 499, 500, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, - 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 571, - 572, 573, 576, 577, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 639, 640, 644, 646, - 647, 648, 649, 650, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, - 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, - 699, 704, 710, 711, 715, - }; - - internal static readonly ushort[] Pouch_Items_AO = - { - 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056, - 057, 058, 059, 060, 061, 062, 063, 064, 068, 069, 070, 071, 072, 073, 074, 075, - 076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, 090, 091, 092, 093, 094, - 099, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 116, 117, 118, 119, 135, 136, - 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, - 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, - 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, - 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, - 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, - 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, - 492, 493, 494, 495, 496, 497, 498, 499, 500, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, - 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 571, - 572, 573, 576, 577, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 639, 640, 644, 646, - 647, 648, 649, 650, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, - 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, - 699, 704, 710, 711, 715, - - // ORAS - 534, 535, - 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 767, 768, 769, 770, - }; - - internal static readonly ushort[] Pouch_Key_XY = - { - 216, 431, 442, 445, 446, 447, 450, 465, 466, 471, 628, - 629, 631, 632, 638, 641, 642, 643, 651, 689, 695, 696, 697, 698, - 700, 701, 702, 703, 705, 712, 713, 714, - - // Illegal - // 716, 717, 706, 707, - }; - - internal static readonly ushort[] Pouch_Key_AO = - { - 216, 445, 446, 447, 465, 466, 471, 628, - 629, 631, 632, 638, 697, - - // Illegal - // 716, 717, 723, 745, 746, 747, 748, 749, 750, 766, - - // ORAS - 457, 474, 503, - - 718, 719, - 720, 721, 722, 724, 725, 726, 727, 728, 729, - 730, 731, 732, 733, 734, 735, 736, 738, 739, - 740, 741, 742, 743, 744, - 751, - 765, 771, 772, 774, 775, - }; - - internal static readonly ushort[] Pouch_TMHM_XY = - { - 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, - 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, - 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, - 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, - 418, 419, 618, 619, 620, 690, 691, 692, 693, 694, - - 420, 421, 422, 423, 424, - }; - - internal static readonly ushort[] Pouch_TMHM_AO = - { - 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, - 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, - 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, - 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, - 418, 419, 618, 619, 620, 690, 691, 692, 693, 694, - - 420, 421, 422, 423, 424, - - // ORAS - 425, 737, - }; - - internal static readonly ushort[] Pouch_Medicine_XY = - { - 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, - 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051, - 052, 053, 054, 134, 504, 565, 566, 567, 568, 569, 570, 571, 591, 645, 708, 709, - }; - - internal static readonly ushort[] Pouch_Medicine_AO = - { - 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, - 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051, - 052, 053, 054, 134, 504, 565, 566, 567, 568, 569, 570, 571, 591, 645, 708, 709, - - //ORAS - 065, 066, 067, - }; - - public static readonly ushort[] Pouch_Berry_XY = - { - 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, - 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, - 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, - 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, - 208, 209, 210, 211, 212, 686, 687, 688, - }; - - internal static readonly ushort[] HeldItem_XY = ArrayUtil.ConcatAll(Pouch_Items_XY, Pouch_Medicine_XY, Pouch_Berry_XY); - internal static readonly ushort[] HeldItem_AO = ArrayUtil.ConcatAll(Pouch_Items_AO, Pouch_Medicine_AO, Pouch_Berry_XY); - #endregion - + internal static readonly ushort[] HeldItem_AO = ItemStorage6XY.GetAllHeld(); internal static readonly HashSet ValidMet_XY = new() { @@ -191,42 +60,5 @@ public static partial class Legal 350, 352, 354, }; - internal static readonly bool[] ReleasedHeldItems_6 = GetPermitList(MaxItemID_6_AO, HeldItem_AO, stackalloc ushort[] - { - 005, // Safari Ball - 016, // Cherish Ball - 492, // Fast Ball - 493, // Level Ball - 494, // Lure Ball - 495, // Heavy Ball - 496, // Love Ball - 497, // Friend Ball - 498, // Moon Ball - 499, // Sport Ball - 500, // Park Ball - 548, // Fire Gem - 549, // Water Gem - 550, // Electric Gem - 551, // Grass Gem - 552, // Ice Gem - 553, // Fighting Gem - 554, // Poison Gem - 555, // Ground Gem - 556, // Flying Gem - 557, // Psychic Gem - 558, // Bug Gem - 559, // Rock Gem - 560, // Ghost Gem - 561, // Dragon Gem - 562, // Dark Gem - 563, // Steel Gem - 576, // Dream Ball - 584, // Relic Copper - 585, // Relic Silver - 587, // Relic Vase - 588, // Relic Band - 589, // Relic Statue - 590, // Relic Crown - 715, // Fairy Gem - }); + internal static readonly bool[] ReleasedHeldItems_6 = GetPermitList(MaxItemID_6_AO, HeldItem_AO, ItemStorage6XY.Unreleased); } diff --git a/PKHeX.Core/Legality/Tables/Tables7.cs b/PKHeX.Core/Legality/Tables/Tables7.cs index 971c7b769..a0ef58f53 100644 --- a/PKHeX.Core/Legality/Tables/Tables7.cs +++ b/PKHeX.Core/Legality/Tables/Tables7.cs @@ -16,91 +16,7 @@ public static partial class Legal internal const int MaxMoveID_7_USUM = 728; internal const int MaxItemID_7_USUM = 959; internal const int MaxAbilityID_7_USUM = 233; - - internal static readonly ushort[] Pouch_Regular_SM = // 00 - { - 068, 069, 070, 071, 072, 073, 074, 075, 076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 086, 087, - 088, 089, 090, 091, 092, 093, 094, 099, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 116, 117, 118, 119, 135, 136, 137, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, - 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, - 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, - 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, - 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, - 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, - 326, 327, 499, 534, 535, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, - 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 571, 572, 573, 580, 581, 582, 583, - 584, 585, 586, 587, 588, 589, 590, 639, 640, 644, 646, 647, 648, 649, 650, 656, 657, 658, 659, - 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, - 680, 681, 682, 683, 684, 685, 699, 704, 710, 711, 715, 752, 753, 754, 755, 756, 757, 758, 759, 760, - 761, 762, 763, 764, 767, 768, 769, 770, 795, 796, 844, 849, 853, 854, 855, 856, 879, 880, 881, 882, - 883, 884, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, - }; - - internal static readonly ushort[] Pouch_Ball_SM = { // 08 - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 492, 493, 494, 495, 496, 497, 498, 576, - 851, - }; - - internal static readonly ushort[] Pouch_Battle_SM = { // 16 - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 577, - 846, - }; - - internal static readonly ushort[] Pouch_Items_SM = ArrayUtil.ConcatAll(Pouch_Regular_SM, Pouch_Ball_SM, Pouch_Battle_SM); - - internal static readonly ushort[] Pouch_Key_SM = { - 216, 465, 466, 628, 629, 631, 632, 638, - 705, 706, 765, 773, 797, - 841, 842, 843, 845, 847, 850, 857, 858, 860, - }; - - internal static readonly ushort[] Pouch_Key_USUM = ArrayUtil.ConcatAll(Pouch_Key_SM, stackalloc ushort[] { - 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, - 440, - }); - - public static readonly ushort[] Pouch_Roto_USUM = { - 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, - }; - - internal static readonly ushort[] Pouch_TMHM_SM = { // 02 - 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, - 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, - 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, - 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, - 418, 419, 618, 619, 620, 690, 691, 692, 693, 694, - }; - - internal static readonly ushort[] Pouch_Medicine_SM = { // 32 - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 65, 66, 67, 134, - 504, 565, 566, 567, 568, 569, 570, 591, 645, 708, 709, - 852, - }; - - internal static readonly ushort[] Pouch_Berries_SM = { - 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - 686, 687, 688, - }; - - internal static readonly ushort[] Pouch_ZCrystal_SM = { // Bead - 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, - }; - - internal static readonly ushort[] Pouch_ZCrystalHeld_SM = { // Piece - 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 798, 799, 800, 801, 802, 803, 804, 805, 806, 836, - }; - - internal static readonly ushort[] Pouch_ZCrystal_USUM = ArrayUtil.ConcatAll(Pouch_ZCrystal_SM, stackalloc ushort[] { // Bead - 927, 928, 929, 930, 931, 932, - }); - - internal static readonly ushort[] Pouch_ZCrystalHeld_USUM = ArrayUtil.ConcatAll(Pouch_ZCrystalHeld_SM, stackalloc ushort[] { // Piece - 921, 922, 923, 924, 925, 926, - }); - - public static readonly Dictionary ZCrystalDictionary = GetDictionary(Pouch_ZCrystal_USUM, Pouch_ZCrystalHeld_USUM); - + private static Dictionary GetDictionary(IReadOnlyList key, IReadOnlyList held) { var result = new Dictionary(held.Count); @@ -109,8 +25,8 @@ public static partial class Legal return result; } - internal static readonly ushort[] HeldItems_SM = ArrayUtil.ConcatAll(Pouch_Items_SM, Pouch_Berries_SM, Pouch_Medicine_SM, Pouch_ZCrystalHeld_SM); - internal static readonly ushort[] HeldItems_USUM = ArrayUtil.ConcatAll(Pouch_Items_SM, Pouch_Berries_SM, Pouch_Medicine_SM, Pouch_ZCrystalHeld_USUM, Pouch_Roto_USUM); + internal static readonly ushort[] HeldItems_SM = ItemStorage7SM.GetAllHeld(); + internal static readonly ushort[] HeldItems_USUM = ItemStorage7USUM.GetAllHeld(); internal static readonly HashSet AlolanOriginForms = new() { @@ -253,69 +169,6 @@ public static partial class Legal }; #region Unreleased Items - internal static readonly bool[] ReleasedHeldItems_7 = GetPermitList(MaxItemID_7_USUM, HeldItems_USUM, stackalloc ushort[] - { - 005, // Safari Ball - 016, // Cherish Ball - 064, // Fluffy Tail - 065, // Blue Flute - 066, // Yellow Flute - 067, // Red Flute - 068, // Black Flute - 069, // White Flute - 070, // Shoal Salt - 071, // Shoal Shell - 103, // Old Amber - 111, // Odd Keystone - 164, // Razz Berry - 166, // Nanab Berry - 167, // Wepear Berry - 175, // Cornn Berry - 176, // Magost Berry - 177, // Rabuta Berry - 178, // Nomel Berry - 179, // Spelon Berry - 180, // Pamtre Berry - 181, // Watmel Berry - 182, // Durin Berry - 183, // Belue Berry - //208, // Enigma Berry - //209, // Micle Berry - //210, // Custap Berry - //211, // Jaboca Berry - //212, // Rowap Berry - 215, // Macho Brace - 260, // Red Scarf - 261, // Blue Scarf - 262, // Pink Scarf - 263, // Green Scarf - 264, // Yellow Scarf - 499, // Sport Ball - 548, // Fire Gem - 549, // Water Gem - 550, // Electric Gem - 551, // Grass Gem - 552, // Ice Gem - 553, // Fighting Gem - 554, // Poison Gem - 555, // Ground Gem - 556, // Flying Gem - 557, // Psychic Gem - 558, // Bug Gem - 559, // Rock Gem - 560, // Ghost Gem - 561, // Dragon Gem - 562, // Dark Gem - 563, // Steel Gem - 576, // Dream Ball - 584, // Relic Copper - 585, // Relic Silver - 587, // Relic Vase - 588, // Relic Band - 589, // Relic Statue - 590, // Relic Crown - 699, // Discount Coupon - 715, // Fairy Gem - }); + internal static readonly bool[] ReleasedHeldItems_7 = GetPermitList(MaxItemID_7_USUM, HeldItems_USUM, ItemStorage7SM.Unreleased); #endregion } diff --git a/PKHeX.Core/Legality/Tables/Tables7b.cs b/PKHeX.Core/Legality/Tables/Tables7b.cs index 9260e7e1c..d9f68bc7c 100644 --- a/PKHeX.Core/Legality/Tables/Tables7b.cs +++ b/PKHeX.Core/Legality/Tables/Tables7b.cs @@ -12,118 +12,7 @@ public static partial class Legal internal const int MaxAbilityID_7b = MaxAbilityID_7_USUM; internal static readonly ushort[] HeldItems_GG = Array.Empty(); public const byte AwakeningMax = 200; - - #region Items - - internal static readonly ushort[] Pouch_Candy_GG_Regular = - { - 050, // Rare Candy - 960, 961, 962, 963, 964, 965, // S - 966, 967, 968, 969, 970, 971, // L - 972, 973, 974, 975, 976, 977, // XL - }; - - internal static readonly ushort[] Pouch_Candy_GG_Species = - { - 978, 979, - 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, - 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, - 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, - 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, - 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, - 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, - 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, - 1050, 1051, 1052, 1053, 1054, 1055, 1056, - 1057, - }; - - internal static readonly ushort[] Pouch_Candy_GG = ArrayUtil.ConcatAll(Pouch_Candy_GG_Regular, Pouch_Candy_GG_Species); - - internal static readonly ushort[] Pouch_Medicine_GG = - { - 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 038, 039, 040, 041, 709, 903, - }; - - internal static readonly ushort[] Pouch_TM_GG = - { - 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, - 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, - 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, - 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, - 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, - }; - - internal static readonly ushort[] Pouch_PowerUp_GG = - { - 051, 053, 081, 082, 083, 084, 085, - 849, - }; - - internal static readonly ushort[] Pouch_Catching_GG = - { - 001, 002, 003, 004, 012, 164, 166, 168, - 861, 862, 863, 864, 865, 866, - }; - - internal static readonly ushort[] Pouch_Battle_GG = - { - 055, 056, 057, 058, 059, 060, 061, 062, - 656, 659, 660, 661, 662, 663, 671, 672, 675, 676, 678, 679, - 760, 762, 770, 773, - }; - - internal static readonly ushort[] Pouch_Regular_GG = - { - 076, 077, 078, 079, 086, 087, 088, 089, - 090, 091, 092, 093, 101, 102, 103, 113, 115, - 121, 122, 123, 124, 125, 126, 127, 128, - 442, - 571, - 632, 651, - 795, 796, - 872, 873, 874, 875, 876, 877, 878, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 900, 901, 902, - }; - - internal static readonly ushort[] Pouch_Regular_GG_Key = - { - 113, // Tea - 115, // Autograph - 121, // Pokémon Box - 122, // Medicine Pocket - 123, // TM Case - 124, // Candy Jar - 125, // Power-Up Pocket - 126, // Clothing Trunk - 127, // Catching Pocket - 128, // Battle Pocket - 442, // Town Map - 632, // Shiny Charm - 651, // Poké Flute - - 872, // Secret Key - 873, // S.S. Ticket - 874, // Silph Scope - 875, // Parcel - 876, // Card Key - 877, // Gold Teeth - 878, // Lift Key - 885, // Stretchy Spring - 886, // Chalky Stone - 887, // Marble - 888, // Lone Earring - 889, // Beach Glass - 890, // Gold Leaf - 891, // Silver Leaf - 892, // Polished Mud Ball - 893, // Tropical Shell - 894, // Leaf Letter (P) - 895, // Leaf Letter (E) - 896, // Small Bouquet - }; - - #endregion - + #region Moves public static bool IsAllowedMoveGG(ushort move) => AllowedMovesGG.BinarySearch(move) >= 0; diff --git a/PKHeX.Core/Legality/Tables/Tables8.cs b/PKHeX.Core/Legality/Tables/Tables8.cs index 8c11dcef2..87b300f40 100644 --- a/PKHeX.Core/Legality/Tables/Tables8.cs +++ b/PKHeX.Core/Legality/Tables/Tables8.cs @@ -31,142 +31,7 @@ public static partial class Legal internal const int MaxBallID_8 = 0x1A; // 26 Beast internal const int MaxGameID_8 = 45; // Shield - internal static readonly ushort[] Pouch_Regular_SWSH = - { - 045, 046, 047, 048, 049, 050, 051, 052, 053, 076, 077, 079, 080, 081, 082, 083, 084, 085, 107, 108, 109, - 110, 112, 116, 117, 118, 119, 135, 136, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 228, - 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, - 250, 251, 252, 253, 254, 255, 257, 258, 259, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, - 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, - 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, - 319, 320, 321, 322, 323, 324, 325, 326, 485, 486, 487, 488, 489, 490, 491, 537, 538, 539, 540, 541, 542, - 543, 544, 545, 546, 547, 564, 565, 566, 567, 568, 569, 570, 639, 640, 644, 645, 646, 647, 648, 649, 650, - 846, 849, 879, 880, 881, 882, 883, 884, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, - 917, 918, 919, 920, 1103, 1104, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, - 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, - 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, - - 1279, - 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, - 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, - 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, - 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, - 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, - 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, - 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, - 1406, 1407, 1408, 1409, 1410, 1411, 1412, 1413, 1414, 1415, 1416, 1417, 1418, 1419, 1420, 1421, 1422, 1423, - 1424, 1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, - 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, - 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, - 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, - 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, - 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, - 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, - 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, - 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1581, 1582, 1588, - - // DLC 2 - 1592, 1604, 1606, - }; - - internal static readonly ushort[] Pouch_Ball_SWSH = - { - 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, - 492, 493, 494, 495, 496, 497, 498, 499, 500, - 576, - 851, - }; - - internal static readonly ushort[] Pouch_Battle_SWSH = - { - 055, 056, 057, 058, 059, 060, 061, 062, 063, 1580, - }; - - internal static readonly ushort[] Pouch_Items_SWSH = ArrayUtil.ConcatAll(Pouch_Regular_SWSH, Pouch_Ball_SWSH, Pouch_Battle_SWSH); - - internal static readonly ushort[] Pouch_Key_SWSH = - { - 078, - 628, 629, 631, 632, 638, - 703, - 847, - 943, 944, 945, 946, - 1074, 1075, 1076, 1077, 1080, 1081, 1100, 1255, 1266, 1267, - 1269, 1270, 1271, 1278, 1583, 1584, 1585, 1586, 1587, 1589, - - // DLC 2 - 1590, 1591, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1605, 1607, - }; - - internal static readonly ushort[] Pouch_TM_SWSH = - { - 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, - 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, - 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, - 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, - 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, - 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, - 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, - 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, - 418, 419, 618, 619, 620, 690, 691, 692, 693, // TM99 - 1230, // TM00 - }; - - internal static readonly ushort[] Pouch_TR_SWSH = - { - 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, - 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, - 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, - 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, - 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, - 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, - 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, - 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, - 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, - 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, - }; - - internal static readonly ushort[] Pouch_TMHM_SWSH = ArrayUtil.ConcatAll(Pouch_TM_SWSH, Pouch_TR_SWSH); - - internal static readonly ushort[] Pouch_Medicine_SWSH = - { - 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, - 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, - 037, 038, 039, 040, 041, 042, 043, 054, - 134, - 504, 591, - 708, 709, - 852, 903, - 1579, - }; - - internal static readonly ushort[] Pouch_Berries_SWSH = - { - 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, - 159, 160, 161, 162, 163, 169, 170, 171, 172, 173, - 174, 184, 185, 186, 187, 188, 189, 190, 191, 192, - 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, - 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - 686, 687, 688, - }; - - internal static readonly ushort[] Pouch_Ingredients_SWSH = - { - 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, - 1094, 1095, 1096, 1097, 1098, 1099, 1256, 1257, 1258, 1259, - 1260, 1261, 1262, 1263, 1264, - }; - - internal static readonly ushort[] Pouch_Treasure_SWSH = - { - 086, 087, 088, 089, 090, 091, 092, 094, 106, - 571, 580, 581, 582, 583, - 795, 796, - 1105, 1106, 1107, 1108, - }; - - internal static readonly ushort[] HeldItems_SWSH = ArrayUtil.ConcatAll(Pouch_Items_SWSH, Pouch_Berries_SWSH, Pouch_Medicine_SWSH, Pouch_TR_SWSH, Pouch_Treasure_SWSH, Pouch_Ingredients_SWSH); + internal static readonly ushort[] HeldItems_SWSH = ItemStorage8SWSH.GetAllHeld(); internal static readonly HashSet GalarOriginForms = new() { @@ -230,329 +95,6 @@ public static partial class Legal public static bool IsDynamaxCrystal(ushort item) => item is >= DMAX_START and <= DMAX_END; public static bool IsDynamaxCrystalAvailable(ushort item) => item is >= DMAX_START and <= DMAX_LEGAL_END; - internal static readonly bool[] ReleasedHeldItems_8 = GetPermitList(MaxItemID_8, HeldItems_SWSH, stackalloc ushort[] - { - 016, // Cherish Ball - 298, // Flame Plate - 299, // Splash Plate - 300, // Zap Plate - 301, // Meadow Plate - 302, // Icicle Plate - 303, // Fist Plate - 304, // Toxic Plate - 305, // Earth Plate - 306, // Sky Plate - 307, // Mind Plate - 308, // Insect Plate - 309, // Stone Plate - 310, // Spooky Plate - 311, // Draco Plate - 312, // Dread Plate - 313, // Iron Plate - - 500, // Park Ball - // 644, // Pixie Plate - - 1279, // ★And458 (Jangmo-o) - 1280, // ★And15 (Larvitar) - 1281, // ★And337 (Corviknight) - 1282, // ★And603 (Eiscue) - 1283, // ★And390 (Stonjourner) - 1284, // ★Sgr6879 (Copperajah) - 1285, // ★Sgr6859 (Centiskorch) - 1286, // ★Sgr6913 (Flapple/Appletun) - 1287, // ★Sgr7348 (Sandaconda) - 1288, // ★Sgr7121 (Duraludon) - 1289, // ★Sgr6746 (Pikachu) - 1290, // ★Sgr7194 (Eevee) - 1291, // ★Sgr7337 - 1292, // ★Sgr7343 - 1293, // ★Sgr6812 - 1294, // ★Sgr7116 - 1295, // ★Sgr7264 - 1296, // ★Sgr7597 - 1297, // ★Del7882 - 1298, // ★Del7906 - 1299, // ★Del7852 - 1300, // ★Psc596 - 1301, // ★Psc361 - 1302, // ★Psc510 - 1303, // ★Psc437 - 1304, // ★Psc8773 - 1305, // ★Lep1865 - 1306, // ★Lep1829 - 1307, // ★Boo5340 - 1308, // ★Boo5506 - 1309, // ★Boo5435 - 1310, // ★Boo5602 - 1311, // ★Boo5733 - 1312, // ★Boo5235 - 1313, // ★Boo5351 - 1314, // ★Hya3748 - 1315, // ★Hya3903 - 1316, // ★Hya3418 - 1317, // ★Hya3482 - 1318, // ★Hya3845 - 1319, // ★Eri1084 - 1320, // ★Eri472 - 1321, // ★Eri1666 - 1322, // ★Eri897 - 1323, // ★Eri1231 - 1324, // ★Eri874 - 1325, // ★Eri1298 - 1326, // ★Eri1325 - 1327, // ★Eri984 - 1328, // ★Eri1464 - 1329, // ★Eri1393 - 1330, // ★Eri850 - 1331, // ★Tau1409 - 1332, // ★Tau1457 - 1333, // ★Tau1165 - 1334, // ★Tau1791 - 1335, // ★Tau1910 - 1336, // ★Tau1346 - 1337, // ★Tau1373 - 1338, // ★Tau1412 - 1339, // ★CMa2491 - 1340, // ★CMa2693 - 1341, // ★CMa2294 - 1342, // ★CMa2827 - 1343, // ★CMa2282 - 1344, // ★CMa2618 - 1345, // ★CMa2657 - 1346, // ★CMa2646 - 1347, // ★UMa4905 - 1348, // ★UMa4301 - 1349, // ★UMa5191 - 1350, // ★UMa5054 - 1351, // ★UMa4295 - 1352, // ★UMa4660 - 1353, // ★UMa4554 - 1354, // ★UMa4069 - 1355, // ★UMa3569 - 1356, // ★UMa3323 - 1357, // ★UMa4033 - 1358, // ★UMa4377 - 1359, // ★UMa4375 - 1360, // ★UMa4518 - 1361, // ★UMa3594 - 1362, // ★Vir5056 - 1363, // ★Vir4825 - 1364, // ★Vir4932 - 1365, // ★Vir4540 - 1366, // ★Vir4689 - 1367, // ★Vir5338 - 1368, // ★Vir4910 - 1369, // ★Vir5315 - 1370, // ★Vir5359 - 1371, // ★Vir5409 - 1372, // ★Vir5107 - 1373, // ★Ari617 - 1374, // ★Ari553 - 1375, // ★Ari546 - 1376, // ★Ari951 - 1377, // ★Ori1713 - 1378, // ★Ori2061 - 1379, // ★Ori1790 - 1380, // ★Ori1903 - 1381, // ★Ori1948 - 1382, // ★Ori2004 - 1383, // ★Ori1852 - 1384, // ★Ori1879 - 1385, // ★Ori1899 - 1386, // ★Ori1543 - 1387, // ★Cas21 - 1388, // ★Cas168 - 1389, // ★Cas403 - 1390, // ★Cas153 - 1391, // ★Cas542 - 1392, // ★Cas219 - 1393, // ★Cas265 - 1394, // ★Cnc3572 - 1395, // ★Cnc3208 - 1396, // ★Cnc3461 - 1397, // ★Cnc3449 - 1398, // ★Cnc3429 - 1399, // ★Cnc3627 - 1400, // ★Cnc3268 - 1401, // ★Cnc3249 - 1402, // ★Com4968 - 1403, // ★Crv4757 - 1404, // ★Crv4623 - 1405, // ★Crv4662 - 1406, // ★Crv4786 - 1407, // ★Aur1708 - 1408, // ★Aur2088 - 1409, // ★Aur1605 - 1410, // ★Aur2095 - 1411, // ★Aur1577 - 1412, // ★Aur1641 - 1413, // ★Aur1612 - 1414, // ★Pav7790 - 1415, // ★Cet911 - 1416, // ★Cet681 - 1417, // ★Cet188 - 1418, // ★Cet539 - 1419, // ★Cet804 - 1420, // ★Cep8974 - 1421, // ★Cep8162 - 1422, // ★Cep8238 - 1423, // ★Cep8417 - 1424, // ★Cen5267 - 1425, // ★Cen5288 - 1426, // ★Cen551 - 1427, // ★Cen5459 - 1428, // ★Cen5460 - 1429, // ★CMi2943 - 1430, // ★CMi2845 - 1431, // ★Equ8131 - 1432, // ★Vul7405 - 1433, // ★UMi424 - 1434, // ★UMi5563 - 1435, // ★UMi5735 - 1436, // ★UMi6789 - 1437, // ★Crt4287 - 1438, // ★Lyr7001 - 1439, // ★Lyr7178 - 1440, // ★Lyr7106 - 1441, // ★Lyr7298 - 1442, // ★Ara6585 - 1443, // ★Sco6134 - 1444, // ★Sco6527 - 1445, // ★Sco6553 - 1446, // ★Sco5953 - 1447, // ★Sco5984 - 1448, // ★Sco6508 - 1449, // ★Sco6084 - 1450, // ★Sco5944 - 1451, // ★Sco6630 - 1452, // ★Sco6027 - 1453, // ★Sco6247 - 1454, // ★Sco6252 - 1455, // ★Sco5928 - 1456, // ★Sco6241 - 1457, // ★Sco6165 - 1458, // ★Tri544 - 1459, // ★Leo3982 - 1460, // ★Leo4534 - 1461, // ★Leo4357 - 1462, // ★Leo4057 - 1463, // ★Leo4359 - 1464, // ★Leo4031 - 1465, // ★Leo3852 - 1466, // ★Leo3905 - 1467, // ★Leo3773 - 1468, // ★Gru8425 - 1469, // ★Gru8636 - 1470, // ★Gru8353 - 1471, // ★Lib5685 - 1472, // ★Lib5531 - 1473, // ★Lib5787 - 1474, // ★Lib5603 - 1475, // ★Pup3165 - 1476, // ★Pup3185 - 1477, // ★Pup3045 - 1478, // ★Cyg7924 - 1479, // ★Cyg7417 - 1480, // ★Cyg7796 - 1481, // ★Cyg8301 - 1482, // ★Cyg7949 - 1483, // ★Cyg7528 - 1484, // ★Oct7228 - 1485, // ★Col1956 - 1486, // ★Col2040 - 1487, // ★Col2177 - 1488, // ★Gem2990 - 1489, // ★Gem2891 - 1490, // ★Gem2421 - 1491, // ★Gem2473 - 1492, // ★Gem2216 - 1493, // ★Gem2777 - 1494, // ★Gem2650 - 1495, // ★Gem2286 - 1496, // ★Gem2484 - 1497, // ★Gem2930 - 1498, // ★Peg8775 - 1499, // ★Peg8781 - 1500, // ★Peg39 - 1501, // ★Peg8308 - 1502, // ★Peg8650 - 1503, // ★Peg8634 - 1504, // ★Peg8684 - 1505, // ★Peg8450 - 1506, // ★Peg8880 - 1507, // ★Peg8905 - 1508, // ★Oph6556 - 1509, // ★Oph6378 - 1510, // ★Oph6603 - 1511, // ★Oph6149 - 1512, // ★Oph6056 - 1513, // ★Oph6075 - 1514, // ★Ser5854 - 1515, // ★Ser7141 - 1516, // ★Ser5879 - 1517, // ★Her6406 - 1518, // ★Her6148 - 1519, // ★Her6410 - 1520, // ★Her6526 - 1521, // ★Her6117 - 1522, // ★Her6008 - 1523, // ★Per936 - 1524, // ★Per1017 - 1525, // ★Per1131 - 1526, // ★Per1228 - 1527, // ★Per834 - 1528, // ★Per941 - 1529, // ★Phe99 - 1530, // ★Phe338 - 1531, // ★Vel3634 - 1532, // ★Vel3485 - 1533, // ★Vel3734 - 1534, // ★Aqr8232 - 1535, // ★Aqr8414 - 1536, // ★Aqr8709 - 1537, // ★Aqr8518 - 1538, // ★Aqr7950 - 1539, // ★Aqr8499 - 1540, // ★Aqr8610 - 1541, // ★Aqr8264 - 1542, // ★Cru4853 - 1543, // ★Cru4730 - 1544, // ★Cru4763 - 1545, // ★Cru4700 - 1546, // ★Cru4656 - 1547, // ★PsA8728 - 1548, // ★TrA6217 - 1549, // ★Cap7776 - 1550, // ★Cap7754 - 1551, // ★Cap8278 - 1552, // ★Cap8322 - 1553, // ★Cap7773 - 1554, // ★Sge7479 - 1555, // ★Car2326 - 1556, // ★Car3685 - 1557, // ★Car3307 - 1558, // ★Car3699 - 1559, // ★Dra5744 - 1560, // ★Dra5291 - 1561, // ★Dra6705 - 1562, // ★Dra6536 - 1563, // ★Dra7310 - 1564, // ★Dra6688 - 1565, // ★Dra4434 - 1566, // ★Dra6370 - 1567, // ★Dra7462 - 1568, // ★Dra6396 - 1569, // ★Dra6132 - 1570, // ★Dra6636 - 1571, // ★CVn4915 - 1572, // ★CVn4785 - 1573, // ★CVn4846 - 1574, // ★Aql7595 - 1575, // ★Aql7557 - 1576, // ★Aql7525 - 1577, // ★Aql7602 - 1578, // ★Aql7235 - }); + internal static readonly bool[] ReleasedHeldItems_8 = GetPermitList(MaxItemID_8, HeldItems_SWSH, ItemStorage8SWSH.Unreleased); #endregion } diff --git a/PKHeX.Core/Legality/Tables/Tables8a.cs b/PKHeX.Core/Legality/Tables/Tables8a.cs index b9f608744..0fabb4257 100644 --- a/PKHeX.Core/Legality/Tables/Tables8a.cs +++ b/PKHeX.Core/Legality/Tables/Tables8a.cs @@ -12,60 +12,4 @@ public static partial class Legal internal const int MaxAbilityID_8a = MaxAbilityID_8_R2; internal static readonly ushort[] HeldItems_LA = Array.Empty(); - - internal static readonly ushort[] Pouch_Items_LA = - { - 017, 023, 024, 025, 026, 027, 028, 029, 039, 041, - 050, 054, 072, 073, 075, 080, 081, 082, 083, 084, - 085, 090, 091, 092, 107, 108, 109, 110, 149, 150, - 151, 152, 153, 154, 155, 157, 158, 159, 160, 161, - 162, 163, 164, 166, 168, 233, 252, 321, 322, 323, - 324, 325, 326, 327, 583, 849, - - 1125, 1126, 1127, 1128, 1231, 1232, 1233, 1234, 1235, 1236, - 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, - 1247, 1248, 1249, 1250, 1251, - - 1611, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, - 1628, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, - 1651, 1679, 1681, 1682, 1684, 1686, 1687, 1688, 1689, 1690, - 1691, 1692, 1693, 1694, 1695, 1696, 1699, 1700, 1701, 1702, - 1703, 1704, 1705, 1706, 1707, 1708, 1709, 1710, 1711, 1712, - 1713, 1716, 1717, 1720, 1724, 1725, 1726, 1727, 1728, 1732, - 1733, 1734, 1735, 1736, 1738, 1739, 1740, 1741, 1742, 1746, - 1747, 1748, 1749, 1750, 1754, 1755, 1756, 1757, 1758, 1759, - 1760, 1761, 1762, 1764, 1785, - }; - - internal static readonly ushort[] Pouch_Recipe_LA = - { - 1640, 1641, 1642, 1643, 1644, 1646, 1647, 1648, 1649, - 1650, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, - 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669, - 1670, 1671, 1673, 1674, 1675, 1676, 1677, - - 1729, - 1730, 1731, - - 1751, 1752, 1753, - - 1783, 1784, - }; - - internal static readonly ushort[] Pouch_Key_LA = - { - 111, - 298, 299, - 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, - 310, 311, 312, 313, - 441, 455, 466, - 632, 638, 644, - 1608, 1609, 1610, 1612, 1622, 1624, 1625, 1626, 1627, 1629, - 1639, 1678, 1721, 1722, 1723, 1737, 1743, 1744, 1745, 1763, - 1765, 1766, 1767, 1768, 1769, 1771, 1776, 1777, 1778, 1779, - 1780, 1782, 1786, 1787, 1788, 1789, 1790, 1792, 1793, 1794, - 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, - 1805, 1806, 1807, - 1828, - }; } diff --git a/PKHeX.Core/Legality/Tables/Tables8bs.cs b/PKHeX.Core/Legality/Tables/Tables8bs.cs index d7d4a82e7..2e896d0e4 100644 --- a/PKHeX.Core/Legality/Tables/Tables8bs.cs +++ b/PKHeX.Core/Legality/Tables/Tables8bs.cs @@ -11,125 +11,10 @@ public static partial class Legal internal const int MaxGameID_8b = (int)GameVersion.SP; internal const int MaxAbilityID_8b = MaxAbilityID_8_R2; - internal static readonly ushort[] Pouch_Regular_BS = - { - 045, 046, 047, 048, 049, 050, 051, 052, 053, 072, 073, 074, 075, 076, 077, 078, - 079, 080, 081, 082, 083, 084, 085, 093, 094, 107, 108, 109, 110, 111, 112, 135, - 136, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, - 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, - 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, - 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, - 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, - 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, - 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, - 325, 326, 327, 537, 565, 566, 567, 568, 569, 570, 644, 645, 849, - - 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, - 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1606, - }; - - internal static readonly ushort[] Pouch_Ball_BS = - { - 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, - 492, 493, 494, 495, 496, 497, 498, 499, 500, - 576, - 851, - }; - - internal static readonly ushort[] Pouch_Battle_BS = - { - 055, 056, 057, 058, 059, 060, 061, 062, 063, - }; - - internal static readonly ushort[] Pouch_Items_BS = ArrayUtil.ConcatAll(Pouch_Regular_BS, Pouch_Ball_BS, Pouch_Battle_BS); - - internal static readonly ushort[] Pouch_Key_BS = - { - 428, 431, 432, 433, 438, 439, 440, 443, 445, 446, 447, 448, 449, 450, 451, 452, - 453, 454, 455, 459, 460, 461, 462, 463, 464, 466, 467, 631, 632, - - 1267, 1278, 1822, - }; - - internal static readonly ushort[] Pouch_Medicine_BS = - { - 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, - 038, 039, 040, 041, 042, 043, 044, 054, - - // 134 Sweet Heart (future event item?) - }; - - internal static readonly ushort[] Pouch_Berries_BS = - { - 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, - 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, - 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, - 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, - 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, - 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, - 209, 210, 211, 212, 686, - }; - - internal static readonly ushort[] Pouch_Treasure_BS = - { - 086, 087, 088, 089, 090, 091, 092, 099, 100, 101, 102, 103, 104, 105, 106, 795, 796, - - 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, - }; - - internal static readonly ushort[] Pouch_TMHM_BS = // TM01-TM100 - { - 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, - 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, - 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, - 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, - 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, - 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, - 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, - 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, - 418, 419, - 420, 421, 422, 423, 424, 425, 426, 427, // Previously called HM0X, in BDSP they're now called TM93-TM100 - }; - - internal static readonly ushort[] HeldItems_BS = ArrayUtil.ConcatAll(Pouch_Items_BS, Pouch_Berries_BS, Pouch_TMHM_BS, Pouch_Medicine_BS, Pouch_Treasure_BS); + internal static readonly ushort[] HeldItems_BS = ItemStorage8BDSP.GetAll(); #region Unreleased Items - internal static readonly bool[] ReleasedHeldItems_8b = GetPermitList(MaxItemID_8b, HeldItems_BS, stackalloc ushort[] - { - 044, // Sacred Ash - 537, // Prism Scale - 565, // Health Feather - 566, // Muscle Feather - 567, // Resist Feather - 568, // Genius Feather - 569, // Clever Feather - 570, // Swift Feather - 849, // Ice Stone - - 005, // Safari Ball - 016, // Cherish Ball - 499, // Sport Ball - 500, // Park Ball - 576, // Dream Ball - 851, // Beast Ball - - // new BDSP items, but they can't be held - 1808, // Mysterious Shard S - 1809, // Mysterious Shard L - 1810, // Digger Drill - 1811, // Kanto Slate - 1812, // Johto Slate - 1813, // Soul Slate - 1814, // Rainbow Slate - 1815, // Squall Slate - 1816, // Oceanic Slate - 1817, // Tectonic Slate - 1818, // Stratospheric Slate - 1819, // Genome Slate - 1820, // Discovery Slate - 1821, // Distortion Slate - }); + internal static readonly bool[] ReleasedHeldItems_8b = GetPermitList(MaxItemID_8b, HeldItems_BS, ItemStorage8BDSP.Unreleased); #endregion private const int MaxValidHatchLocation8b = 657; diff --git a/PKHeX.Core/Legality/Tables/Tables9.cs b/PKHeX.Core/Legality/Tables/Tables9.cs index e3ad0b324..9d9aa1b95 100644 --- a/PKHeX.Core/Legality/Tables/Tables9.cs +++ b/PKHeX.Core/Legality/Tables/Tables9.cs @@ -12,153 +12,7 @@ public static partial class Legal internal const int MaxBallID_9 = (int)Ball.LAOrigin; internal const int MaxGameID_9 = (int)GameVersion.VL; - internal static readonly ushort[] Pouch_Medicine_SV = - { - 0017, 0018, 0019, 0020, 0021, 0022, 0023, 0024, 0025, 0026, - 0027, 0028, 0029, 0030, 0031, 0032, 0033, 0034, 0035, 0036, - 0037, 0038, 0039, 0040, 0041, 0708, 0709, - }; - - internal static readonly ushort[] Pouch_Ball_SV = - { - 0001, 0002, 0003, 0004, 0005, 0006, 0007, 0008, 0009, 0010, - 0011, 0012, 0013, 0014, 0015, 0016, 0492, 0493, 0494, 0495, - 0496, 0497, 0498, 0499, 0500, 0576, 0851, 1785, - }; - - internal static readonly ushort[] Pouch_Battle_SV = - { - 0055, 0056, 0057, 0058, 0059, 0060, 0061, 0062, 0063, - }; - - internal static readonly ushort[] Pouch_Berries_SV = - { - 0149, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0158, - 0159, 0160, 0161, 0162, 0163, 0169, 0170, 0171, 0172, 0173, - 0174, 0184, 0185, 0186, 0187, 0188, 0189, 0190, 0191, 0192, - 0193, 0194, 0195, 0196, 0197, 0198, 0199, 0200, 0201, 0202, - 0203, 0204, 0205, 0206, 0207, 0208, 0209, 0210, 0211, 0212, - 0686, 0687, 0688, - }; - - internal static readonly ushort[] Pouch_Other_SV = - { - 0045, 0046, 0047, 0048, 0049, 0050, 0051, 0052, 0053, 0080, - 0081, 0082, 0083, 0084, 0085, 0107, 0108, 0109, 0110, 0111, - 0112, 0135, 0136, 0213, 0214, 0217, 0218, 0219, 0220, 0221, - 0222, 0223, 0224, 0228, 0229, 0230, 0231, 0232, 0233, 0234, - 0236, 0237, 0238, 0239, 0240, 0241, 0242, 0243, 0244, 0245, - 0246, 0247, 0248, 0249, 0250, 0251, 0253, 0265, 0266, 0267, - 0268, 0269, 0270, 0271, 0272, 0273, 0275, 0276, 0277, 0278, - 0279, 0280, 0281, 0282, 0283, 0284, 0285, 0286, 0287, 0288, - 0289, 0290, 0291, 0292, 0293, 0294, 0295, 0296, 0297, 0298, - 0299, 0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, 0308, - 0309, 0310, 0311, 0312, 0313, 0326, 0485, 0486, 0487, 0488, - 0489, 0490, 0491, 0538, 0539, 0540, 0541, 0542, 0543, 0544, - 0545, 0546, 0547, 0564, 0565, 0566, 0567, 0568, 0569, 0570, - 0639, 0640, 0644, 0645, 0648, 0649, 0650, 0795, 0796, 0846, - 0849, 0853, 0854, 0855, 0856, 0879, 0880, 0881, 0882, 0883, - 0884, 1103, 1104, 1116, 1117, 1118, 1119, 1120, 1121, 1122, - 1123, 1124, 1125, 1126, 1127, 1128, 1231, 1232, 1233, 1234, - 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, - 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1253, 1254, 1582, - 1592, 1606, 1777, 1778, 1779, 1861, 1862, 1863, 1864, 1865, - 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, - 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, - 1886, 2344, 2345, - }; - - internal static readonly ushort[] Pouch_TM_SV = - { - 0328, 0329, 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, - 0338, 0339, 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, - 0348, 0349, 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, - 0358, 0359, 0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367, - 0368, 0369, 0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377, - 0378, 0379, 0380, 0381, 0382, 0383, 0384, 0385, 0386, 0387, - 0388, 0389, 0390, 0391, 0392, 0393, 0394, 0395, 0396, 0397, - 0398, 0399, 0400, 0401, 0402, 0403, 0404, 0405, 0406, 0407, - 0408, 0409, 0410, 0411, 0412, 0413, 0414, 0415, 0416, 0417, - 0418, 0419, 0618, 0619, 0620, 0690, 0691, 0692, 0693, 1230, - 2160, 2161, 2162, 2163, 2164, 2165, 2166, 2167, 2168, 2169, - 2170, 2171, 2172, 2173, 2174, 2175, 2176, 2177, 2178, 2179, - 2180, 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189, - 2190, 2191, 2192, 2193, 2194, 2195, 2196, 2197, 2198, 2199, - 2200, 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, - 2210, 2211, 2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219, - 2220, 2221, 2222, 2223, 2224, 2225, 2226, 2227, 2228, 2229, - 2230, 2231, - }; - - internal static readonly ushort[] Pouch_Treasure_SV = - { - 0086, 0087, 0088, 0089, 0090, 0091, 0092, 0094, 0106, 0571, - 0580, 0581, 0582, 0583, 1842, 1843, - }; - - internal static readonly ushort[] Pouch_Picnic_SV = - { - 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, - 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, - 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, - 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, - 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, - 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, - 2311, 2313, - 2314, 2315, 2316, 2317, 2318, 2319, 2320, 2321, 2322, 2323, - 2324, 2325, 2326, 2327, 2329, 2330, 2331, 2332, 2333, 2334, - 2335, 2336, 2337, 2338, 2339, 2340, 2341, 2342, 2348, 2349, - 2350, 2351, 2352, 2353, 2354, 2355, 2356, 2357, 2358, 2359, - 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369, - 2370, 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, - 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, - 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, - 2400, - - // Item data is present, but the items have no associated text or sprites, so they do not appear in the bag. - // 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, - }; - - internal static readonly ushort[] Pouch_Event_SV = - { - 0632, 0638, 0703, 0765, 1278, 1590, 1591, 1829, 1830, 1831, - 1832, 1833, 1834, 1835, 1836, 1857, 1858, - - // Item data is present, but the items have no associated text or sprites, so they do not appear in the bag. - // 0078, 0466, 0631, 1267, 1587, 1589, 1837, 1838, 1839, 1840, 1841, - }; - - internal static readonly ushort[] Pouch_Material_SV = - { - 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, - 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, - 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, - 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, - 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, - 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, - 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, - 2036, 2037, 2038, 2039, 2040, 2041, 2042, 2043, 2044, 2045, - 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, - 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2064, 2065, - 2066, 2067, 2068, 2069, 2070, 2071, 2072, 2073, 2074, 2075, - 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085, - 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, - 2096, 2097, 2098, 2099, 2103, 2104, 2105, - 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, - 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2126, 2127, - 2128, 2129, 2130, 2131, 2132, 2133, 2134, 2135, 2136, 2137, - - 2156, 2157, - 2158, 2159, - - // Item data is present, but the items have no associated text or sprites, so they do not appear in the bag. - // 2100, 2101, 2102, - // 2138, 2139, 2140, 2141, 2142, 2143, 2144, 2145, 2146, 2147, - // 2148, 2149, 2150, 2151, 2152, 2153, 2154, 2155, - }; - - internal static readonly ushort[] HeldItems_SV = ArrayUtil.ConcatAll(Pouch_Medicine_SV, Pouch_Ball_SV, Pouch_Battle_SV, Pouch_Berries_SV, Pouch_Other_SV, Pouch_TM_SV, Pouch_Treasure_SV); + internal static readonly ushort[] HeldItems_SV = ItemStorage9SV.GetAllHeld(); internal static readonly HashSet ValidMet_SV = new() { @@ -191,62 +45,6 @@ public static bool IsValidEggHatchLocation9(ushort location, GameVersion version #region Unreleased Items - internal static readonly bool[] ReleasedHeldItems_9 = GetPermitList(MaxItemID_9, HeldItems_SV, stackalloc ushort[] - { - 0005, // Safari Ball - 0016, // Cherish Ball - 0499, // Sport Ball - 0500, // Park Ball - 1785, // Strange Ball - - 0208, // Enigma Berry - 0209, // Micle Berry - 0210, // Custap Berry - 0211, // Jaboca Berry - 0212, // Rowap Berry - - 0111, // Odd Keystone - 0485, // Red Apricorn - 0486, // Blue Apricorn - 0487, // Yellow Apricorn - 0488, // Green Apricorn - 0489, // Pink Apricorn - 0490, // White Apricorn - 0491, // Black Apricorn - 0708, // Lumiose Galette - 0709, // Shalour Sable - - // Porto Marinada specialty auctioneer, locked behind HOME in 2023. - 0112, // Griseous Orb - 0135, // Adamant Orb - 0136, // Lustrous Orb - 0298, // Flame Plate - 0299, // Splash Plate - 0300, // Zap Plate - 0301, // Meadow Plate - 0302, // Icicle Plate - 0303, // Fist Plate - 0304, // Toxic Plate - 0305, // Earth Plate - 0306, // Sky Plate - 0307, // Mind Plate - 0308, // Insect Plate - 0309, // Stone Plate - 0310, // Spooky Plate - 0311, // Draco Plate - 0312, // Dread Plate - 0313, // Iron Plate - 0644, // Pixie Plate - 1103, // Rusted Sword - 1104, // Rusted Shield - 1777, // Adamant Crystal - 1778, // Lustrous Globe - 1779, // Griseous Core - - 1582, // Galarica Cuff - 1592, // Galarica Wreath - - 1230, // TM00 - Mega Punch (Nothing learns, not obtainable even though it is assigned a move.) - }); + internal static readonly bool[] ReleasedHeldItems_9 = GetPermitList(MaxItemID_9, HeldItems_SV, ItemStorage9SV.Unreleased); #endregion } diff --git a/PKHeX.Core/PKM/Util/Conversion/ItemConverter.cs b/PKHeX.Core/PKM/Util/Conversion/ItemConverter.cs index 7145833ee..4e256727c 100644 --- a/PKHeX.Core/PKM/Util/Conversion/ItemConverter.cs +++ b/PKHeX.Core/PKM/Util/Conversion/ItemConverter.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; namespace PKHeX.Core; @@ -161,7 +160,7 @@ internal static int GetItemFuture1(byte value) return value; } - private static bool IsItemTransferable12(ushort item) => ((IList) Legal.HeldItems_GSC).Contains(item); + private static bool IsItemTransferable12(ushort item) => Legal.HeldItems_GSC.AsSpan().Contains(item); /// /// Gets a format specific value depending on the desired format and the provided item index & origin format. diff --git a/PKHeX.Core/Saves/SAV1.cs b/PKHeX.Core/Saves/SAV1.cs index 63fa9484e..edb94860b 100644 --- a/PKHeX.Core/Saves/SAV1.cs +++ b/PKHeX.Core/Saves/SAV1.cs @@ -412,11 +412,10 @@ public override IReadOnlyList Inventory { get { - ushort[] legalItems = Legal.Pouch_Items_RBY; InventoryPouch[] pouch = { - new InventoryPouchGB(InventoryType.Items, legalItems, 99, Offsets.Items, 20), - new InventoryPouchGB(InventoryType.PCItems, legalItems, 99, Offsets.PCItems, 50), + new InventoryPouchGB(InventoryType.Items, ItemStorage1.Instance, 99, Offsets.Items, 20), + new InventoryPouchGB(InventoryType.PCItems, ItemStorage1.Instance, 99, Offsets.PCItems, 50), }; return pouch.LoadAll(Data); } diff --git a/PKHeX.Core/Saves/SAV2.cs b/PKHeX.Core/Saves/SAV2.cs index bd14ffad2..80c6756f7 100644 --- a/PKHeX.Core/Saves/SAV2.cs +++ b/PKHeX.Core/Saves/SAV2.cs @@ -501,22 +501,18 @@ public byte BlueCardPoints } } - private static ushort[] LegalItems => Legal.Pouch_Items_GSC; - private ushort[] LegalKeyItems => Version == GameVersion.C? Legal.Pouch_Key_C : Legal.Pouch_Key_GS; - private static ushort[] LegalBalls => Legal.Pouch_Ball_GSC; - private static ushort[] LegalTMHMs => Legal.Pouch_TMHM_GSC; - public override IReadOnlyList Inventory { get { + var info = Version == GameVersion.C ? ItemStorage2.InstanceC : ItemStorage2.InstanceGS; InventoryPouch[] pouch = { - new InventoryPouchGB(InventoryType.TMHMs, LegalTMHMs, 99, Offsets.PouchTMHM, 57), - new InventoryPouchGB(InventoryType.Items, LegalItems, 99, Offsets.PouchItem, 20), - new InventoryPouchGB(InventoryType.KeyItems, LegalKeyItems, 99, Offsets.PouchKey, 26), - new InventoryPouchGB(InventoryType.Balls, LegalBalls, 99, Offsets.PouchBall, 12), - new InventoryPouchGB(InventoryType.PCItems, ArrayUtil.ConcatAll(LegalItems, LegalKeyItems, LegalBalls, LegalTMHMs), 99, Offsets.PouchPC, 50), + new InventoryPouchGB(InventoryType.TMHMs, info, 99, Offsets.PouchTMHM, 57), + new InventoryPouchGB(InventoryType.Items, info, 99, Offsets.PouchItem, 20), + new InventoryPouchGB(InventoryType.KeyItems, info, 99, Offsets.PouchKey, 26), + new InventoryPouchGB(InventoryType.Balls, info, 99, Offsets.PouchBall, 12), + new InventoryPouchGB(InventoryType.PCItems, info, 99, Offsets.PouchPC, 50), }; return pouch.LoadAll(Data); } diff --git a/PKHeX.Core/Saves/SAV3Colosseum.cs b/PKHeX.Core/Saves/SAV3Colosseum.cs index 9724cd2e7..63ac2b16b 100644 --- a/PKHeX.Core/Saves/SAV3Colosseum.cs +++ b/PKHeX.Core/Saves/SAV3Colosseum.cs @@ -13,7 +13,7 @@ public sealed class SAV3Colosseum : SaveFile, IGCSaveFile protected internal override string ShortSummary => $"{OT} ({Version}) - {PlayTimeString}"; public override string Extension => this.GCExtension(); public override PersonalTable3 Personal => PersonalTable.RS; - public override ReadOnlySpan HeldItems => Legal.HeldItems_COLO; + public override ReadOnlySpan HeldItems => Legal.HeldItems_RS; public SAV3GCMemoryCard? MemoryCard { get; init; } // 3 Save files are stored @@ -383,14 +383,15 @@ public override IReadOnlyList Inventory { get { + var info = ItemStorage3Colo.Instance; InventoryPouch[] pouch = { - new InventoryPouch3GC(InventoryType.Items, Legal.Pouch_Items_COLO, 99, 0x007F8, 20), // 20 COLO, 30 XD - new InventoryPouch3GC(InventoryType.KeyItems, Legal.Pouch_Key_COLO, 1, 0x00848, 43), - new InventoryPouch3GC(InventoryType.Balls, Legal.Pouch_Ball_RS, 99, 0x008F4, 16), - new InventoryPouch3GC(InventoryType.TMHMs, Legal.Pouch_TM_RS, 99, 0x00934, 64), // no HMs - new InventoryPouch3GC(InventoryType.Berries, Legal.Pouch_Berries_RS, 999, 0x00A34, 46), - new InventoryPouch3GC(InventoryType.Medicine, Legal.Pouch_Cologne_COLO, 99, 0x00AEC, 3), // Cologne + new InventoryPouch3GC(InventoryType.Items, info, 99, 0x007F8, 20), // 20 COLO, 30 XD + new InventoryPouch3GC(InventoryType.KeyItems, info, 1, 0x00848, 43), + new InventoryPouch3GC(InventoryType.Balls, info, 99, 0x008F4, 16), + new InventoryPouch3GC(InventoryType.TMHMs, info, 99, 0x00934, 64), // no HMs + new InventoryPouch3GC(InventoryType.Berries, info, 999, 0x00A34, 46), + new InventoryPouch3GC(InventoryType.Medicine, info, 99, 0x00AEC, 3), // Cologne }; return pouch.LoadAll(Data); } diff --git a/PKHeX.Core/Saves/SAV3E.cs b/PKHeX.Core/Saves/SAV3E.cs index f374171b6..baaa0bd9e 100644 --- a/PKHeX.Core/Saves/SAV3E.cs +++ b/PKHeX.Core/Saves/SAV3E.cs @@ -131,15 +131,15 @@ public override uint Coin protected override InventoryPouch3[] GetItems() { const int max = 99; - var PCItems = ArrayUtil.ConcatAll(Legal.Pouch_Items_RS, Legal.Pouch_Key_E, Legal.Pouch_Ball_RS, Legal.Pouch_TMHM_RS, Legal.Pouch_Berries_RS); + var info = ItemStorage3E.Instance; return new InventoryPouch3[] { - new(InventoryType.Items, Legal.Pouch_Items_RS, max, OFS_PouchHeldItem, (OFS_PouchKeyItem - OFS_PouchHeldItem) / 4), - new(InventoryType.KeyItems, Legal.Pouch_Key_E, 1, OFS_PouchKeyItem, (OFS_PouchBalls - OFS_PouchKeyItem) / 4), - new(InventoryType.Balls, Legal.Pouch_Ball_RS, max, OFS_PouchBalls, (OFS_PouchTMHM - OFS_PouchBalls) / 4), - new(InventoryType.TMHMs, Legal.Pouch_TMHM_RS, max, OFS_PouchTMHM, (OFS_PouchBerry - OFS_PouchTMHM) / 4), - new(InventoryType.Berries, Legal.Pouch_Berries_RS, 999, OFS_PouchBerry, 46), - new(InventoryType.PCItems, PCItems, 999, OFS_PCItem, (OFS_PouchHeldItem - OFS_PCItem) / 4), + new(InventoryType.Items, info, max, OFS_PouchHeldItem, (OFS_PouchKeyItem - OFS_PouchHeldItem) / 4), + new(InventoryType.KeyItems, info, 1, OFS_PouchKeyItem, (OFS_PouchBalls - OFS_PouchKeyItem) / 4), + new(InventoryType.Balls, info, max, OFS_PouchBalls, (OFS_PouchTMHM - OFS_PouchBalls) / 4), + new(InventoryType.TMHMs, info, max, OFS_PouchTMHM, (OFS_PouchBerry - OFS_PouchTMHM) / 4), + new(InventoryType.Berries, info, 999, OFS_PouchBerry, 46), + new(InventoryType.PCItems, info, 999, OFS_PCItem, (OFS_PouchHeldItem - OFS_PCItem) / 4), }; } diff --git a/PKHeX.Core/Saves/SAV3FRLG.cs b/PKHeX.Core/Saves/SAV3FRLG.cs index a941f3970..e1f59d0ba 100644 --- a/PKHeX.Core/Saves/SAV3FRLG.cs +++ b/PKHeX.Core/Saves/SAV3FRLG.cs @@ -120,15 +120,15 @@ public override uint Coin protected override InventoryPouch3[] GetItems() { const int max = 999; - var PCItems = ArrayUtil.ConcatAll(Legal.Pouch_Items_RS, Legal.Pouch_Key_FRLG, Legal.Pouch_Ball_RS, Legal.Pouch_TMHM_RS, Legal.Pouch_Berries_RS); + var info = ItemStorage3FRLG.Instance; return new InventoryPouch3[] { - new(InventoryType.Items, Legal.Pouch_Items_RS, max, OFS_PouchHeldItem, (OFS_PouchKeyItem - OFS_PouchHeldItem) / 4), - new(InventoryType.KeyItems, Legal.Pouch_Key_FRLG, 1, OFS_PouchKeyItem, (OFS_PouchBalls - OFS_PouchKeyItem) / 4), - new(InventoryType.Balls, Legal.Pouch_Ball_RS, max, OFS_PouchBalls, (OFS_PouchTMHM - OFS_PouchBalls) / 4), - new(InventoryType.TMHMs, Legal.Pouch_TMHM_RS, max, OFS_PouchTMHM, (OFS_PouchBerry - OFS_PouchTMHM) / 4), - new(InventoryType.Berries, Legal.Pouch_Berries_RS, 999, OFS_PouchBerry, 43), - new(InventoryType.PCItems, PCItems, 999, OFS_PCItem, (OFS_PouchHeldItem - OFS_PCItem) / 4), + new(InventoryType.Items, info, max, OFS_PouchHeldItem, (OFS_PouchKeyItem - OFS_PouchHeldItem) / 4), + new(InventoryType.KeyItems, info, 1, OFS_PouchKeyItem, (OFS_PouchBalls - OFS_PouchKeyItem) / 4), + new(InventoryType.Balls, info, max, OFS_PouchBalls, (OFS_PouchTMHM - OFS_PouchBalls) / 4), + new(InventoryType.TMHMs, info, max, OFS_PouchTMHM, (OFS_PouchBerry - OFS_PouchTMHM) / 4), + new(InventoryType.Berries, info, 999, OFS_PouchBerry, 43), + new(InventoryType.PCItems, info, 999, OFS_PCItem, (OFS_PouchHeldItem - OFS_PCItem) / 4), }; } diff --git a/PKHeX.Core/Saves/SAV3RS.cs b/PKHeX.Core/Saves/SAV3RS.cs index 18efd9ed8..182fe8bcc 100644 --- a/PKHeX.Core/Saves/SAV3RS.cs +++ b/PKHeX.Core/Saves/SAV3RS.cs @@ -94,15 +94,15 @@ public override uint Coin protected override InventoryPouch3[] GetItems() { const int max = 99; - var PCItems = ArrayUtil.ConcatAll(Legal.Pouch_Items_RS, Legal.Pouch_Key_RS, Legal.Pouch_Ball_RS, Legal.Pouch_TMHM_RS, Legal.Pouch_Berries_RS); + var info = ItemStorage3RS.Instance; return new InventoryPouch3[] { - new(InventoryType.Items, Legal.Pouch_Items_RS, max, OFS_PouchHeldItem, (OFS_PouchKeyItem - OFS_PouchHeldItem) / 4), - new(InventoryType.KeyItems, Legal.Pouch_Key_RS, 1, OFS_PouchKeyItem, (OFS_PouchBalls - OFS_PouchKeyItem) / 4), - new(InventoryType.Balls, Legal.Pouch_Ball_RS, max, OFS_PouchBalls, (OFS_PouchTMHM - OFS_PouchBalls) / 4), - new(InventoryType.TMHMs, Legal.Pouch_TMHM_RS, max, OFS_PouchTMHM, (OFS_PouchBerry - OFS_PouchTMHM) / 4), - new(InventoryType.Berries, Legal.Pouch_Berries_RS, 999, OFS_PouchBerry, 46), - new(InventoryType.PCItems, PCItems, 999, OFS_PCItem, (OFS_PouchHeldItem - OFS_PCItem) / 4), + new(InventoryType.Items, info, max, OFS_PouchHeldItem, (OFS_PouchKeyItem - OFS_PouchHeldItem) / 4), + new(InventoryType.KeyItems, info, 1, OFS_PouchKeyItem, (OFS_PouchBalls - OFS_PouchKeyItem) / 4), + new(InventoryType.Balls, info, max, OFS_PouchBalls, (OFS_PouchTMHM - OFS_PouchBalls) / 4), + new(InventoryType.TMHMs, info, max, OFS_PouchTMHM, (OFS_PouchBerry - OFS_PouchTMHM) / 4), + new(InventoryType.Berries, info, 999, OFS_PouchBerry, 46), + new(InventoryType.PCItems, info, 999, OFS_PCItem, (OFS_PouchHeldItem - OFS_PCItem) / 4), }; } diff --git a/PKHeX.Core/Saves/SAV3XD.cs b/PKHeX.Core/Saves/SAV3XD.cs index f5f5767a8..a84b2c260 100644 --- a/PKHeX.Core/Saves/SAV3XD.cs +++ b/PKHeX.Core/Saves/SAV3XD.cs @@ -55,7 +55,7 @@ public SAV3XD(byte[] data) : base(data) } public override PersonalTable3 Personal => PersonalTable.RS; - public override ReadOnlySpan HeldItems => Legal.HeldItems_XD; + public override ReadOnlySpan HeldItems => Legal.HeldItems_RS; private readonly bool Japanese; @@ -415,15 +415,16 @@ public override IReadOnlyList Inventory { get { + var info = ItemStorage3XD.Instance; InventoryPouch[] pouch = { - new InventoryPouch3GC(InventoryType.Items, Legal.Pouch_Items_XD, 999, OFS_PouchHeldItem, 30), // 20 COLO, 30 XD - new InventoryPouch3GC(InventoryType.KeyItems, Legal.Pouch_Key_XD, 1, OFS_PouchKeyItem, 43), - new InventoryPouch3GC(InventoryType.Balls, Legal.Pouch_Ball_RS, 999, OFS_PouchBalls, 16), - new InventoryPouch3GC(InventoryType.TMHMs, Legal.Pouch_TM_RS, 999, OFS_PouchTMHM, 64), - new InventoryPouch3GC(InventoryType.Berries, Legal.Pouch_Berries_RS, 999, OFS_PouchBerry, 46), - new InventoryPouch3GC(InventoryType.Medicine, Legal.Pouch_Cologne_XD, 999, OFS_PouchCologne, 3), // Cologne - new InventoryPouch3GC(InventoryType.BattleItems, Legal.Pouch_Disc_XD, 1, OFS_PouchDisc, 60), + new InventoryPouch3GC(InventoryType.Items, info, 999, OFS_PouchHeldItem, 30), // 20 COLO, 30 XD + new InventoryPouch3GC(InventoryType.KeyItems, info, 1, OFS_PouchKeyItem, 43), + new InventoryPouch3GC(InventoryType.Balls, info, 999, OFS_PouchBalls, 16), + new InventoryPouch3GC(InventoryType.TMHMs, info, 999, OFS_PouchTMHM, 64), + new InventoryPouch3GC(InventoryType.Berries, info, 999, OFS_PouchBerry, 46), + new InventoryPouch3GC(InventoryType.Medicine, info, 999, OFS_PouchCologne, 3), // Cologne + new InventoryPouch3GC(InventoryType.BattleItems, info, 1, OFS_PouchDisc, 60), }; return pouch.LoadAll(Data); } diff --git a/PKHeX.Core/Saves/SAV4DP.cs b/PKHeX.Core/Saves/SAV4DP.cs index 357947a25..dc758b3aa 100644 --- a/PKHeX.Core/Saves/SAV4DP.cs +++ b/PKHeX.Core/Saves/SAV4DP.cs @@ -84,16 +84,17 @@ public override IReadOnlyList Inventory { get { + var info = ItemStorage4DP.Instance; InventoryPouch[] pouch = { - new InventoryPouch4(InventoryType.Items, Legal.Pouch_Items_DP, 999, 0x624), - new InventoryPouch4(InventoryType.KeyItems, Legal.Pouch_Key_DP, 1, 0x8B8), - new InventoryPouch4(InventoryType.TMHMs, Legal.Pouch_TMHM_DP, 99, 0x980), - new InventoryPouch4(InventoryType.MailItems, Legal.Pouch_Mail_DP, 999, 0xB10), - new InventoryPouch4(InventoryType.Medicine, Legal.Pouch_Medicine_DP, 999, 0xB40), - new InventoryPouch4(InventoryType.Berries, Legal.Pouch_Berries_DP, 999, 0xBE0), - new InventoryPouch4(InventoryType.Balls, Legal.Pouch_Ball_DP, 999, 0xCE0), - new InventoryPouch4(InventoryType.BattleItems, Legal.Pouch_Battle_DP, 999, 0xD1C), + new InventoryPouch4(InventoryType.Items, info, 999, 0x624), + new InventoryPouch4(InventoryType.KeyItems, info, 1, 0x8B8), + new InventoryPouch4(InventoryType.TMHMs, info, 99, 0x980), + new InventoryPouch4(InventoryType.MailItems, info, 999, 0xB10), + new InventoryPouch4(InventoryType.Medicine, info, 999, 0xB40), + new InventoryPouch4(InventoryType.Berries, info, 999, 0xBE0), + new InventoryPouch4(InventoryType.Balls, info, 999, 0xCE0), + new InventoryPouch4(InventoryType.BattleItems, info, 999, 0xD1C), }; return pouch.LoadAll(General); } diff --git a/PKHeX.Core/Saves/SAV4HGSS.cs b/PKHeX.Core/Saves/SAV4HGSS.cs index a95666ec2..49f2faac0 100644 --- a/PKHeX.Core/Saves/SAV4HGSS.cs +++ b/PKHeX.Core/Saves/SAV4HGSS.cs @@ -144,16 +144,17 @@ public override IReadOnlyList Inventory { get { + var info = ItemStorage4HGSS.Instance; InventoryPouch[] pouch = { - new InventoryPouch4(InventoryType.Items, Legal.Pouch_Items_HGSS, 999, 0x644), // 0x644-0x8D7 (0x8CB) - new InventoryPouch4(InventoryType.KeyItems, Legal.Pouch_Key_HGSS, 1, 0x8D8), // 0x8D8-0x99F (0x979) - new InventoryPouch4(InventoryType.TMHMs, Legal.Pouch_TMHM_HGSS, 99, 0x9A0), // 0x9A0-0xB33 (0xB2F) - new InventoryPouch4(InventoryType.MailItems, Legal.Pouch_Mail_HGSS, 999, 0xB34), // 0xB34-0xB63 (0xB63) - new InventoryPouch4(InventoryType.Medicine, Legal.Pouch_Medicine_HGSS, 999, 0xB64), // 0xB64-0xC03 (0xBFB) - new InventoryPouch4(InventoryType.Berries, Legal.Pouch_Berries_HGSS, 999, 0xC04), // 0xC04-0xD03 - new InventoryPouch4(InventoryType.Balls, Legal.Pouch_Ball_HGSS, 999, 0xD04), // 0xD04-0xD63 - new InventoryPouch4(InventoryType.BattleItems, Legal.Pouch_Battle_HGSS, 999, 0xD64), // 0xD64-0xD97 + new InventoryPouch4(InventoryType.Items, info, 999, 0x644), // 0x644-0x8D7 (0x8CB) + new InventoryPouch4(InventoryType.KeyItems, info, 1, 0x8D8), // 0x8D8-0x99F (0x979) + new InventoryPouch4(InventoryType.TMHMs, info, 99, 0x9A0), // 0x9A0-0xB33 (0xB2F) + new InventoryPouch4(InventoryType.MailItems, info, 999, 0xB34), // 0xB34-0xB63 (0xB63) + new InventoryPouch4(InventoryType.Medicine, info, 999, 0xB64), // 0xB64-0xC03 (0xBFB) + new InventoryPouch4(InventoryType.Berries, info, 999, 0xC04), // 0xC04-0xD03 + new InventoryPouch4(InventoryType.Balls, info, 999, 0xD04), // 0xD04-0xD63 + new InventoryPouch4(InventoryType.BattleItems, info, 999, 0xD64), // 0xD64-0xD97 }; return pouch.LoadAll(General); } diff --git a/PKHeX.Core/Saves/SAV4Pt.cs b/PKHeX.Core/Saves/SAV4Pt.cs index 9b94698d9..4c19e74ed 100644 --- a/PKHeX.Core/Saves/SAV4Pt.cs +++ b/PKHeX.Core/Saves/SAV4Pt.cs @@ -94,16 +94,17 @@ public override IReadOnlyList Inventory { get { + var info = ItemStorage4Pt.Instance; InventoryPouch[] pouch = { - new InventoryPouch4(InventoryType.Items, Legal.Pouch_Items_Pt, 999, 0x630), - new InventoryPouch4(InventoryType.KeyItems, Legal.Pouch_Key_Pt, 1, 0x8C4), - new InventoryPouch4(InventoryType.TMHMs, Legal.Pouch_TMHM_Pt, 99, 0x98C), - new InventoryPouch4(InventoryType.MailItems, Legal.Pouch_Mail_Pt, 999, 0xB1C), - new InventoryPouch4(InventoryType.Medicine, Legal.Pouch_Medicine_Pt, 999, 0xB4C), - new InventoryPouch4(InventoryType.Berries, Legal.Pouch_Berries_Pt, 999, 0xBEC), - new InventoryPouch4(InventoryType.Balls, Legal.Pouch_Ball_Pt, 999, 0xCEC), - new InventoryPouch4(InventoryType.BattleItems, Legal.Pouch_Battle_Pt, 999, 0xD28), + new InventoryPouch4(InventoryType.Items, info, 999, 0x630), + new InventoryPouch4(InventoryType.KeyItems, info, 1, 0x8C4), + new InventoryPouch4(InventoryType.TMHMs, info, 99, 0x98C), + new InventoryPouch4(InventoryType.MailItems, info, 999, 0xB1C), + new InventoryPouch4(InventoryType.Medicine, info, 999, 0xB4C), + new InventoryPouch4(InventoryType.Berries, info, 999, 0xBEC), + new InventoryPouch4(InventoryType.Balls, info, 999, 0xCEC), + new InventoryPouch4(InventoryType.BattleItems, info, 999, 0xD28), }; return pouch.LoadAll(General); } diff --git a/PKHeX.Core/Saves/SAV6XY.cs b/PKHeX.Core/Saves/SAV6XY.cs index 7c975fa66..3efed3763 100644 --- a/PKHeX.Core/Saves/SAV6XY.cs +++ b/PKHeX.Core/Saves/SAV6XY.cs @@ -24,7 +24,7 @@ public SAV6XY() : base(SaveUtil.SIZE_G6XY, SaveBlockAccessor6XY.BlockMetadataOff } public override PersonalTable6XY Personal => PersonalTable.XY; - public override ReadOnlySpan HeldItems => Legal.HeldItem_XY; + public override ReadOnlySpan HeldItems => Legal.HeldItem_AO; public SaveBlockAccessor6XY Blocks { get; } protected override SAV6XY CloneInternal() => new((byte[])Data.Clone()); public override ushort MaxMoveID => Legal.MaxMoveID_6_XY; diff --git a/PKHeX.Core/Saves/Substructures/Gen5/MyItem5B2W2.cs b/PKHeX.Core/Saves/Substructures/Gen5/MyItem5B2W2.cs index 3b65e19a3..05447539a 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/MyItem5B2W2.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/MyItem5B2W2.cs @@ -10,26 +10,20 @@ public sealed class MyItem5B2W2 : MyItem private const int TMHM = 0x624; // 2 private const int Medicine = 0x7D8; // 3 private const int Berry = 0x898; // 4 - - private static readonly ushort[] LegalItems = Legal.Pouch_Items_BW; - private static readonly ushort[] LegalKeyItems = Legal.Pouch_Key_B2W2; - private static readonly ushort[] LegalTMHMs = Legal.Pouch_TMHM_BW; - private static readonly ushort[] LegalMedicine = Legal.Pouch_Medicine_BW; - private static readonly ushort[] LegalBerries = Legal.Pouch_Berries_BW; - public MyItem5B2W2(SaveFile SAV, int offset) : base(SAV) => Offset = offset; public override IReadOnlyList Inventory { get { + var info = ItemStorage5B2W2.Instance; InventoryPouch4[] pouch = { - new(InventoryType.Items, LegalItems, 999, Offset + HeldItem), - new(InventoryType.KeyItems, LegalKeyItems, 1, Offset + KeyItem), - new(InventoryType.TMHMs, LegalTMHMs, 1, Offset + TMHM), - new(InventoryType.Medicine, LegalMedicine, 999, Offset + Medicine), - new(InventoryType.Berries, LegalBerries, 999, Offset + Berry), + new(InventoryType.Items, info, 999, Offset + HeldItem), + new(InventoryType.KeyItems, info, 1, Offset + KeyItem), + new(InventoryType.TMHMs, info, 1, Offset + TMHM), + new(InventoryType.Medicine, info, 999, Offset + Medicine), + new(InventoryType.Berries, info, 999, Offset + Berry), }; return pouch.LoadAll(Data); } diff --git a/PKHeX.Core/Saves/Substructures/Gen5/MyItem5BW.cs b/PKHeX.Core/Saves/Substructures/Gen5/MyItem5BW.cs index ce0124085..56e385692 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/MyItem5BW.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/MyItem5BW.cs @@ -11,25 +11,20 @@ public sealed class MyItem5BW : MyItem private const int Medicine = 0x7D8; // 3 private const int Berry = 0x898; // 4 - private static readonly ushort[] LegalItems = Legal.Pouch_Items_BW; - private static readonly ushort[] LegalKeyItems = Legal.Pouch_Key_BW; - private static readonly ushort[] LegalTMHMs = Legal.Pouch_TMHM_BW; - private static readonly ushort[] LegalMedicine = Legal.Pouch_Medicine_BW; - private static readonly ushort[] LegalBerries = Legal.Pouch_Berries_BW; - public MyItem5BW(SaveFile SAV, int offset) : base(SAV) => Offset = offset; public override IReadOnlyList Inventory { get { + var info = ItemStorage5BW.Instance; InventoryPouch4[] pouch = { - new(InventoryType.Items, LegalItems, 999, Offset + HeldItem), - new(InventoryType.KeyItems, LegalKeyItems, 1, Offset + KeyItem), - new(InventoryType.TMHMs, LegalTMHMs, 1, Offset + TMHM), - new(InventoryType.Medicine, LegalMedicine, 999, Offset + Medicine), - new(InventoryType.Berries, LegalBerries, 999, Offset + Berry), + new(InventoryType.Items, info, 999, Offset + HeldItem), + new(InventoryType.KeyItems, info, 1, Offset + KeyItem), + new(InventoryType.TMHMs, info, 1, Offset + TMHM), + new(InventoryType.Medicine, info, 999, Offset + Medicine), + new(InventoryType.Berries, info, 999, Offset + Berry), }; return pouch.LoadAll(Data); } diff --git a/PKHeX.Core/Saves/Substructures/Gen6/ItemInfo6.cs b/PKHeX.Core/Saves/Substructures/Gen6/ItemInfo6.cs index 926c3d84b..df42f7a99 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/ItemInfo6.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/ItemInfo6.cs @@ -1,4 +1,4 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; diff --git a/PKHeX.Core/Saves/Substructures/Gen6/MyItem6AO.cs b/PKHeX.Core/Saves/Substructures/Gen6/MyItem6AO.cs index bbac261ba..d033cd47e 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/MyItem6AO.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/MyItem6AO.cs @@ -17,13 +17,14 @@ public override IReadOnlyList Inventory { get { + var info = ItemStorage6AO.Instance; InventoryPouch4[] pouch = { - new(InventoryType.Items, Legal.Pouch_Items_AO, 999, Offset + HeldItem), - new(InventoryType.KeyItems, Legal.Pouch_Key_AO, 1, Offset + KeyItem), - new(InventoryType.TMHMs, Legal.Pouch_TMHM_AO, 1, Offset + TMHM), - new(InventoryType.Medicine, Legal.Pouch_Medicine_AO, 999, Offset + Medicine), - new(InventoryType.Berries, Legal.Pouch_Berry_XY, 999, Offset + Berry), + new(InventoryType.Items, info, 999, Offset + HeldItem), + new(InventoryType.KeyItems, info, 1, Offset + KeyItem), + new(InventoryType.TMHMs, info, 1, Offset + TMHM), + new(InventoryType.Medicine, info, 999, Offset + Medicine), + new(InventoryType.Berries, info, 999, Offset + Berry), }; return pouch.LoadAll(Data); } diff --git a/PKHeX.Core/Saves/Substructures/Gen6/MyItem6XY.cs b/PKHeX.Core/Saves/Substructures/Gen6/MyItem6XY.cs index 4a5e61eb1..ac5d0b2a4 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/MyItem6XY.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/MyItem6XY.cs @@ -16,13 +16,14 @@ public override IReadOnlyList Inventory { get { + var info = ItemStorage6XY.Instance; InventoryPouch4[] pouch = { - new(InventoryType.Items, Legal.Pouch_Items_XY, 999, Offset + HeldItem), - new(InventoryType.KeyItems, Legal.Pouch_Key_XY, 1, Offset + KeyItem), - new(InventoryType.TMHMs, Legal.Pouch_TMHM_XY, 1, Offset + TMHM), - new(InventoryType.Medicine, Legal.Pouch_Medicine_XY, 999, Offset + Medicine), - new(InventoryType.Berries, Legal.Pouch_Berry_XY, 999, Offset + Berry), + new(InventoryType.Items, info, 999, Offset + HeldItem), + new(InventoryType.KeyItems, info, 1, Offset + KeyItem), + new(InventoryType.TMHMs, info, 1, Offset + TMHM), + new(InventoryType.Medicine, info, 999, Offset + Medicine), + new(InventoryType.Berries, info, 999, Offset + Berry), }; return pouch.LoadAll(Data); } diff --git a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/MyItem7b.cs b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/MyItem7b.cs index cf103435c..7bb48e913 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/MyItem7b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/MyItem7b.cs @@ -18,15 +18,16 @@ public override IReadOnlyList Inventory { get { + var info = ItemStorage7GG.Instance; InventoryPouch7b[] pouch = { - new(InventoryType.Medicine, Legal.Pouch_Medicine_GG, 999, Medicine, PouchSize7b.Medicine), - new(InventoryType.TMHMs, Legal.Pouch_TM_GG, 1, TM, PouchSize7b.TM), - new(InventoryType.Balls, Legal.Pouch_Catching_GG, 999, Catching, PouchSize7b.Catching), - new(InventoryType.Items, Legal.Pouch_Regular_GG, 999, Key, PouchSize7b.Items), - new(InventoryType.BattleItems, Legal.Pouch_Battle_GG, 999, Battle, PouchSize7b.Battle), - new(InventoryType.ZCrystals, Legal.Pouch_PowerUp_GG, 999, PowerUp, PouchSize7b.PowerUp), - new(InventoryType.Candy, Legal.Pouch_Candy_GG, 999, Candy, PouchSize7b.Candy), + new(InventoryType.Medicine, info, 999, Medicine, PouchSize7b.Medicine), + new(InventoryType.TMHMs, info, 1, TM, PouchSize7b.TM), + new(InventoryType.Balls, info, 999, Catching, PouchSize7b.Catching), + new(InventoryType.Items, info, 999, Key, PouchSize7b.Items), + new(InventoryType.BattleItems, info, 999, Battle, PouchSize7b.Battle), + new(InventoryType.ZCrystals, info, 999, PowerUp, PouchSize7b.PowerUp), + new(InventoryType.Candy, info, 999, Candy, PouchSize7b.Candy), }; return pouch.LoadAll(Data); } diff --git a/PKHeX.Core/Saves/Substructures/Gen7/MyItem7SM.cs b/PKHeX.Core/Saves/Substructures/Gen7/MyItem7SM.cs index 9ea7ee9a7..97add76d4 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/MyItem7SM.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/MyItem7SM.cs @@ -17,14 +17,15 @@ public override IReadOnlyList Inventory { get { + var info = ItemStorage7SM.Instance; InventoryPouch7[] pouch = { - new(InventoryType.Medicine, Legal.Pouch_Medicine_SM, 999, Offset + Medicine), - new(InventoryType.Items, Legal.Pouch_Items_SM, 999, Offset + HeldItem), - new(InventoryType.TMHMs, Legal.Pouch_TMHM_SM, 1, Offset + TMHM), - new(InventoryType.Berries, Legal.Pouch_Berries_SM, 999, Offset + Berry), - new(InventoryType.KeyItems, Legal.Pouch_Key_SM, 1, Offset + KeyItem), - new(InventoryType.ZCrystals, Legal.Pouch_ZCrystal_SM, 1, Offset + ZCrystals), + new(InventoryType.Medicine, info, 999, Offset + Medicine), + new(InventoryType.Items, info, 999, Offset + HeldItem), + new(InventoryType.TMHMs, info, 1, Offset + TMHM), + new(InventoryType.Berries, info, 999, Offset + Berry), + new(InventoryType.KeyItems, info, 1, Offset + KeyItem), + new(InventoryType.ZCrystals, info, 1, Offset + ZCrystals), }; return pouch.LoadAll(Data); } diff --git a/PKHeX.Core/Saves/Substructures/Gen7/MyItem7USUM.cs b/PKHeX.Core/Saves/Substructures/Gen7/MyItem7USUM.cs index 3f0dcb627..73459dd03 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/MyItem7USUM.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/MyItem7USUM.cs @@ -18,15 +18,16 @@ public override IReadOnlyList Inventory { get { + var info = ItemStorage7USUM.Instance; InventoryPouch7[] pouch = { - new(InventoryType.Medicine, Legal.Pouch_Medicine_SM, 999, Medicine), - new(InventoryType.Items, Legal.Pouch_Items_SM, 999, HeldItem), - new(InventoryType.TMHMs, Legal.Pouch_TMHM_SM, 1, TMHM), - new(InventoryType.Berries, Legal.Pouch_Berries_SM, 999, Berry), - new(InventoryType.KeyItems, Legal.Pouch_Key_USUM, 1, KeyItem), - new(InventoryType.ZCrystals, Legal.Pouch_ZCrystal_USUM, 1, ZCrystals), - new(InventoryType.BattleItems, Legal.Pouch_Roto_USUM, 999, BattleItems), + new(InventoryType.Medicine, info, 999, Medicine), + new(InventoryType.Items, info, 999, HeldItem), + new(InventoryType.TMHMs, info, 1, TMHM), + new(InventoryType.Berries, info, 999, Berry), + new(InventoryType.KeyItems, info, 1, KeyItem), + new(InventoryType.ZCrystals, info, 1, ZCrystals), + new(InventoryType.BattleItems, info, 999, BattleItems), }; return pouch.LoadAll(Data); } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/MyItem8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/MyItem8b.cs index 3bcc59ad9..8931b8503 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/MyItem8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/MyItem8b.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; @@ -36,20 +36,13 @@ public void SetItemQuantity(ushort itemIndex, int quantity) item.Write(span); } - public static InventoryType GetType(ushort itemIndex) - { - var types = new[] - { - InventoryType.Items, InventoryType.KeyItems, InventoryType.TMHMs, InventoryType.Medicine, - InventoryType.Berries, InventoryType.Balls, InventoryType.BattleItems, InventoryType.Treasure, - }; - return Array.Find(types, z => GetLegal(z).Contains(itemIndex)); - } + public static InventoryType GetType(ushort itemIndex) => ItemStorage8BDSP.GetInventoryPouch(itemIndex); public ushort GetNextSortIndex(InventoryType type) { + var legal = ItemStorage8BDSP.GetLegal(type); ushort max = 0; - foreach (var itemID in GetLegal(type)) + foreach (var itemID in legal) { var ofs = InventoryPouch8b.GetItemOffset(itemID, Offset); var span = Data.AsSpan(ofs, InventoryItem8b.SIZE); @@ -66,14 +59,14 @@ private IReadOnlyList ConvertToPouches() { var pouches = new[] { - MakePouch(InventoryType.Items, IsHeldItemLegal), + MakePouch(InventoryType.Items), MakePouch(InventoryType.KeyItems), - MakePouch(InventoryType.TMHMs, IsHeldItemLegal), - MakePouch(InventoryType.Medicine, IsHeldItemLegal), - MakePouch(InventoryType.Berries, IsHeldItemLegal), - MakePouch(InventoryType.Balls, IsHeldItemLegal), - MakePouch(InventoryType.BattleItems, IsHeldItemLegal), - MakePouch(InventoryType.Treasure, IsHeldItemLegal), + MakePouch(InventoryType.TMHMs), + MakePouch(InventoryType.Medicine), + MakePouch(InventoryType.Berries), + MakePouch(InventoryType.Balls), + MakePouch(InventoryType.BattleItems), + MakePouch(InventoryType.Treasure), }; return pouches.LoadAll(Data); } @@ -86,19 +79,15 @@ private void LoadFromPouches(IReadOnlyList value) private void CleanIllegalSlots() { - var all = new[] + var types = ItemStorage8BDSP.ValidTypes; + var hashSet = new HashSet(Legal.MaxItemID_8b); + foreach (var type in types) { - GetLegal(InventoryType.Items), - GetLegal(InventoryType.KeyItems), - GetLegal(InventoryType.TMHMs), - GetLegal(InventoryType.Medicine), - GetLegal(InventoryType.Berries), - GetLegal(InventoryType.Balls), - GetLegal(InventoryType.BattleItems), - GetLegal(InventoryType.Treasure), - }.SelectMany(z => z).Distinct(); + var items = ItemStorage8BDSP.GetLegal(type); + foreach (var item in items) + hashSet.Add(item); + } - var hashSet = new HashSet(all); for (ushort i = 0; i < (ushort)SAV.MaxItemID; i++) // even though there are 3000, just overwrite the ones that people will mess up. { if (!hashSet.Contains(i)) @@ -106,38 +95,12 @@ private void CleanIllegalSlots() } } - private InventoryPouch8b MakePouch(InventoryType type, Func? isLegal = null) + private InventoryPouch8b MakePouch(InventoryType type) { - ushort[] legal = GetLegal(type); - var max = GetMax(type); - return new InventoryPouch8b(type, legal, max, Offset, isLegal); + var info = ItemStorage8BDSP.Instance; + var max = info.GetMax(type); + return new InventoryPouch8b(type, info, max, Offset); } public static bool IsHeldItemLegal(ushort item) => !Legal.HeldItems_BS.Contains(item) || Legal.ReleasedHeldItems_8b[item]; - - private static int GetMax(InventoryType type) => type switch - { - InventoryType.Items => 999, - InventoryType.KeyItems => 1, - InventoryType.TMHMs => 999, - InventoryType.Medicine => 999, - InventoryType.Berries => 999, - InventoryType.Balls => 999, - InventoryType.BattleItems => 999, - InventoryType.Treasure => 999, - _ => throw new ArgumentOutOfRangeException(nameof(type)), - }; - - private static ushort[] GetLegal(InventoryType type) => type switch - { - InventoryType.Items => Legal.Pouch_Regular_BS, - InventoryType.KeyItems => Legal.Pouch_Key_BS, - InventoryType.TMHMs => Legal.Pouch_TMHM_BS, - InventoryType.Medicine => Legal.Pouch_Medicine_BS, - InventoryType.Berries => Legal.Pouch_Berries_BS, - InventoryType.Balls => Legal.Pouch_Ball_BS, - InventoryType.BattleItems => Legal.Pouch_Battle_BS, - InventoryType.Treasure => Legal.Pouch_Treasure_BS, - _ => throw new ArgumentOutOfRangeException(nameof(type)), - }; } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/MyItem8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/MyItem8a.cs index f1e675441..2b224e7ad 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/MyItem8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/MyItem8a.cs @@ -21,10 +21,11 @@ public override IReadOnlyList Inventory var satchel = (uint)access.GetBlock(SaveBlockAccessor8LA.KSatchelUpgrades).GetValue(); var regularSize = (int)Math.Min(675, satchel + 20); - var regular = new InventoryPouch8a(InventoryType.Items, Legal.Pouch_Items_LA , 999, regularSize); - var key = new InventoryPouch8a(InventoryType.KeyItems, Legal.Pouch_Key_LA , 1, 100); - var stored = new InventoryPouch8a(InventoryType.PCItems, Legal.Pouch_Items_LA , 999, 180); - var recipe = new InventoryPouch8a(InventoryType.Treasure, Legal.Pouch_Recipe_LA, 1, 70); + var info = ItemStorage8LA.Instance; + var regular = new InventoryPouch8a(InventoryType.Items, info, 999, regularSize); + var key = new InventoryPouch8a(InventoryType.KeyItems, info, 1, 100); + var stored = new InventoryPouch8a(InventoryType.PCItems, info, 999, 180); + var recipe = new InventoryPouch8a(InventoryType.Treasure, info, 1, 70); regular.GetPouch(access.GetBlock(SaveBlockAccessor8LA.KItemRegular).Data); key .GetPouch(access.GetBlock(SaveBlockAccessor8LA.KItemKey).Data); stored.GetPouch(access.GetBlock(SaveBlockAccessor8LA.KItemStored).Data); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyItem8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyItem8.cs index d71f3fca6..0b051a6ac 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyItem8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyItem8.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; namespace PKHeX.Core; @@ -21,17 +20,18 @@ public override IReadOnlyList Inventory { get { + var info = ItemStorage8SWSH.Instance; InventoryPouch8[] pouch = { - new(InventoryType.Medicine, Legal.Pouch_Medicine_SWSH, 999, Medicine, PouchSize8.Medicine, IsItemLegal), - new(InventoryType.Balls, Legal.Pouch_Ball_SWSH, 999, Balls, PouchSize8.Balls, IsItemLegal), - new(InventoryType.BattleItems, Legal.Pouch_Battle_SWSH, 999, Battle, PouchSize8.Battle, IsItemLegal), - new(InventoryType.Berries, Legal.Pouch_Berries_SWSH, 999, Berries, PouchSize8.Berries, IsItemLegal), - new(InventoryType.Items, Legal.Pouch_Regular_SWSH, 999, Items, PouchSize8.Items, IsItemLegal), - new(InventoryType.TMHMs, Legal.Pouch_TMHM_SWSH, 999, TMs, PouchSize8.TMs, IsItemLegal), - new(InventoryType.Treasure, Legal.Pouch_Treasure_SWSH, 999, Treasures, PouchSize8.Treasures, IsItemLegal), - new(InventoryType.Candy, Legal.Pouch_Ingredients_SWSH, 999, Ingredients, PouchSize8.Ingredients, IsItemLegal), - new(InventoryType.KeyItems, Legal.Pouch_Key_SWSH, 1, Key, PouchSize8.Key), + new(InventoryType.Medicine, info, 999, Medicine, PouchSize8.Medicine), + new(InventoryType.Balls, info, 999, Balls, PouchSize8.Balls), + new(InventoryType.BattleItems, info, 999, Battle, PouchSize8.Battle), + new(InventoryType.Berries, info, 999, Berries, PouchSize8.Berries), + new(InventoryType.Items, info, 999, Items, PouchSize8.Items), + new(InventoryType.TMHMs, info, 999, TMs, PouchSize8.TMs), + new(InventoryType.Treasure, info, 999, Treasures, PouchSize8.Treasures), + new(InventoryType.Candy, info, 999, Ingredients, PouchSize8.Ingredients), + new(InventoryType.KeyItems, info, 1, Key, PouchSize8.Key), }; return pouch.LoadAll(Data); } @@ -42,13 +42,4 @@ public override IReadOnlyList Inventory value.SaveAll(Data); } } - - public static bool IsItemLegal(ushort item) - { - if (Legal.IsDynamaxCrystal(item)) - return Legal.IsDynamaxCrystalAvailable(item); - if (!Legal.HeldItems_SWSH.Contains(item)) - return true; - return Legal.ReleasedHeldItems_8[item]; - } } diff --git a/PKHeX.Core/Saves/Substructures/Gen9/MyItem9.cs b/PKHeX.Core/Saves/Substructures/Gen9/MyItem9.cs index 38583714a..b48585bde 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/MyItem9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/MyItem9.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; namespace PKHeX.Core; @@ -32,16 +31,7 @@ public void SetItemQuantity(ushort itemIndex, int quantity) item.Write(span); } - public static InventoryType GetType(ushort itemIndex) - { - var types = new[] - { - InventoryType.Items, InventoryType.KeyItems, InventoryType.TMHMs, InventoryType.Medicine, - InventoryType.Berries, InventoryType.Balls, InventoryType.BattleItems, InventoryType.Treasure, - InventoryType.Ingredients, InventoryType.Candy, - }; - return Array.Find(types, z => GetLegal(z).Contains(itemIndex)); - } + public static InventoryType GetType(ushort itemIndex) => ItemStorage9SV.GetInventoryPouch(itemIndex); public override IReadOnlyList Inventory { get => ConvertToPouches(); set => LoadFromPouches(value); } @@ -49,16 +39,16 @@ private IReadOnlyList ConvertToPouches() { var pouches = new[] { - MakePouch(InventoryType.Medicine, IsHeldItemLegal), - MakePouch(InventoryType.Balls, IsHeldItemLegal), - MakePouch(InventoryType.BattleItems, IsHeldItemLegal), - MakePouch(InventoryType.Berries, IsHeldItemLegal), - MakePouch(InventoryType.Items, IsHeldItemLegal), - MakePouch(InventoryType.TMHMs, IsHeldItemLegal), - MakePouch(InventoryType.Treasure, IsHeldItemLegal), - MakePouch(InventoryType.Ingredients, IsHeldItemLegal), + MakePouch(InventoryType.Medicine), + MakePouch(InventoryType.Balls), + MakePouch(InventoryType.BattleItems), + MakePouch(InventoryType.Berries), + MakePouch(InventoryType.Items), + MakePouch(InventoryType.TMHMs), + MakePouch(InventoryType.Treasure), + MakePouch(InventoryType.Ingredients), MakePouch(InventoryType.KeyItems), - MakePouch(InventoryType.Candy, IsHeldItemLegal), + MakePouch(InventoryType.Candy), }; return pouches.LoadAll(Data); } @@ -71,21 +61,14 @@ private void LoadFromPouches(IReadOnlyList value) private void CleanIllegalSlots() { - var all = new[] + var types = ItemStorage9SV.ValidTypes; + var hashSet = new HashSet(Legal.MaxItemID_9); + foreach (var type in types) { - GetLegal(InventoryType.Items), - GetLegal(InventoryType.KeyItems), - GetLegal(InventoryType.TMHMs), - GetLegal(InventoryType.Medicine), - GetLegal(InventoryType.Berries), - GetLegal(InventoryType.Balls), - GetLegal(InventoryType.BattleItems), - GetLegal(InventoryType.Treasure), - GetLegal(InventoryType.Ingredients), - GetLegal(InventoryType.Candy), - }.SelectMany(z => z).Distinct(); - - var hashSet = new HashSet(all); + var items = ItemStorage9SV.GetLegal(type); + foreach (var item in items) + hashSet.Add(item); + } for (ushort i = 0; i < (ushort)SAV.MaxItemID; i++) // even though there are 3000, just overwrite the ones that people will mess up. { if (!hashSet.Contains(i)) @@ -93,45 +76,13 @@ private void CleanIllegalSlots() } } - private static InventoryPouch9 MakePouch(InventoryType type, Func? isLegal = null) + private static InventoryPouch9 MakePouch(InventoryType type) { - ushort[] legal = GetLegal(type); - var max = GetMax(type); - return new InventoryPouch9(type, legal, max, GetPouchIndex(type), isLegal); + var info = ItemStorage9SV.Instance; + var max = info.GetMax(type); + return new InventoryPouch9(type, info, max, GetPouchIndex(type)); } - public static bool IsHeldItemLegal(ushort item) => !Legal.HeldItems_SV.Contains(item) || Legal.ReleasedHeldItems_9[item]; - - private static int GetMax(InventoryType type) => type switch - { - InventoryType.Items => 999, - InventoryType.KeyItems => 1, - InventoryType.TMHMs => 999, - InventoryType.Medicine => 999, - InventoryType.Berries => 999, - InventoryType.Balls => 999, - InventoryType.BattleItems => 999, - InventoryType.Treasure => 999, - InventoryType.Ingredients => 999, // 999 - InventoryType.Candy => 999, // 999 - _ => throw new ArgumentOutOfRangeException(nameof(type)), - }; - - private static ushort[] GetLegal(InventoryType type) => type switch - { - InventoryType.Items => Legal.Pouch_Other_SV, - InventoryType.KeyItems => Legal.Pouch_Event_SV, - InventoryType.TMHMs => Legal.Pouch_TM_SV, - InventoryType.Medicine => Legal.Pouch_Medicine_SV, - InventoryType.Berries => Legal.Pouch_Berries_SV, - InventoryType.Balls => Legal.Pouch_Ball_SV, - InventoryType.BattleItems => Legal.Pouch_Battle_SV, - InventoryType.Treasure => Legal.Pouch_Treasure_SV, - InventoryType.Ingredients => Legal.Pouch_Picnic_SV, - InventoryType.Candy => Legal.Pouch_Material_SV, - _ => throw new ArgumentOutOfRangeException(nameof(type)), - }; - private static uint GetPouchIndex(InventoryType type) => type switch { InventoryType.Items => InventoryItem9.PouchOther, diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Item/InventoryItem.cs b/PKHeX.Core/Saves/Substructures/Inventory/Item/InventoryItem.cs index 1ebd2234f..b61465bc9 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Item/InventoryItem.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Item/InventoryItem.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System; namespace PKHeX.Core; @@ -10,21 +9,6 @@ public record InventoryItem /// Quantity public int Count { get; set; } - /// - /// Checks if the item is compatible with a pouch. - /// - /// Legal Item IDs for the pouch - /// Max item ID that exists in the game - /// Bend the rules for cheaters? - public bool IsValid(IList legal, int maxItemID, bool HaX = false) - { - if (Index == 0) - return true; - if ((uint) Index > maxItemID) - return false; - return HaX || legal.Contains((ushort)Index); - } - /// /// Resets all data in the object back to zero. /// diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/IItemStorage.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/IItemStorage.cs new file mode 100644 index 000000000..4543725bc --- /dev/null +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/IItemStorage.cs @@ -0,0 +1,9 @@ +using System; + +namespace PKHeX.Core; + +public interface IItemStorage +{ + bool IsLegal(InventoryType type, int itemIndex, int itemCount); + ReadOnlySpan GetItems(InventoryType type); +} diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch.cs index aa8ff8a40..65858160c 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch.cs @@ -13,9 +13,7 @@ public abstract class InventoryPouch public readonly InventoryType Type; /// Valid item IDs that may be stored in the pouch. - public readonly ushort[] LegalItems; - - public readonly Func? IsItemLegal; + public readonly IItemStorage Info; /// Max quantity for a given item that can be stored in the pouch. public readonly int MaxCount; @@ -24,7 +22,7 @@ public abstract class InventoryPouch public int Count => Items.Count(it => it.Count > 0); /// Checks if the player may run out of bag space when there are too many unique items to fit into the pouch. - public bool IsCramped => LegalItems.Length > Items.Length; + public bool IsCramped => Info.GetItems(Type).Length > Items.Length; public InventoryItem[] Items; @@ -33,15 +31,14 @@ public abstract class InventoryPouch /// Size of the backing byte array that represents the pouch. protected readonly int PouchDataSize; - protected InventoryPouch(InventoryType type, ushort[] legal, int maxCount, int offset, int size = -1, Func? isLegal = null) + protected InventoryPouch(InventoryType type, IItemStorage storage, int maxCount, int offset, int size = -1) { Items = Array.Empty(); Type = type; - LegalItems = legal; + Info = storage; MaxCount = maxCount; Offset = offset; - PouchDataSize = size > -1 ? size : legal.Length; - IsItemLegal = isLegal; + PouchDataSize = size > -1 ? size : storage.GetItems(Type).Length; } /// Reads the pouch from the backing . @@ -88,13 +85,21 @@ private static int Compare(int i1, int i2, bool rev) public void Sanitize(int maxItemID, bool HaX = false) { int ctr = 0; - for (int i = 0; i < Items.Length; i++) + var arr = Items; + for (int i = 0; i < arr.Length; i++) { - if (Items[i].IsValid(LegalItems, maxItemID, HaX)) - Items[ctr++] = Items[i]; + var item = arr[i]; + if (item.Index != 0) + { + if ((uint)item.Index > maxItemID) + continue; + if (!HaX && !Info.IsLegal(Type, item.Index, item.Count)) + continue; + } + arr[ctr++] = arr[i]; // absorb down } - while (ctr < Items.Length) - Items[ctr++].Clear(); + while (ctr < arr.Length) + arr[ctr++].Clear(); } /// @@ -175,55 +180,78 @@ public void ModifyAllCount(SaveFile sav, int count = -1) item.Count = GetSuggestedItemCount(sav, item.Index, count); } - public void ModifyAllCount(Func modification) + public void GiveAllItems(SaveFile sav, ReadOnlySpan newItems, int count = -1) { - foreach (var item in Items.Where(z => z.Index != 0)) - item.Count = modification(item); + foreach (var item in Items) + item.Clear(); + + foreach (var item in newItems) + { + if (Info.IsLegal(Type, item, count)) + GiveItem(sav, item, count); + } } - public void GiveAllItems(ReadOnlySpan newItems, Func getSuggestedItemCount, int count = -1) + public void GiveAllItems(SaveFile sav, int count = -1) { - GiveAllItems(newItems, count); - ModifyAllCount(getSuggestedItemCount); + var items = Info.GetItems(Type); + foreach (var item in items) + GiveItem(sav, item, count); + + foreach (var item in Items) + { + if (item.Count != 0) + GetSuggestedItemCount(sav, item.Index, count); + } } - public void GiveAllItems(SaveFile sav, ReadOnlySpan items, int count = -1) + public int GiveItem(SaveFile sav, ushort itemID, int count = -1) { - GiveAllItems(items, count); - ModifyAllCount(item => GetSuggestedItemCount(sav, item.Index, count)); - } - - public void GiveAllItems(SaveFile sav, int count = -1) => GiveAllItems(sav, LegalItems, count); - - private void GiveAllItems(ReadOnlySpan newItems, int count = -1) - { - if (count < 0) + if (count <= 0) count = MaxCount; - var current = (InventoryItem[]) Items.Clone(); - var itemEnd = Math.Min(Items.Length, newItems.Length); - var iterate = newItems[..itemEnd]; + var existIndex = FindFirstMatchingSlot(itemID); + if (existIndex >= 0) + return AddCountTo(Items[existIndex], count, sav); - int ctr = 0; - foreach (var newItemID in iterate) + var emptyIndex = FindFirstEmptySlot(); + if (emptyIndex < 0) + return -1; + + var newItem = Items[emptyIndex]; + newItem.Index = itemID; + newItem.SetNewDetails(0); + return AddCountTo(newItem, count, sav); + } + + private int AddCountTo(InventoryItem exist, int count, SaveFile sav) + { + var existCount = exist.Count; + var newCount = existCount + count; + + // Sanitize the value + newCount = GetSuggestedItemCount(sav, exist.Index, newCount); + return exist.Count = newCount; + } + + private int FindFirstEmptySlot() + { + for (int i = 0; i < Items.Length; i++) { - if (IsItemLegal?.Invoke(newItemID) == false) - continue; - - var item = Items[ctr++] = GetEmpty(newItemID); - var match = Array.Find(current, z => z.Index == newItemID); - if (match == null) - { - item.SetNewDetails(count); - continue; - } - - // load old values - item.MergeOverwrite(match); + if (Items[i].Index == 0) + return i; } + return -1; + } - for (int i = ctr; i < Items.Length; i++) - Items[i] = GetEmpty(); + private int FindFirstMatchingSlot(ushort itemID) + { + for (int i = 0; i < Items.Length; i++) + { + if (Items[i].Index == itemID) + return i; + } + return -1; } public bool IsValidItemAndCount(ITrainerInfo sav, int item, bool HasNew, bool HaX, ref int count) @@ -270,6 +298,16 @@ private int GetSuggestedItemCount(ITrainerInfo sav, int item, int requestVal = 1 } public abstract InventoryItem GetEmpty(int itemID = 0, int count = 0); + + public ReadOnlySpan GetAllItems() + { + return Info.GetItems(Type); + } + + public bool CanContain(ushort itemIndex) + { + return Info.GetItems(Type).Contains(itemIndex); + } } public static class InventoryPouchExtensions diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3.cs index f76a5ccbd..a387be324 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3.cs @@ -7,8 +7,8 @@ public sealed class InventoryPouch3 : InventoryPouch { public uint SecurityKey { private get; set; } // = 0 // Gen3 Only - public InventoryPouch3(InventoryType type, ushort[] legal, int maxCount, int offset, int size) - : base(type, legal, maxCount, offset, size) + public InventoryPouch3(InventoryType type, IItemStorage info, int maxCount, int offset, int size) + : base(type, info, maxCount, offset, size) { } diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3GC.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3GC.cs index 78fab88cd..b31d10473 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3GC.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3GC.cs @@ -5,8 +5,8 @@ namespace PKHeX.Core; public sealed class InventoryPouch3GC : InventoryPouch { - public InventoryPouch3GC(InventoryType type, ushort[] legal, int maxCount, int offset, int size) - : base(type, legal, maxCount, offset, size) + public InventoryPouch3GC(InventoryType type, IItemStorage info, int maxCount, int offset, int size) + : base(type, info, maxCount, offset, size) { } diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch4.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch4.cs index 331980085..3a58c0d3e 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch4.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch4.cs @@ -8,8 +8,8 @@ namespace PKHeX.Core; /// public sealed class InventoryPouch4 : InventoryPouch { - public InventoryPouch4(InventoryType type, ushort[] legal, int maxCount, int offset) - : base(type, legal, maxCount, offset) + public InventoryPouch4(InventoryType type, IItemStorage info, int maxCount, int offset) + : base(type, info, maxCount, offset) { } diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7.cs index 3892a1425..7dd04c6cc 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7.cs @@ -8,8 +8,7 @@ public sealed class InventoryPouch7 : InventoryPouch public bool SetNew { get; set; } private int[] OriginalItems = Array.Empty(); - public InventoryPouch7(InventoryType type, ushort[] legal, int maxCount, int offset) - : base(type, legal, maxCount, offset) { } + public InventoryPouch7(InventoryType type, IItemStorage info, int maxCount, int offset) : base(type, info, maxCount, offset) { } public override InventoryItem7 GetEmpty(int itemID = 0, int count = 0) => new() { Index = itemID, Count = count }; diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7b.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7b.cs index ba55b4ff3..587ad4bee 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7b.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7b.cs @@ -13,8 +13,7 @@ public sealed class InventoryPouch7b : InventoryPouch public override InventoryItem7b GetEmpty(int itemID = 0, int count = 0) => new() { Index = itemID, Count = count }; - public InventoryPouch7b(InventoryType type, ushort[] legal, int maxCount, int offset, int size) - : base(type, legal, maxCount, offset, size) { } + public InventoryPouch7b(InventoryType type, IItemStorage info, int maxCount, int offset, int size) : base(type, info, maxCount, offset, size) { } public override void GetPouch(ReadOnlySpan data) { @@ -64,7 +63,7 @@ public static int GetSuggestedCount(InventoryType t, int item, int requestVal) // mixed regular battle items & mega stones case InventoryType.BattleItems when item > 100: // mixed regular items & key items - case InventoryType.Items when Array.IndexOf(Legal.Pouch_Regular_GG_Key, (ushort)item) != -1: + case InventoryType.Items when ItemStorage7GG.Pouch_Regular_GG_Key.Contains((ushort)item): return Math.Min(1, requestVal); default: diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8.cs index 4bd491301..901f2e6a8 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8.cs @@ -11,8 +11,7 @@ public sealed class InventoryPouch8 : InventoryPouch public bool SetNew { get; set; } private int[] OriginalItems = Array.Empty(); - public InventoryPouch8(InventoryType type, ushort[] legal, int maxCount, int offset, int size, Func? isLegal = null) - : base(type, legal, maxCount, offset, size, isLegal) { } + public InventoryPouch8(InventoryType type, IItemStorage info, int maxCount, int offset, int size) : base(type, info, maxCount, offset, size) { } public override InventoryItem8 GetEmpty(int itemID = 0, int count = 0) => new() { Index = itemID, Count = count }; diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8a.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8a.cs index 19c2d5565..3dbf045b8 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8a.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8a.cs @@ -12,9 +12,8 @@ public sealed class InventoryPouch8a : InventoryPouch { private readonly int MaxSize; - public InventoryPouch8a(InventoryType type, ushort[] legal, int maxCount, int size, int offset = 0, - Func? isLegal = null) - : base(type, legal, maxCount, offset, isLegal: isLegal) => MaxSize = size; + public InventoryPouch8a(InventoryType type, IItemStorage info, int maxCount, int size, int offset = 0) + : base(type, info, maxCount, offset) => MaxSize = size; public override InventoryItem8a GetEmpty(int itemID = 0, int count = 0) => new() { Index = itemID, Count = count }; diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8b.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8b.cs index 315a54dbb..9416a3ea0 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8b.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8b.cs @@ -8,14 +8,14 @@ public sealed class InventoryPouch8b : InventoryPouch { public bool SetNew { get; set; } - public InventoryPouch8b(InventoryType type, ushort[] legal, int maxCount, int offset, - Func? isLegal) - : base(type, legal, maxCount, offset, isLegal: isLegal) { } + public InventoryPouch8b(InventoryType type, IItemStorage info, int maxCount, int offset) + : base(type, info, maxCount, offset) { } public override InventoryItem8b GetEmpty(int itemID = 0, int count = 0) => new() { Index = itemID, Count = count, IsNew = true }; public override void GetPouch(ReadOnlySpan data) { + var LegalItems = Info.GetItems(Type); var items = new InventoryItem8b[LegalItems.Length]; int ctr = 0; @@ -48,13 +48,13 @@ public override void SetPouch(Span data) for (int i = 0; i < items.Length; i++) items[i].SortOrder = (ushort)(i + 1); + var LegalItems = Info.GetItems(Type); foreach (var item in items) { var index = (ushort)item.Index; if (index == 0) continue; - var isInLegal = Array.IndexOf(LegalItems, index); - if (isInLegal == -1) + if (!LegalItems.Contains(index)) { Debug.WriteLine($"Invalid Item ID returned within this pouch: {index}"); continue; diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch9.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch9.cs index 04c2faf43..fc79ea4d4 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch9.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch9.cs @@ -9,9 +9,8 @@ public sealed class InventoryPouch9 : InventoryPouch public bool SetNew { get; set; } public uint PouchIndex { get; set; } - public InventoryPouch9(InventoryType type, ushort[] legal, int maxCount, uint pouch, - Func? isLegal) - : base(type, legal, maxCount, 0, isLegal: isLegal) + public InventoryPouch9(InventoryType type, IItemStorage info, int maxCount, uint pouch) + : base(type, info, maxCount, 0) { PouchIndex = pouch; } @@ -20,6 +19,7 @@ public sealed class InventoryPouch9 : InventoryPouch public override void GetPouch(ReadOnlySpan data) { + var LegalItems = Info.GetItems(Type); var items = new InventoryItem9[LegalItems.Length]; int ctr = 0; @@ -49,13 +49,13 @@ public override void SetPouch(Span data) // Write all the item slots still present in the pouch. Keep track of the item IDs processed. var items = (InventoryItem9[])Items; + var LegalItems = Info.GetItems(Type); foreach (var item in items) { var index = (ushort)item.Index; if (index == 0) continue; - var isInLegal = Array.IndexOf(LegalItems, index); - if (isInLegal == -1) + if (!LegalItems.Contains(index)) { Debug.WriteLine($"Invalid Item ID returned within this pouch: {index}"); continue; diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouchGB.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouchGB.cs index a5011be3f..e5f76759d 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouchGB.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouchGB.cs @@ -4,8 +4,8 @@ namespace PKHeX.Core; public sealed class InventoryPouchGB : InventoryPouch { - public InventoryPouchGB(InventoryType type, ushort[] legal, int maxCount, int offset, int size) - : base(type, legal, maxCount, offset, size) + public InventoryPouchGB(InventoryType type, IItemStorage info, int maxCount, int offset, int size) + : base(type, info, maxCount, offset, size) { } @@ -13,6 +13,7 @@ public InventoryPouchGB(InventoryType type, ushort[] legal, int maxCount, int of public override void GetPouch(ReadOnlySpan data) { + var LegalItems = Info.GetItems(Type); var items = new InventoryItem[PouchDataSize]; if (Type == InventoryType.TMHMs) { @@ -74,9 +75,10 @@ public override void SetPouch(Span data) switch (Type) { case InventoryType.TMHMs: + var LegalItems = Info.GetItems(Type); foreach (InventoryItem t in Items) { - int index = Array.FindIndex(LegalItems, it => t.Index == it); + int index = LegalItems.IndexOf((ushort)t.Index); if (index < 0) // enforce correct pouch continue; data[Offset + index] = (byte)t.Count; diff --git a/PKHeX.Core/Util/ArrayUtil.cs b/PKHeX.Core/Util/ArrayUtil.cs index 602010d22..bfaeb7847 100644 --- a/PKHeX.Core/Util/ArrayUtil.cs +++ b/PKHeX.Core/Util/ArrayUtil.cs @@ -104,41 +104,108 @@ internal static T[] ConcatAll(params T[][] arr) return result; } - internal static T[] ConcatAll(T[] arr1, T[] arr2) + internal static T[] ConcatAll(ReadOnlySpan arr1, ReadOnlySpan arr2) { int len = arr1.Length + arr2.Length; - var result = new T[len]; - arr1.CopyTo(result, 0); - arr2.CopyTo(result, arr1.Length); - return result; + var arr = new T[len]; + + var result = arr.AsSpan(); + int ctr = 0; + arr1.CopyTo(result); ctr += arr1.Length; + arr2.CopyTo(result[ctr..]); + return arr; } - internal static T[] ConcatAll(T[] arr1, T[] arr2, T[] arr3) + internal static T[] ConcatAll(ReadOnlySpan arr1, ReadOnlySpan arr2, ReadOnlySpan arr3) { int len = arr1.Length + arr2.Length + arr3.Length; - var result = new T[len]; - arr1.CopyTo(result, 0); - arr2.CopyTo(result, arr1.Length); - arr3.CopyTo(result, arr1.Length + arr2.Length); - return result; + var arr = new T[len]; + + var result = arr.AsSpan(); + int ctr = 0; + arr1.CopyTo(result); ctr += arr1.Length; + arr2.CopyTo(result[ctr..]); ctr += arr2.Length; + arr3.CopyTo(result[ctr..]); + return arr; + } + + internal static T[] ConcatAll(ReadOnlySpan arr1, ReadOnlySpan arr2, ReadOnlySpan arr3, ReadOnlySpan arr4) + { + int len = arr1.Length + arr2.Length + arr3.Length + arr4.Length; + var arr = new T[len]; + + var result = arr.AsSpan(); + int ctr = 0; + arr1.CopyTo(result); ctr += arr1.Length; + arr2.CopyTo(result[ctr..]); ctr += arr2.Length; + arr3.CopyTo(result[ctr..]); ctr += arr3.Length; + arr4.CopyTo(result[ctr..]); + return arr; } - internal static T[] ConcatAll(T[] arr1, ReadOnlySpan arr2) + internal static T[] ConcatAll(ReadOnlySpan arr1, ReadOnlySpan arr2, ReadOnlySpan arr3, ReadOnlySpan arr4, ReadOnlySpan arr5) { - int len = arr1.Length + arr2.Length; - var result = new T[len]; - arr1.CopyTo(result, 0); - arr2.CopyTo(result.AsSpan(arr1.Length)); - return result; + int len = arr1.Length + arr2.Length + arr3.Length + arr4.Length + arr5.Length; + var arr = new T[len]; + + var result = arr.AsSpan(); + int ctr = 0; + arr1.CopyTo(result); ctr += arr1.Length; + arr2.CopyTo(result[ctr..]); ctr += arr2.Length; + arr3.CopyTo(result[ctr..]); ctr += arr3.Length; + arr4.CopyTo(result[ctr..]); ctr += arr4.Length; + arr5.CopyTo(result[ctr..]); + return arr; } - internal static T[] ConcatAll(T[] arr1, T[] arr2, ReadOnlySpan arr3) + internal static T[] ConcatAll(ReadOnlySpan arr1, ReadOnlySpan arr2, ReadOnlySpan arr3, ReadOnlySpan arr4, ReadOnlySpan arr5, ReadOnlySpan arr6) { - int len = arr1.Length + arr2.Length + arr3.Length; - var result = new T[len]; - arr1.CopyTo(result, 0); - arr2.CopyTo(result, arr1.Length); - arr3.CopyTo(result.AsSpan(arr1.Length + arr2.Length)); - return result; + int len = arr1.Length + arr2.Length + arr3.Length + arr4.Length + arr5.Length + arr6.Length; + var arr = new T[len]; + + var result = arr.AsSpan(); + int ctr = 0; + arr1.CopyTo(result); ctr += arr1.Length; + arr2.CopyTo(result[ctr..]); ctr += arr2.Length; + arr3.CopyTo(result[ctr..]); ctr += arr3.Length; + arr4.CopyTo(result[ctr..]); ctr += arr4.Length; + arr5.CopyTo(result[ctr..]); ctr += arr5.Length; + arr6.CopyTo(result[ctr..]); + return arr; + } + + internal static T[] ConcatAll(ReadOnlySpan arr1, ReadOnlySpan arr2, ReadOnlySpan arr3, ReadOnlySpan arr4, ReadOnlySpan arr5, ReadOnlySpan arr6, ReadOnlySpan arr7) + { + int len = arr1.Length + arr2.Length + arr3.Length + arr4.Length + arr5.Length + arr6.Length + arr7.Length; + var arr = new T[len]; + + var result = arr.AsSpan(); + int ctr = 0; + arr1.CopyTo(result); ctr += arr1.Length; + arr2.CopyTo(result[ctr..]); ctr += arr2.Length; + arr3.CopyTo(result[ctr..]); ctr += arr3.Length; + arr4.CopyTo(result[ctr..]); ctr += arr4.Length; + arr5.CopyTo(result[ctr..]); ctr += arr5.Length; + arr6.CopyTo(result[ctr..]); ctr += arr6.Length; + arr7.CopyTo(result[ctr..]); + return arr; + } + + internal static T[] ConcatAll(ReadOnlySpan arr1, ReadOnlySpan arr2, ReadOnlySpan arr3, ReadOnlySpan arr4, ReadOnlySpan arr5, ReadOnlySpan arr6, ReadOnlySpan arr7, ReadOnlySpan arr8) + { + int len = arr1.Length + arr2.Length + arr3.Length + arr4.Length + arr5.Length + arr6.Length + arr7.Length + arr8.Length; + var arr = new T[len]; + + var result = arr.AsSpan(); + int ctr = 0; + arr1.CopyTo(result); ctr += arr1.Length; + arr2.CopyTo(result[ctr..]); ctr += arr2.Length; + arr3.CopyTo(result[ctr..]); ctr += arr3.Length; + arr4.CopyTo(result[ctr..]); ctr += arr4.Length; + arr5.CopyTo(result[ctr..]); ctr += arr5.Length; + arr6.CopyTo(result[ctr..]); ctr += arr6.Length; + arr7.CopyTo(result[ctr..]); ctr += arr7.Length; + arr8.CopyTo(result[ctr..]); + return arr; } } diff --git a/PKHeX.Drawing.Misc/Util/MysteryGiftSpriteUtil.cs b/PKHeX.Drawing.Misc/Util/MysteryGiftSpriteUtil.cs index 284fa58bb..7c7fa886f 100644 --- a/PKHeX.Drawing.Misc/Util/MysteryGiftSpriteUtil.cs +++ b/PKHeX.Drawing.Misc/Util/MysteryGiftSpriteUtil.cs @@ -32,7 +32,7 @@ private static Image GetBaseImage(MysteryGift gift) if (gift.IsItem) { var item = (ushort)gift.ItemID; - if (Legal.ZCrystalDictionary.TryGetValue(item, out var value)) + if (ItemStorage7USUM.GetCrystalHeld(item, out var value)) item = value; return SpriteUtil.GetItemSprite(item) ?? Resources.Bag_Key; } diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_PokeBlockORAS.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_PokeBlockORAS.cs index a25d9c847..f9138026c 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_PokeBlockORAS.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_PokeBlockORAS.cs @@ -51,7 +51,7 @@ private void B_RandomizeBerries_Click(object sender, EventArgs e) // Randomize the trees. ReadOnlySpan tree = DefaultBerryTree; - var plantable = Legal.Pouch_Berry_XY; // 0 index is None, skip with rand + var plantable = ItemStorage6XY.Pouch_Berry_XY; // 0 index is None, skip with rand var rnd = Util.Rand; var plots = SAV.Data.AsSpan(SAV.BerryField); diff --git a/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs b/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs index 03c6cd042..6f0e6c514 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs @@ -102,7 +102,7 @@ private DataGridView GetDGV(InventoryPouch pouch) dgv.Columns.Add(GetCountColumn(pouch, true, ColumnFreeSpaceIndex = dgv.Columns.Count, "Free")); // Populate with rows - var itemarr = Main.HaX ? itemlist : GetStringsForPouch(pouch.LegalItems); + var itemarr = Main.HaX ? itemlist : GetStringsForPouch(pouch.GetAllItems()); item.Items.AddRange(itemarr); var items = pouch.Items; @@ -172,7 +172,7 @@ private void LoadAllBags() var dgv = GetGrid(pouch.Type); // Sanity Screen - var invalid = Array.FindAll(pouch.Items, item => item.Index != 0 && !pouch.LegalItems.Contains((ushort)item.Index)); + var invalid = Array.FindAll(pouch.Items, item => item.Index != 0 && !pouch.CanContain((ushort)item.Index)); var outOfBounds = Array.FindAll(invalid, item => item.Index >= itemlist.Length); var incorrectPouch = Array.FindAll(invalid, item => item.Index < itemlist.Length); @@ -288,7 +288,7 @@ private static int GetMax(ITrainerInfo sav, InventoryPouch pouch, bool HaX) // Initialize String Tables private readonly string[] itemlist; - private string[] GetStringsForPouch(ushort[] items, bool sort = true) + private string[] GetStringsForPouch(ReadOnlySpan items, bool sort = true) { string[] res = new string[items.Length + 1]; for (int i = 0; i < res.Length - 1; i++) @@ -317,10 +317,9 @@ private void GiveAllItems(object sender, EventArgs e) if (!GetModifySettings(pouch, out var truncate, out var shuffle)) return; - var items = pouch.LegalItems; + var items = pouch.GetAllItems().ToArray(); if (truncate) { - items = (ushort[])items.Clone(); if (shuffle) Util.Rand.Shuffle(items.AsSpan()); Array.Resize(ref items, pouch.Items.Length);