diff --git a/PKHeX.Core/Legality/Core.cs b/PKHeX.Core/Legality/Core.cs index 705fd62b2..95d5f6773 100644 --- a/PKHeX.Core/Legality/Core.cs +++ b/PKHeX.Core/Legality/Core.cs @@ -195,12 +195,12 @@ internal static int[] GetMinLevelLearnMove(int species, int Generation, List GetExclusivePreEvolutionMoves(PKM pkm, int Spec { var evo = evoChain[i]; var moves = GetMoves(pkm, evo.Species, 1, 1, evo.Level, pkm.AltForm, moveTutor: true, Version: Version, LVL: true, specialTutors: true, Machine: true, MoveReminder: true, RemoveTransferHM: false, Generation: Generation); - if (i >= index) - // Moves from Species or any species bellow in the evolution phase - preevomoves.AddRange(moves); - else - // Moves in phase evolutions after the limit species, this moves should be removed - evomoves.AddRange(moves); + var list = i >= index ? preevomoves : evomoves; + list.AddRange(moves); } - preevomoves.RemoveAll(x => evomoves.Contains(x)); - return preevomoves.Distinct().ToList(); + return preevomoves.Where(z => !evomoves.Contains(z)).Distinct().ToList(); } // Encounter - internal static GameVersion[] GetGen2Versions(LegalInfo Info) + internal static IEnumerable GetGen2Versions(LegalInfo Info) { if (AllowGen2Crystal && Info.Game == GameVersion.C) - return new[] { GameVersion.C }; + yield return GameVersion.C; + // Any encounter marked with version GSC is for pokemon with the same moves in g/s and Crystal, it is enought to check only g/s moves - return new[] { GameVersion.GS }; + yield return GameVersion.GS; } - internal static GameVersion[] GetGen1Versions(LegalInfo Info) + internal static IEnumerable GetGen1Versions(LegalInfo Info) { if (Info.EncounterMatch.Species == 133 && Info.Game == GameVersion.Stadium) - // Staidum eevee, check for red/blue and yellow initial moves - return new[] { GameVersion.RB, GameVersion.YW }; + { + // Stadium Eevee; check for RB and yellow initial moves + yield return GameVersion.RB; + yield return GameVersion.YW; + } if (Info.Game == GameVersion.YW) - return new[] { GameVersion.YW }; + yield return GameVersion.YW; + // Any encounter marked with version RBY is for pokemon with the same moves and catch rate in red/blue and yellow, it is enought to check only red/blue moves - return new[] { GameVersion.RB }; + yield return GameVersion.RB; } internal static IEnumerable GetInitialMovesGBEncounter(int species, int lvl, GameVersion ver) { diff --git a/PKHeX.Core/Legality/Encounters/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/VerifyCurrentMoves.cs index 1b4f90ecc..7f4d000df 100644 --- a/PKHeX.Core/Legality/Encounters/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/VerifyCurrentMoves.cs @@ -43,8 +43,9 @@ private static CheckMoveResult[] ParseMovesForEncounters(PKM pkm, LegalInfo info { // Generation 1 can have different minimum level in different encounter of the same species; update valid level moves UptateGen1LevelUpMoves(pkm, info.EncounterMoves, info.EncounterMoves.MinimumLevelGen1, EncounterMatchGen.Generation, info); - if(!Legal.AllowGen2MoveReminder && pkm.InhabitedGeneration(2)) - // The same for Generation 2 if move reminder from Stadium 2 is not allowed + + // The same for Generation 2; if move reminder from Stadium 2 is not allowed + if (!Legal.AllowGen2MoveReminder && pkm.InhabitedGeneration(2)) UptateGen2LevelUpMoves(pkm, info.EncounterMoves, info.EncounterMoves.MinimumLevelGen2, EncounterMatchGen.Generation, info); } @@ -144,13 +145,13 @@ private static CheckMoveResult[] ParseMovesPre3DS(PKM pkm, int[] Moves, LegalInf } private static CheckMoveResult[] ParseMovesGenGB(PKM pkm, int[] Moves, LegalInfo info) { - GameVersion[] games = (info.EncounterMatch as IGeneration)?.Generation == 1 ? Legal.GetGen1Versions(info) : Legal.GetGen2Versions(info); CheckMoveResult[] res = new CheckMoveResult[4]; var G1Encounter = info.EncounterMatch; if (G1Encounter == null) return ParseMovesSpecialMoveset(pkm, Moves, info); var InitialMoves = new int[0]; int[] SpecialMoves = GetSpecialMoves(info.EncounterMatch); + IEnumerable games = (info.EncounterMatch as IGeneration)?.Generation == 1 ? Legal.GetGen1Versions(info) : Legal.GetGen2Versions(info); foreach (GameVersion ver in games) { var VerInitialMoves = Legal.GetInitialMovesGBEncounter(G1Encounter.Species, G1Encounter.LevelMin, ver).ToArray(); @@ -587,7 +588,7 @@ private static void ParseEvolutionLevelupMove(PKM pkm, IList re return; var ValidMoves = Legal.GetValidPostEvolutionMoves(pkm, pkm.Species, info.EvoChainsAllGens, GameVersion.Any); - // Add the evolution moves to valid moves in case some of this moves could not be learned after evolving + // Add the evolution moves to valid moves in case some of these moves could not be learned after evolving switch (pkm.Species) { case 122: // Mr. Mime (Mime Jr with Mimic)