From 3816d25f7b362761052673ec3a2f9f0b1b5e2f5f Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 12 Jan 2021 22:38:18 -0800 Subject: [PATCH] Condense some expressions Simplify legal held item array creation, reduce linq usage in startup Discard unreleased item array references; no need to retain after startup --- PKHeX.Core/Legality/Tables/Tables.cs | 118 ++++++++++++++----------- PKHeX.Core/Legality/Tables/Tables1.cs | 10 ++- PKHeX.Core/Legality/Tables/Tables2.cs | 12 +-- PKHeX.Core/Legality/Tables/Tables3.cs | 50 +++-------- PKHeX.Core/Legality/Tables/Tables4.cs | 47 +++++----- PKHeX.Core/Legality/Tables/Tables5.cs | 7 +- PKHeX.Core/Legality/Tables/Tables6.cs | 11 +-- PKHeX.Core/Legality/Tables/Tables7.cs | 19 ++-- PKHeX.Core/Legality/Tables/Tables7b.cs | 3 +- PKHeX.Core/Legality/Tables/Tables8.cs | 10 +-- 10 files changed, 130 insertions(+), 157 deletions(-) diff --git a/PKHeX.Core/Legality/Tables/Tables.cs b/PKHeX.Core/Legality/Tables/Tables.cs index 9ed260450..8c2367365 100644 --- a/PKHeX.Core/Legality/Tables/Tables.cs +++ b/PKHeX.Core/Legality/Tables/Tables.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using static PKHeX.Core.Species; +using static PKHeX.Core.Move; namespace PKHeX.Core { @@ -26,61 +27,54 @@ namespace PKHeX.Core /// public static readonly HashSet BattleFrontierBanlist = new() { - 150, // Mewtwo - 151, // Mew - - 249, // Lugia - 250, // Ho-Oh - 251, // Celebi - - 382, // Kyogre - 383, // Groudon - 384, // Rayquaza - 385, // Jirachi - 386, // Deoxys - - 483, // Dialga - 484, // Palkia - 487, // Giratina - 489, // Phione - 490, // Manaphy - 491, // Darkrai - 492, // Shaymin - 493, // Arceus - - 494, // Victini - 643, // Reshiram - 644, // Zekrom - 646, // Kyurem - 647, // Keldeo - 648, // Meloetta - 649, // Genesect - - 716, // Xerneas - 717, // Yveltal - 718, // Zygarde - 719, // Diancie - 720, // Hoopa - 721, // Volcanion - - 789, // Cosmog - 790, // Cosmoem - 791, // Solgaleo - 792, // Lunala - 800, // Necrozma - 801, // Magearna - 802, // Marshadow - 807, // Zeraora - 808, // Meltan - 809, // Melmetal + (int)Mewtwo, (int)Mew, + (int)Lugia, (int)HoOh, (int)Celebi, + (int)Kyogre, (int)Groudon, (int)Rayquaza, (int)Jirachi, (int)Deoxys, + (int)Dialga, (int)Palkia, (int)Giratina, (int)Phione, (int)Manaphy, (int)Darkrai, (int)Shaymin, (int)Arceus, + (int)Victini, (int)Reshiram, (int)Zekrom, (int)Kyurem, (int)Keldeo, (int)Meloetta, (int)Genesect, + (int)Xerneas, (int)Yveltal, (int)Zygarde, (int)Diancie, (int)Hoopa, (int)Volcanion, + (int)Cosmog, (int)Cosmoem, (int)Solgaleo, (int)Lunala, (int)Necrozma, (int)Magearna, (int)Marshadow, (int)Zeraora, + (int)Meltan, (int)Melmetal, }; public static readonly HashSet Z_Moves = new() { - 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, - 695, 696, 697, 698, 699, 700, 701, 702, 703, - 719, - 723, 724, 725, 726, 727, 728 + (int)BreakneckBlitzP, (int)BreakneckBlitzS, + (int)AllOutPummelingP, (int)AllOutPummelingS, + (int)SupersonicSkystrikeP, (int)SupersonicSkystrikeS, + (int)AcidDownpourP, (int)AcidDownpourS, + (int)TectonicRageP, (int)TectonicRageS, + (int)ContinentalCrushP, (int)ContinentalCrushS, + (int)SavageSpinOutP, (int)SavageSpinOutS, + (int)NeverEndingNightmareP, (int)NeverEndingNightmareS, + (int)CorkscrewCrashP, (int)CorkscrewCrashS, + (int)InfernoOverdriveP, (int)InfernoOverdriveS, + (int)HydroVortexP, (int)HydroVortexS, + (int)BloomDoomP, (int)BloomDoomS, + (int)GigavoltHavocP, (int)GigavoltHavocS, + (int)ShatteredPsycheP, (int)ShatteredPsycheS, + (int)SubzeroSlammerP, (int)SubzeroSlammerS, + (int)DevastatingDrakeP, (int)DevastatingDrakeS, + (int)BlackHoleEclipseP, (int)BlackHoleEclipseS, + (int)TwinkleTackleP, (int)TwinkleTackleS, + + (int)Catastropika, + (int)SinisterArrowRaid, + (int)MaliciousMoonsault, + (int)OceanicOperetta, + (int)GuardianofAlola, + (int)SoulStealing7StarStrike, + (int)StokedSparksurfer, + (int)PulverizingPancake, + (int)ExtremeEvoboost, + (int)GenesisSupernova, + (int)TenMVoltThunderbolt, + (int)LightThatBurnstheSky, + (int)SearingSunrazeSmash, + (int)MenacingMoonrazeMaelstrom, + (int)LetsSnuggleForever, + (int)SplinteredStormshards, + (int)ClangorousSoulblaze, }; /// @@ -89,11 +83,11 @@ namespace PKHeX.Core internal static readonly HashSet InvalidSketch = new(Z_Moves) { // Can't Sketch - 165, // Struggle - 448, // Chatter + (int)Struggle, + (int)Chatter, // Unreleased - 617, // Light of Ruin + (int)LightofRuin, }; /// @@ -149,5 +143,21 @@ namespace PKHeX.Core (int)Espurr, (int)Meowstic, // (M/F) form specific }; + + private static bool[] GetPermitList(int max, IEnumerable held) + { + var result = new bool[max + 1]; + foreach (var item in held) + result[item] = true; + return result; + } + + private static bool[] GetPermitList(int max, IEnumerable held, IEnumerable unreleased) + { + var result = GetPermitList(max, held); + foreach (var u in unreleased) + result[u] = false; + return result; + } } } diff --git a/PKHeX.Core/Legality/Tables/Tables1.cs b/PKHeX.Core/Legality/Tables/Tables1.cs index 472d6e395..4846b19bb 100644 --- a/PKHeX.Core/Legality/Tables/Tables1.cs +++ b/PKHeX.Core/Legality/Tables/Tables1.cs @@ -1,4 +1,6 @@ -namespace PKHeX.Core +using static PKHeX.Core.Species; + +namespace PKHeX.Core { public static partial class Legal { @@ -38,9 +40,9 @@ internal static bool TransferSpeciesDefaultAbilityGen1(int species) { System.Diagnostics.Debug.Assert((uint)species <= MaxSpeciesID_1); - return species is (int)Species.Gastly or (int)Species.Haunter or (int)Species.Gengar - or (int)Species.Koffing or (int)Species.Weezing - or (int)Species.Mew; + return species is (int)Gastly or (int)Haunter or (int)Gengar + or (int)Koffing or (int)Weezing + or (int)Mew; } internal static readonly int[] TMHM_RBY = diff --git a/PKHeX.Core/Legality/Tables/Tables2.cs b/PKHeX.Core/Legality/Tables/Tables2.cs index e02407637..40098e3c2 100644 --- a/PKHeX.Core/Legality/Tables/Tables2.cs +++ b/PKHeX.Core/Legality/Tables/Tables2.cs @@ -1,4 +1,4 @@ -using System.Linq; +using static PKHeX.Core.Species; namespace PKHeX.Core { @@ -53,15 +53,15 @@ namespace PKHeX.Core internal static readonly int[] Tutors_GSC = {53, 85, 58}; // Flamethrower, Thunderbolt & Ice Beam - internal static readonly bool[] ReleasedHeldItems_2 = Enumerable.Range(0, MaxItemID_2+1).Select(i => HeldItems_GSC.Contains((ushort)i)).ToArray(); + internal static readonly bool[] ReleasedHeldItems_2 = GetPermitList(MaxItemID_2, HeldItems_GSC); internal static bool TransferSpeciesDefaultAbilityGen2(int species) { System.Diagnostics.Debug.Assert((uint)species <= MaxSpeciesID_2); - return species is (int)Species.Gastly or (int)Species.Haunter or (int)Species.Gengar - or (int)Species.Koffing or (int)Species.Weezing - or (int)Species.Misdreavus or (int)Species.Unown - or (int)Species.Mew or (int)Species.Celebi; + return species is (int)Gastly or (int)Haunter or (int)Gengar + or (int)Koffing or (int)Weezing + or (int)Misdreavus or (int)Unown + or (int)Mew or (int)Celebi; } } } diff --git a/PKHeX.Core/Legality/Tables/Tables3.cs b/PKHeX.Core/Legality/Tables/Tables3.cs index 76ca116eb..4e317ce53 100644 --- a/PKHeX.Core/Legality/Tables/Tables3.cs +++ b/PKHeX.Core/Legality/Tables/Tables3.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; namespace PKHeX.Core { @@ -40,10 +39,10 @@ namespace PKHeX.Core 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; - internal static readonly ushort[] Pouch_Key_FRLG = Pouch_Key_RS.Concat(new 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 }).ToArray(); - internal static readonly ushort[] Pouch_Key_E = Pouch_Key_FRLG.Concat(new ushort[] { 375, 376 }).ToArray(); + internal static readonly ushort[] Pouch_Key_FRLG = ArrayUtil.ConcatAll(Pouch_Key_RS, new 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, new ushort[] { 375, 376 }); - internal static readonly ushort[] Pouch_TMHM_RS = Pouch_TM_RS.Concat(Pouch_HM_RS).ToArray(); + 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); #endregion @@ -61,7 +60,7 @@ namespace PKHeX.Core }; internal static readonly ushort[] Pouch_Cologne_COLO = {543, 544, 545}; - internal static readonly ushort[] Pouch_Items_COLO = Pouch_Items_RS.Concat(new ushort[] {537}).ToArray(); // Time Flute + internal static readonly ushort[] Pouch_Items_COLO = ArrayUtil.ConcatAll(Pouch_Items_RS, new 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 = @@ -74,7 +73,7 @@ namespace PKHeX.Core }; internal static readonly ushort[] Pouch_Cologne_XD = {513, 514, 515}; - internal static readonly ushort[] Pouch_Items_XD = Pouch_Items_RS.Concat(new ushort[] {511}).ToArray(); // Poké Snack + internal static readonly ushort[] Pouch_Items_XD = ArrayUtil.ConcatAll(Pouch_Items_RS, new 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 = @@ -96,12 +95,7 @@ namespace PKHeX.Core 590, 591, 592, 593 }; - internal static readonly int[] UnreleasedItems_3 = - { - 005, // Safari Ball - }; - - internal static readonly bool[] ReleasedHeldItems_3 = Enumerable.Range(0, MaxItemID_3+1).Select(i => HeldItems_RS.Contains((ushort)i) && !UnreleasedItems_3.Contains(i)).ToArray(); + internal static readonly bool[] ReleasedHeldItems_3 = GetPermitList(MaxItemID_3, HeldItems_RS, new ushort[] {005}); // Safari Ball internal static readonly HashSet EReaderBerriesNames_USA = new() { @@ -143,22 +137,15 @@ namespace PKHeX.Core }; internal static readonly HashSet HM_3 = new() { 15, 19, 57, 70, 148, 249, 127, 291}; - internal static readonly int[] TypeTutor3 = {338, 307, 308}; internal static readonly int[] Tutor_3Mew = { - 185, // Feint Attack - 252, // Fake Out - 095, // Hypnosis - 101, // Night Shade - 272, // Role Play - 192, // Zap Cannon - }; - - internal static readonly int[][] Tutor_Frontier = - { - new[] {135, 069, 138, 005, 025, 034, 157, 068, 086, 014}, - new[] {111, 173, 189, 129, 196, 203, 244, 008, 009, 007}, + (int)Move.FeintAttack, + (int)Move.FakeOut, + (int)Move.Hypnosis, + (int)Move.NightShade, + (int)Move.RolePlay, + (int)Move.ZapCannon, }; internal static readonly int[] Tutor_E = @@ -181,20 +168,11 @@ namespace PKHeX.Core internal static readonly int[] SpecialTutors_Compatibility_FRLG = { 6, 9, 3 }; - // Tutor moves from XD that can be learned as tutor moves in emerald - // For this moves compatibility data is the same in XD and Emerald - internal static readonly int[] SpecialTutors_XD_Emerald = - { - 034, 038, 069, 086, 102, 120, 138, 143, 164, 171, 196, 207, - }; - internal static readonly int[] SpecialTutors_XD_Exclusive = { 120, 143, 171 }; - internal static readonly int[] SpecialTutors_XD = SpecialTutors_XD_Emerald.Concat(SpecialTutors_XD_Exclusive).ToArray(); - internal static readonly int[][] SpecialTutors_Compatibility_XD_Exclusive = { new[] { 074, 075, 076, 088, 089, 090, 091, 092, 093, 094, 095, @@ -252,10 +230,10 @@ namespace PKHeX.Core 187, 188, 189, 190, 191, 192, 193, 194, 195, 196 }; - internal static readonly HashSet ValidMet_E = new(ValidMet_RS.Concat(new[] + internal static readonly HashSet ValidMet_E = new(ValidMet_RS) { 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - })); + }; /// /// Species ID that can be originated from Colosseum (using only Generation 3 max Species ID values). diff --git a/PKHeX.Core/Legality/Tables/Tables4.cs b/PKHeX.Core/Legality/Tables/Tables4.cs index 1073a7d52..90724bb78 100644 --- a/PKHeX.Core/Legality/Tables/Tables4.cs +++ b/PKHeX.Core/Legality/Tables/Tables4.cs @@ -77,7 +77,7 @@ namespace PKHeX.Core 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.Take(Pouch_TMHM_DP.Length - 8).ToArray()); + 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 @@ -96,7 +96,7 @@ namespace PKHeX.Core 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.Take(Pouch_TMHM_Pt.Length - 8).ToArray()); + 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 @@ -117,7 +117,7 @@ namespace PKHeX.Core 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.Take(Pouch_TMHM_HGSS.Length - 8).ToArray()); + 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 int[] TM_4 = @@ -134,21 +134,23 @@ namespace PKHeX.Core 430, 433, }; - internal static readonly HashSet HM_HGSS = new() - { - 015, 019, 057, 070, 250, 249, 127, 431 // Whirlpool(HGSS) - }; - - internal static readonly HashSet HM_DPPt = new() - { - 015, 019, 057, 070, 432, 249, 127, 431 // Defog(DPPt) - }; - internal static readonly HashSet HM_4_RemovePokeTransfer = new() { - 015, 019, 057, 070, 249, 127, 431 // Defog(DPPt) & Whirlpool(HGSS) excluded + (int)Move.Cut, + (int)Move.Fly, + (int)Move.Surf, + (int)Move.Strength, + (int)Move.RockSmash, + (int)Move.Waterfall, + (int)Move.RockClimb, + + // Exclude Defog and Whirlpool; check separately. + // Defog (DPPt) excluded since it's actually useful -- prefer to fake transfer from HGSS instead of DPPt. }; + internal static readonly HashSet HM_DPPt = new(HM_4_RemovePokeTransfer) {(int)Move.Defog}; + internal static readonly HashSet HM_HGSS = new(HM_4_RemovePokeTransfer) {(int)Move.Whirlpool}; + internal static readonly byte[] MovePP_DP = { 00, @@ -164,16 +166,14 @@ namespace PKHeX.Core 10, 15, 20, 15, 10, 10, 05, 10, 05, 05, 10, 05, 05, 10, 05, 05, 05, }; - internal static readonly HashSet UnreleasedItems_4 = new() + internal static readonly bool[] ReleasedHeldItems_4 = GetPermitList(MaxItemID_4_HGSS, HeldItems_HGSS, new ushort[] { 005, // Safari Ball 016, // Cherish Ball 147, // Mosaic Mail 499, // Sport Ball 500, // Park Ball - }; - - internal static readonly bool[] ReleasedHeldItems_4 = Enumerable.Range(0, MaxItemID_4_HGSS+1).Select(i => HeldItems_HGSS.Contains((ushort)i) && !UnreleasedItems_4.Contains(i)).ToArray(); + }); internal static readonly int[] Tutors_4 = { @@ -199,13 +199,6 @@ namespace PKHeX.Core new[] { 147, 148, 149, 230, 329, 330, 334, 371, 372, 373, 380, 381, 384, 443, 444, 445, 483, 484, 487 } }; - // Encounter Slots that are replaced - internal static readonly int[] Slot4_Swarm = { 0, 1 }; - internal static readonly int[] Slot4_Time = { 2, 3 }; - internal static readonly int[] Slot4_Sound = { 2, 3, 4, 5 }; - internal static readonly int[] Slot4_Radar = { 4, 5, 10, 11 }; - internal static readonly int[] Slot4_Dual = { 8, 9 }; - internal static readonly HashSet ValidMet_DP = new() { // 063: Flower Paradise unreleased DP event @@ -220,10 +213,10 @@ namespace PKHeX.Core 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, }; - internal static readonly HashSet ValidMet_Pt = new(ValidMet_DP.Concat(new[] + internal static readonly HashSet ValidMet_Pt = new(ValidMet_DP) { 63, 79, 85, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, - })); + }; internal static readonly HashSet ValidMet_HGSS = new() { diff --git a/PKHeX.Core/Legality/Tables/Tables5.cs b/PKHeX.Core/Legality/Tables/Tables5.cs index 608ac6bae..bf95e7721 100644 --- a/PKHeX.Core/Legality/Tables/Tables5.cs +++ b/PKHeX.Core/Legality/Tables/Tables5.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; namespace PKHeX.Core { @@ -103,7 +102,7 @@ namespace PKHeX.Core 05, 10, 05, 05, 15, 10, 05, 05, 05, }; - internal static readonly HashSet UnreleasedItems_5 = new() + internal static readonly bool[] ReleasedHeldItems_5 = GetPermitList(MaxItemID_5_B2W2, HeldItems_BW, new ushort[] { 005, // Safari Ball 016, // Cherish Ball @@ -122,9 +121,7 @@ namespace PKHeX.Core 499, // Sport Ball 500, // Park Ball 576, // Dream Ball - }; - - internal static readonly bool[] ReleasedHeldItems_5 = Enumerable.Range(0, MaxItemID_5_B2W2 + 1).Select(i => HeldItems_BW.Contains((ushort)i) && !UnreleasedItems_5.Contains(i)).ToArray(); + }); internal static readonly int[][] Tutors_B2W2 = { diff --git a/PKHeX.Core/Legality/Tables/Tables6.cs b/PKHeX.Core/Legality/Tables/Tables6.cs index 9ee8b1fff..32a5b917f 100644 --- a/PKHeX.Core/Legality/Tables/Tables6.cs +++ b/PKHeX.Core/Legality/Tables/Tables6.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; namespace PKHeX.Core { @@ -176,8 +175,8 @@ namespace PKHeX.Core 208, 209, 210, 211, 212, 686, 687, 688, }; - internal static readonly ushort[] HeldItem_XY = new ushort[1].Concat(Pouch_Items_XY).Concat(Pouch_Medicine_XY).Concat(Pouch_Berry_XY).ToArray(); - internal static readonly ushort[] HeldItem_AO = new ushort[1].Concat(Pouch_Items_AO).Concat(Pouch_Medicine_AO).Concat(Pouch_Berry_XY).ToArray(); + internal static readonly ushort[] HeldItem_XY = ArrayUtil.ConcatAll(new ushort[1], Pouch_Items_XY, Pouch_Medicine_XY, Pouch_Berry_XY); + internal static readonly ushort[] HeldItem_AO = ArrayUtil.ConcatAll(new ushort[1], Pouch_Items_AO, Pouch_Medicine_AO, Pouch_Berry_XY); #endregion #region TMHM @@ -294,7 +293,7 @@ namespace PKHeX.Core 10, 20, 30, 10, 10, 40, 40, 30, 20, 40, 20, 20, 10, 10, 10, 10, 05, 10, 10, 05, 05, }; - internal static readonly int[] UnreleasedItems_6 = + internal static readonly bool[] ReleasedHeldItems_6 = GetPermitList(MaxItemID_6_AO, HeldItem_AO, new ushort[] { 005, // Safari Ball 016, // Cherish Ball @@ -331,8 +330,6 @@ namespace PKHeX.Core 589, // Relic Statue 590, // Relic Crown 715, // Fairy Gem - }; - - internal static readonly bool[] ReleasedHeldItems_6 = Enumerable.Range(0, MaxItemID_6_AO+1).Select(i => HeldItem_AO.Contains((ushort)i) && !UnreleasedItems_6.Contains(i)).ToArray(); + }); } } diff --git a/PKHeX.Core/Legality/Tables/Tables7.cs b/PKHeX.Core/Legality/Tables/Tables7.cs index c230002a5..97f442a41 100644 --- a/PKHeX.Core/Legality/Tables/Tables7.cs +++ b/PKHeX.Core/Legality/Tables/Tables7.cs @@ -92,7 +92,7 @@ namespace PKHeX.Core 846, }; - internal static readonly ushort[] Pouch_Items_SM = Pouch_Regular_SM.Concat(Pouch_Ball_SM).Concat(Pouch_Battle_SM).ToArray(); + 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, @@ -100,10 +100,10 @@ namespace PKHeX.Core 841, 842, 843, 845, 847, 850, 857, 858, 860, }; - internal static readonly ushort[] Pouch_Key_USUM = Pouch_Key_SM.Concat(new ushort[] { + internal static readonly ushort[] Pouch_Key_USUM = ArrayUtil.ConcatAll(Pouch_Key_SM, new ushort[] { 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 440, - }).ToArray(); + }); public static readonly ushort[] Pouch_Roto_USUM = { 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959 @@ -137,13 +137,13 @@ namespace PKHeX.Core 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 = Pouch_ZCrystal_SM.Concat(new ushort[] { // Bead + internal static readonly ushort[] Pouch_ZCrystal_USUM = ArrayUtil.ConcatAll(Pouch_ZCrystal_SM, new ushort[] { // Bead 927, 928, 929, 930, 931, 932 - }).ToArray(); + }); - internal static readonly ushort[] Pouch_ZCrystalHeld_USUM = Pouch_ZCrystalHeld_SM.Concat(new ushort[] { // Piece + internal static readonly ushort[] Pouch_ZCrystalHeld_USUM = ArrayUtil.ConcatAll(Pouch_ZCrystalHeld_SM, new ushort[] { // Piece 921, 922, 923, 924, 925, 926 - }).ToArray(); + }); public static readonly Dictionary ZCrystalDictionary = Pouch_ZCrystal_USUM .Zip(Pouch_ZCrystalHeld_USUM, (k, v) => new KeyValuePair(k, v)) @@ -323,7 +323,7 @@ namespace PKHeX.Core }; #region Unreleased Items - internal static readonly HashSet UnreleasedHeldItems_7 = new() + internal static readonly bool[] ReleasedHeldItems_7 = GetPermitList(MaxItemID_7_USUM, HeldItems_USUM, new ushort[] { 005, // Safari Ball 016, // Cherish Ball @@ -386,8 +386,7 @@ namespace PKHeX.Core 590, // Relic Crown 699, // Discount Coupon 715, // Fairy Gem - }; + }); #endregion - internal static readonly bool[] ReleasedHeldItems_7 = Enumerable.Range(0, MaxItemID_7_USUM+1).Select(i => HeldItems_USUM.Contains((ushort)i) && !UnreleasedHeldItems_7.Contains(i)).ToArray(); } } diff --git a/PKHeX.Core/Legality/Tables/Tables7b.cs b/PKHeX.Core/Legality/Tables/Tables7b.cs index c9373136c..a17104a22 100644 --- a/PKHeX.Core/Legality/Tables/Tables7b.cs +++ b/PKHeX.Core/Legality/Tables/Tables7b.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; namespace PKHeX.Core { @@ -73,7 +72,7 @@ namespace PKHeX.Core 1057, }; - internal static readonly ushort[] Pouch_Candy_GG = Pouch_Candy_GG_Regular.Concat(Pouch_Candy_GG_Species).ToArray(); + internal static readonly ushort[] Pouch_Candy_GG = ArrayUtil.ConcatAll(Pouch_Candy_GG_Regular, Pouch_Candy_GG_Species); internal static readonly ushort[] Pouch_Medicine_GG = { diff --git a/PKHeX.Core/Legality/Tables/Tables8.cs b/PKHeX.Core/Legality/Tables/Tables8.cs index 9598cdbcb..09d26a03f 100644 --- a/PKHeX.Core/Legality/Tables/Tables8.cs +++ b/PKHeX.Core/Legality/Tables/Tables8.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; namespace PKHeX.Core { @@ -136,7 +135,7 @@ namespace PKHeX.Core 055, 056, 057, 058, 059, 060, 061, 062, 063, 1580 }; - internal static readonly ushort[] Pouch_Items_SWSH = Pouch_Regular_SWSH.Concat(Pouch_Ball_SWSH).Concat(Pouch_Battle_SWSH).ToArray(); + 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 = { @@ -181,7 +180,7 @@ namespace PKHeX.Core 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, }; - internal static readonly ushort[] Pouch_TMHM_SWSH = TM_SWSH.Concat(TR_SWSH).ToArray(); + internal static readonly ushort[] Pouch_TMHM_SWSH = ArrayUtil.ConcatAll(TM_SWSH, TR_SWSH); internal static readonly ushort[] Pouch_Medicine_SWSH = { @@ -347,7 +346,7 @@ namespace PKHeX.Core }; #region Unreleased Items - internal static readonly HashSet UnreleasedHeldItems_8 = new() + internal static readonly bool[] ReleasedHeldItems_8 = GetPermitList(MaxItemID_8, HeldItems_SWSH, new ushort[] { 298, // Flame Plate 299, // Splash Plate @@ -670,9 +669,8 @@ namespace PKHeX.Core 016, // Cherish Ball 500, // Park Ball - }; + }); #endregion - internal static readonly bool[] ReleasedHeldItems_8 = Enumerable.Range(0, MaxItemID_8+1).Select(i => HeldItems_SWSH.Contains((ushort)i) && !UnreleasedHeldItems_8.Contains(i)).ToArray(); /// /// Moves that are kill