From a94c754c3ffffd5920945890b6d7c17bf46495d2 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 12 Apr 2020 11:28:03 -0700 Subject: [PATCH] More shedinja edge cases Don't allow shedinja evolution moves if it wasn't evolved in that generation --- .../Encounters/Verifiers/VerifyCurrentMoves.cs | 14 ++++++++++---- PKHeX.Core/Legality/Verifiers/BallVerifier.cs | 10 ++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs index 4ad4b1386..c5e4159a8 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs @@ -275,7 +275,7 @@ private static CheckMoveResult[] ParseMoves(PKM pkm, MoveParseSource source, Leg } if (pkm.Species == (int)Species.Shedinja && info.Generation <= 4) - ParseShedinjaEvolveMoves(pkm, res, source.CurrentMoves); + ParseShedinjaEvolveMoves(pkm, res, source.CurrentMoves, info.EvoChainsAllGens); for (int m = 0; m < 4; m++) { @@ -574,14 +574,20 @@ private static void ParseEvolutionsIncompatibleMoves(PKM pkm, IList res, int[] moves) + private static void ParseShedinjaEvolveMoves(PKM pkm, IList res, int[] moves, IReadOnlyList> evos) { var ShedinjaEvoMovesLearned = new List(); - for (int gen = Math.Min(pkm.Format, 4); gen >= 3; gen--) + var format = pkm.Format; + for (int gen = Math.Min(format, 4); gen >= 3; gen--) { + if (evos[gen].Count != 2) + continue; // Was not evolved in this generation + if (gen == 4 && pkm.Ball != 4) + continue; // Was definitively evolved in Gen3 + var maxLevel = pkm.CurrentLevel; var ninjaskMoves = Legal.GetShedinjaEvolveMoves(pkm, gen, maxLevel); - bool native = gen == pkm.Format; + bool native = gen == format; for (int m = 0; m < 4; m++) { if (IsCheckValid(res[m])) // already validated diff --git a/PKHeX.Core/Legality/Verifiers/BallVerifier.cs b/PKHeX.Core/Legality/Verifiers/BallVerifier.cs index 7de7e43f7..cbd65c165 100644 --- a/PKHeX.Core/Legality/Verifiers/BallVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/BallVerifier.cs @@ -38,8 +38,14 @@ private CheckResult VerifyBall(LegalityAnalysis data) // Capture / Inherit cases -- can be one of many balls var pkm = data.pkm; - if (pkm.Species == (int)Species.Shedinja && Info.Generation != 3 && data.EncounterMatch.Species != (int)Species.Shedinja) // Shedinja. For gen3, copy the ball from Nincada - return VerifyBallEquals(data, (int)Poke); // Pokeball Only + if (pkm.Species == (int)Species.Shedinja && data.EncounterMatch.Species != (int)Species.Shedinja) // Shedinja. For gen3, copy the ball from Nincada + { + // Only Gen3 origin Shedinja can copy the wild ball. + // Evolution chains will indicate if it could have existed as Shedinja in Gen3. + // The special move verifier has a similar check! + if (Info.Generation != 3 || Info.EvoChainsAllGens[3].Count != 2) + return VerifyBallEquals(data, (int)Poke); // Pokeball Only + } if (pkm.Ball == (int)Heavy && Legal.AlolanCaptureNoHeavyBall.Contains(EncounterMatch.Species) && !EncounterMatch.EggEncounter && pkm.SM) return GetInvalid(LBallHeavy); // Heavy Ball, can inherit if from egg (USUM fixed catch rate calc)