From 48fd36a9a2ef996ff1f9a6bc2308bea37ab613ba Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 12 Jan 2020 14:34:29 -0800 Subject: [PATCH] Handle g4 shedinja learn case too change 291/292 to Shedinja/Ninjask for easy enum reference check --- PKHeX.Core/Legality/Core.cs | 26 +++++++------------ .../Generator/EncounterMovesetGenerator.cs | 12 +++++---- .../Verifiers/VerifyCurrentMoves.cs | 11 ++++---- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/PKHeX.Core/Legality/Core.cs b/PKHeX.Core/Legality/Core.cs index 4f8214c94..6c2e22387 100644 --- a/PKHeX.Core/Legality/Core.cs +++ b/PKHeX.Core/Legality/Core.cs @@ -112,27 +112,19 @@ internal static IEnumerable GetValidRelearn(PKM pkm, int species, int form, return r.Distinct(); } - internal static int[] GetShedinjaEvolveMoves(PKM pkm, int generation, int lvl = -1) + internal static int[] GetShedinjaEvolveMoves(PKM pkm, int generation, int lvl) { - if (lvl == -1) - lvl = pkm.CurrentLevel; - if (pkm.Species != 292 || lvl < 20) + if (pkm.Species != (int)Species.Shedinja || lvl < 20) return Array.Empty(); - // If nincada evolves into Ninjask an learn in the evolution a move from ninjask learnset pool - // Shedinja would appear with that move learned. Only one move above level 20 allowed, only in generations 3 and 4 - switch (generation) + // If Nincada evolves into Ninjask and learns a move after evolution from Ninjask's LevelUp data, Shedinja would appear with that move. + // Only one move above level 20 is allowed; check the count of Ninjask moves elsewhere. + return generation switch { - case 3: // Ninjask have the same learnset in every gen 3 games - if (pkm.InhabitedGeneration(3)) - return LevelUpE[291].GetMoves(lvl, 20); - break; - case 4: // Ninjask have the same learnset in every gen 4 games - if (pkm.InhabitedGeneration(4)) - return LevelUpPt[291].GetMoves(lvl, 20); - break; - } - return Array.Empty(); + 3 when pkm.InhabitedGeneration(3) => LevelUpE[(int)Species.Ninjask].GetMoves(lvl, 20), // Same LevelUp data in all Gen3 games + 4 when pkm.InhabitedGeneration(4) => LevelUpPt[(int)Species.Ninjask].GetMoves(lvl, 20), // Same LevelUp data in all Gen4 games + _ => Array.Empty(), + }; } internal static int GetShedinjaMoveLevel(int species, int move, int generation) diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterMovesetGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterMovesetGenerator.cs index aea453733..364ff8681 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterMovesetGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterMovesetGenerator.cs @@ -143,15 +143,17 @@ private static IEnumerable GetMovesForGeneration(PKM pk, IReadOnlyList=2 special moves will get caught by the legality checker later. - var ninjask = MoveLevelUp.GetMovesLevelUp(pk, (int)Species.Ninjask, 0, 0, 100, 0, GameVersion.Any, false, 3); - moves = moves.Concat(ninjask); + if (generation == 3) + return moves.Concat(Legal.LevelUpE[(int)Species.Ninjask].GetMoves(100, 20)); + if (generation == 4) + return moves.Concat(Legal.LevelUpPt[(int)Species.Ninjask].GetMoves(100, 20)); } return moves; } diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs index b5439c3ec..57db2dcaa 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs @@ -596,7 +596,8 @@ private static void ParseShedinjaEvolveMoves(PKM pkm, IList res var ShedinjaEvoMovesLearned = new List(); for (int gen = Math.Min(pkm.Format, 4); gen >= 3; gen--) { - var ninjaskMoves = Legal.GetShedinjaEvolveMoves(pkm, gen); + var maxLevel = pkm.CurrentLevel; + var ninjaskMoves = Legal.GetShedinjaEvolveMoves(pkm, gen, maxLevel); bool native = gen == pkm.Format; for (int m = 0; m < 4; m++) { @@ -625,7 +626,7 @@ private static void ParseShedinjaEvolveMoves(PKM pkm, IList res // Double check that the Ninjask move level isn't less than any Nincada move level int move = ShedinjaEvoMovesLearned[0]; int g = res[move].Generation; - int levelJ = Legal.GetShedinjaMoveLevel(291, moves[move], g); + int levelJ = Legal.GetShedinjaMoveLevel((int)Species.Ninjask, moves[move], g); for (int m = 0; m < 4; m++) { @@ -633,13 +634,13 @@ private static void ParseShedinjaEvolveMoves(PKM pkm, IList res continue; if (res[m].Source != LevelUp) continue; - int levelS = Legal.GetShedinjaMoveLevel(292, moves[m], res[m].Generation); + int levelS = Legal.GetShedinjaMoveLevel((int)Species.Shedinja, moves[m], res[m].Generation); if (levelS > 0) continue; - int levelN = Legal.GetShedinjaMoveLevel(290, moves[m], res[m].Generation); + int levelN = Legal.GetShedinjaMoveLevel((int)Species.Nincada, moves[m], res[m].Generation); if (levelN > levelJ) - res[m] = new CheckMoveResult(res[m], Invalid, string.Format(LMoveEvoFHigher, SpeciesStrings[290], SpeciesStrings[291]), Move); + res[m] = new CheckMoveResult(res[m], Invalid, string.Format(LMoveEvoFHigher, SpeciesStrings[(int)Species.Nincada], SpeciesStrings[(int)Species.Ninjask]), Move); } }