From 387ed9cbccd38adca2f276507448cfe6c43c29b2 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sun, 4 Sep 2016 14:00:52 -0700 Subject: [PATCH] Refactoring Gen1/2 arrays to legality tables Add PP tables for gen1/2 too --- PKHeX/Legality/Tables1.cs | 28 ++++++++++++++++++++++++++++ PKHeX/Legality/Tables2.cs | 35 +++++++++++++++++++++++++++++++++++ PKHeX/PKHeX.csproj | 2 ++ PKHeX/PKM/PKM.cs | 2 ++ PKHeX/PKM/PKX.cs | 12 ------------ PKHeX/Saves/SAV1.cs | 2 +- PKHeX/Saves/SAV2.cs | 15 +++++---------- 7 files changed, 73 insertions(+), 23 deletions(-) create mode 100644 PKHeX/Legality/Tables1.cs create mode 100644 PKHeX/Legality/Tables2.cs diff --git a/PKHeX/Legality/Tables1.cs b/PKHeX/Legality/Tables1.cs new file mode 100644 index 000000000..fb27c2f0b --- /dev/null +++ b/PKHeX/Legality/Tables1.cs @@ -0,0 +1,28 @@ +using System.Linq; + +namespace PKHeX +{ + public static partial class Legal + { + // PKHeX Valid Array Storage + internal static readonly ushort[] Pouch_Items_RBY = Enumerable.Range(0, 7) // 0-6 + .Concat(Enumerable.Range(10, 11)) // 10-20 + .Concat(Enumerable.Range(29, 15)) // 29-43 + .Concat(Enumerable.Range(45, 5)) // 45-49 + .Concat(Enumerable.Range(51, 8)) // 51-58 + .Concat(Enumerable.Range(60, 24)) // 60-83 + .Concat(Enumerable.Range(196, 54)) // 196-249 + .Select(i => (ushort)i).ToArray(); + + internal static readonly int[] MovePP_RBY = + { + 0, + 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 30, 30, 35, 35, 20, 15, 20, 20, 10, 20, 30, 05, 25, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 20, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, + 30, 25, 15, 30, 25, 05, 15, 10, 05, 20, 20, 20, 05, 35, 20, 25, 20, 20, 20, 15, 20, 10, 10, 40, 25, 10, 35, 30, 15, 20, 40, 10, 15, 30, 15, 20, 10, 15, 10, 05, 10, 10, 25, 10, 20, 40, 30, 30, 20, 20, + 15, 10, 40, 15, 20, 30, 20, 20, 10, 40, 40, 30, 30, 30, 20, 30, 10, 10, 20, 05, 10, 30, 20, 20, 20, 05, 15, 10, 20, 15, 15, 35, 20, 15, 10, 20, 30, 15, 40, 20, 15, 10, 05, 10, 30, 10, 15, 20, 15, 40, + 40, 10, 05, 15, 10, 10, 10, 15, 30, 30, 10, 10, 20, 10, 10, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, + 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, + 00, 00, 00, 00, 00, 00 + }; + } +} diff --git a/PKHeX/Legality/Tables2.cs b/PKHeX/Legality/Tables2.cs new file mode 100644 index 000000000..c7f0be57d --- /dev/null +++ b/PKHeX/Legality/Tables2.cs @@ -0,0 +1,35 @@ +using System.Linq; + +namespace PKHeX +{ + public static partial class Legal + { + // PKHeX Valid Array Storage + 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, 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, 167 + }; + 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 = Pouch_Key_GS.Concat(new ushort[]{70, 115, 116, 129}).ToArray(); + 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 = new ushort[1].Concat(Pouch_Items_GSC).Concat(Pouch_Ball_GSC).ToArray(); + + internal static readonly int[] MovePP_GSC = + { + 00, + 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 30, 30, 35, 35, 20, 15, 20, 20, 10, 20, 30, 05, 25, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 20, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, + 30, 25, 15, 30, 25, 05, 15, 10, 05, 20, 20, 20, 05, 35, 20, 25, 20, 20, 20, 15, 20, 10, 10, 40, 25, 10, 35, 30, 15, 20, 40, 10, 15, 30, 15, 20, 10, 15, 10, 05, 10, 10, 25, 10, 20, 40, 30, 30, 20, 20, + 15, 10, 40, 15, 20, 30, 20, 20, 10, 40, 40, 30, 30, 30, 20, 30, 10, 10, 20, 05, 10, 30, 20, 20, 20, 05, 15, 10, 20, 15, 15, 35, 20, 15, 10, 20, 30, 15, 40, 20, 15, 10, 05, 10, 30, 10, 15, 20, 15, 40, + 40, 10, 05, 15, 10, 10, 10, 15, 30, 30, 10, 10, 20, 10, 01, 01, 10, 10, 10, 05, 15, 25, 15, 10, 15, 30, 05, 40, 15, 10, 25, 10, 30, 10, 20, 10, 10, 10, 10, 10, 20, 05, 40, 05, 05, 15, 05, 10, 05, 15, + 10, 05, 10, 20, 20, 40, 15, 10, 20, 20, 25, 05, 15, 10, 05, 20, 15, 20, 25, 20, 05, 30, 05, 10, 20, 40, 05, 20, 40, 20, 15, 35, 10, 05, 05, 05, 15, 05, 20, 05, 05, 15, 20, 10, 05, 05, 15, 15, 15, 15, + 10, 00, 00, 00, 00 + }; + } +} diff --git a/PKHeX/PKHeX.csproj b/PKHeX/PKHeX.csproj index a5eaa88f4..ab34b112a 100644 --- a/PKHeX/PKHeX.csproj +++ b/PKHeX/PKHeX.csproj @@ -70,6 +70,8 @@ + + diff --git a/PKHeX/PKM/PKM.cs b/PKHeX/PKM/PKM.cs index 0bbb0f351..bb2293dbd 100644 --- a/PKHeX/PKM/PKM.cs +++ b/PKHeX/PKM/PKM.cs @@ -447,6 +447,8 @@ private int getBasePP(int move) int[] pptable; switch (Format) { + case 1: pptable = Legal.MovePP_RBY; break; + case 2: pptable = Legal.MovePP_GSC; break; case 3: pptable = Legal.MovePP_RS; break; case 4: pptable = Legal.MovePP_DP; break; case 5: pptable = Legal.MovePP_BW; break; diff --git a/PKHeX/PKM/PKX.cs b/PKHeX/PKM/PKX.cs index 3f5b51498..c85c9531a 100644 --- a/PKHeX/PKM/PKX.cs +++ b/PKHeX/PKM/PKX.cs @@ -2148,18 +2148,6 @@ public static ushort getG4Item(ushort g3val) }; #endregion - public static int[] getG1LegalItems() - { - return Enumerable.Range(0, 7) // 0-6 - .Concat(Enumerable.Range(10, 11)) // 10-20 - .Concat(Enumerable.Range(29, 15)) // 29-43 - .Concat(Enumerable.Range(45, 5)) // 45-49 - .Concat(Enumerable.Range(51, 8)) // 51-58 - .Concat(Enumerable.Range(60, 24)) // 60-83 - .Concat(Enumerable.Range(196, 54)) // 196-249 - .ToArray(); - } - public static int getG1Species(int raw_id) { int[] table = { 0x00, 0x70, 0x73, 0x20, 0x23, 0x15, 0x64, 0x22, 0x50, 0x02, 0x67, 0x6C, 0x66, 0x58, 0x5E, 0x1D, 0x1F, 0x68, 0x6F, 0x83, 0x3B, 0x97, 0x82, 0x5A, 0x48, 0x5C, 0x7B, 0x78, 0x09, 0x7F, 0x72, 0x00, 0x00, 0x3A, 0x5F, 0x16, 0x10, 0x4F, 0x40, 0x4B, 0x71, 0x43, 0x7A, 0x6A, 0x6B, 0x18, 0x2F, 0x36, 0x60, 0x4C, 0x00, 0x7E, 0x00, 0x7D, 0x52, 0x6D, 0x00, 0x38, 0x56, 0x32, 0x80, 0x00, 0x00, 0x00, 0x53, 0x30, 0x95, 0x00, 0x00, 0x00, 0x54, 0x3C, 0x7C, 0x92, 0x90, 0x91, 0x84, 0x34, 0x62, 0x00, 0x00, 0x00, 0x25, 0x26, 0x19, 0x1A, 0x00, 0x00, 0x93, 0x94, 0x8C, 0x8D, 0x74, 0x75, 0x00, 0x00, 0x1B, 0x1C, 0x8A, 0x8B, 0x27, 0x28, 0x85, 0x88, 0x87, 0x86, 0x42, 0x29, 0x17, 0x2E, 0x3D, 0x3E, 0x0D, 0x0E, 0x0F, 0x00, 0x55, 0x39, 0x33, 0x31, 0x57, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x44, 0x00, 0x37, 0x61, 0x2A, 0x96, 0x8F, 0x81, 0x00, 0x00, 0x59, 0x00, 0x63, 0x5B, 0x00, 0x65, 0x24, 0x6E, 0x35, 0x69, 0x00, 0x5D, 0x3F, 0x41, 0x11, 0x12, 0x79, 0x01, 0x03, 0x49, 0x00, 0x76, 0x77, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x4E, 0x13, 0x14, 0x21, 0x1E, 0x4A, 0x89, 0x8E, 0x00, 0x51, 0x00, 0x00, 0x04, 0x07, 0x05, 0x08, 0x06, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x2C, 0x2D, 0x45, 0x46, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/PKHeX/Saves/SAV1.cs b/PKHeX/Saves/SAV1.cs index 03e99cac3..1bd0ff55c 100644 --- a/PKHeX/Saves/SAV1.cs +++ b/PKHeX/Saves/SAV1.cs @@ -327,7 +327,7 @@ public uint Coin } } - private readonly ushort[] LegalItems = PKX.getG1LegalItems().Select(i => (ushort)i).ToArray(); + private readonly ushort[] LegalItems = Legal.Pouch_Items_RBY; public override InventoryPouch[] Inventory { get diff --git a/PKHeX/Saves/SAV2.cs b/PKHeX/Saves/SAV2.cs index 2af40cf19..615aa26aa 100644 --- a/PKHeX/Saves/SAV2.cs +++ b/PKHeX/Saves/SAV2.cs @@ -31,16 +31,11 @@ public SAV2(byte[] data = null) getSAVOffsets(); - LegalItems = new ushort[] { 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, 168, 169, 170, 172, 173, 174, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189 }; - LegalBalls = new ushort[] { 1, 2, 4, 5, 157, 159, 160, 161, 164, 165, 166, 167}; - LegalKeyItems = new ushort[] {7, 54, 55, 58, 59, 61, 66, 67, 68 , 69, 71, 127, 128, 130, 133, 134, 175, 178}; - if (Version == GameVersion.C) - { - LegalKeyItems = LegalKeyItems.Concat(new ushort[] {70, 115, 116, 129}).ToArray(); - } - LegalTMHMs = 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}; - HeldItems = new ushort[] {0}.Concat(LegalItems).Concat(LegalBalls).ToArray(); - Array.Sort(HeldItems); + LegalItems = Legal.Pouch_Items_GSC; + LegalBalls = Legal.Pouch_Ball_GSC; + LegalKeyItems = Version == GameVersion.C ? Legal.Pouch_Key_C : Legal.Pouch_Key_GS; + LegalTMHMs = Legal.Pouch_TMHM_GSC; + HeldItems = Legal.HeldItems_GSC; // Stash boxes after the save file's end. byte[] TempBox = new byte[SIZE_STOREDBOX];