From 86d10af78b5b5246ab807c347d4e6d958544db5f Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 16 Apr 2019 22:14:21 -0700 Subject: [PATCH] Minor clean cache Generation value, store arceus stuff as ushort --- PKHeX.Core/Legality/Core.cs | 19 ++++++++++--------- PKHeX.Core/Legality/Tables/Tables.cs | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/PKHeX.Core/Legality/Core.cs b/PKHeX.Core/Legality/Core.cs index b98ccdb5f..b218f1bd2 100644 --- a/PKHeX.Core/Legality/Core.cs +++ b/PKHeX.Core/Legality/Core.cs @@ -254,14 +254,14 @@ internal static int[] GetBaseEggMoves(PKM pkm, int species, GameVersion gameSour return Array.Empty(); } - internal static List GetValidPostEvolutionMoves(PKM pkm, int Species, IReadOnlyList[] evoChains, GameVersion Version) + internal static List GetValidPostEvolutionMoves(PKM pkm, int species, IReadOnlyList[] evoChains, GameVersion Version) { // Return moves that the pokemon could learn after evolving var moves = new List(); for (int i = 1; i < evoChains.Length; i++) { if (evoChains[i].Count != 0) - moves.AddRange(GetValidPostEvolutionMoves(pkm, Species, evoChains[i], i, Version)); + moves.AddRange(GetValidPostEvolutionMoves(pkm, species, evoChains[i], i, Version)); } if (pkm.GenNumber >= 6) @@ -269,10 +269,10 @@ internal static List GetValidPostEvolutionMoves(PKM pkm, int Species, IRead return moves.Distinct().ToList(); } - private static List GetValidPostEvolutionMoves(PKM pkm, int Species, IReadOnlyList evoChain, int Generation, GameVersion Version) + private static List GetValidPostEvolutionMoves(PKM pkm, int species, IReadOnlyList evoChain, int Generation, GameVersion Version) { var evomoves = new List(); - var index = EvolutionChain.GetEvoChainSpeciesIndex(evoChain, Species); + var index = EvolutionChain.GetEvoChainSpeciesIndex(evoChain, species); for (int i = 0; i <= index; i++) { var evo = evoChain[i]; @@ -519,18 +519,19 @@ internal static bool IsEvolutionValidWithMove(PKM pkm, LegalInfo info) { // Exclude species that do not evolve leveling with a move // Exclude gen 1-3 formats - // Exclude Mr Mime and Snorlax for gen 1-3 games - if (!SpeciesEvolutionWithMove.Contains(pkm.Species) || pkm.Format <= 3 || (BabyEvolutionWithMove.Contains(pkm.Species) && pkm.GenNumber <= 3)) + // Exclude Mr. Mime and Snorlax for gen 1-3 games + var gen = info.Generation; + if (!SpeciesEvolutionWithMove.Contains(pkm.Species) || pkm.Format <= 3 || (BabyEvolutionWithMove.Contains(pkm.Species) && gen <= 3)) return true; var index = Array.FindIndex(SpeciesEvolutionWithMove, p => p == pkm.Species); var levels = MinLevelEvolutionWithMove[index]; var moves = MoveEvolutionWithMove[index]; - var allowegg = EggMoveEvolutionWithMove[index][pkm.GenNumber]; + var allowegg = EggMoveEvolutionWithMove[index][gen]; // Get the minimum level in any generation when the pokemon could learn the evolve move var LearnLevel = 101; - for (int g = pkm.GenNumber; g <= pkm.Format; g++) + for (int g = gen; g <= pkm.Format; g++) { if (pkm.InhabitedGeneration(g) && levels[g] > 0) LearnLevel = Math.Min(LearnLevel, levels[g]); @@ -545,7 +546,7 @@ internal static bool IsEvolutionValidWithMove(PKM pkm, LegalInfo info) if (info.EncounterMatch.EggEncounter && !pkm.WasGiftEgg && !pkm.WasEventEgg && allowegg) { if (IsMoveInherited(pkm, info, moves)) - LearnLevel = Math.Min(LearnLevel, pkm.GenNumber < 4 ? 6 : 2); + LearnLevel = Math.Min(LearnLevel, gen <= 3 ? 6 : 2); } // If has original met location the minimum evolution level is one level after met level diff --git a/PKHeX.Core/Legality/Tables/Tables.cs b/PKHeX.Core/Legality/Tables/Tables.cs index 7e55b7dc6..d2fe068c2 100644 --- a/PKHeX.Core/Legality/Tables/Tables.cs +++ b/PKHeX.Core/Legality/Tables/Tables.cs @@ -308,8 +308,8 @@ public static partial class Legal 797, 798, 799, 803, 804, 805, 806, }; - public static readonly int[] Arceus_Plate = {303, 306, 304, 305, 309, 308, 310, 313, 298, 299, 301, 300, 307, 302, 311, 312, 644}; - public static readonly int[] Arceus_ZCrystal = {782, 785, 783, 784, 788, 787, 789, 792, 777, 778, 780, 779, 786, 781, 790, 791, 793}; + public static readonly ushort[] Arceus_Plate = {303, 306, 304, 305, 309, 308, 310, 313, 298, 299, 301, 300, 307, 302, 311, 312, 644}; + public static readonly ushort[] Arceus_ZCrystal = {782, 785, 783, 784, 788, 787, 789, 792, 777, 778, 780, 779, 786, 781, 790, 791, 793}; internal static readonly int[] BabyEvolutionWithMove = {