diff --git a/PKHeX.Core/Legality/BulkAnalysis.cs b/PKHeX.Core/Legality/BulkAnalysis.cs index 3e4c1f633..9dfcab5ab 100644 --- a/PKHeX.Core/Legality/BulkAnalysis.cs +++ b/PKHeX.Core/Legality/BulkAnalysis.cs @@ -92,7 +92,7 @@ private void CheckClones() else Trackers.Add(tracker, cp); } - else if (cp.GenNumber < 8) + else if (ca.Info.Generation < 8) { AddLine(cp, "Missing tracker.", Encounter); } diff --git a/PKHeX.Core/Legality/Core.cs b/PKHeX.Core/Legality/Core.cs index 76470dba0..419ed408d 100644 --- a/PKHeX.Core/Legality/Core.cs +++ b/PKHeX.Core/Legality/Core.cs @@ -337,17 +337,17 @@ public static IReadOnlyList GetPPTable(int format) }; } - internal static ICollection GetWildBalls(PKM pkm) + internal static ICollection GetWildBalls(int gen, GameVersion game) { - return pkm.GenNumber switch + return gen switch { 1 => WildPokeBalls1, 2 => WildPokeBalls2, 3 => WildPokeBalls3, - 4 => (pkm.HGSS ? WildPokeBalls4_HGSS : WildPokeBalls4_DPPt), + 4 => GameVersion.HGSS.Contains(game) ? WildPokeBalls4_HGSS : WildPokeBalls4_DPPt, 5 => WildPokeBalls5, 6 => WildPokeballs6, - 7 => (pkm.GG ? WildPokeballs7b : WildPokeballs7), + 7 => GameVersion.GG.Contains(game) ? WildPokeballs7b : WildPokeballs7, 8 => WildPokeballs8, _ => Array.Empty() }; diff --git a/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterEgg.cs b/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterEgg.cs index 8af0aace9..ed0fa1315 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterEgg.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterEgg.cs @@ -28,18 +28,12 @@ public EncounterEgg(int species, int form, int level, int gen, GameVersion game) Version = game; } - public PKM ConvertToPKM(ITrainerInfo SAV) => ConvertToPKM(SAV, EncounterCriteria.Unrestricted); public PKM ConvertToPKM(ITrainerInfo SAV, EncounterCriteria criteria) { - int gen = Version.GetGeneration(); + int gen = Generation; var version = Version; - if (gen < 2) - { - gen = 2; - version = GameVersion.C; - } var pk = PKMConverter.GetBlank(gen, version); SAV.ApplyToPKM(pk); @@ -48,26 +42,26 @@ public PKM ConvertToPKM(ITrainerInfo SAV, EncounterCriteria criteria) pk.Nickname = SpeciesName.GetSpeciesNameGeneration(Species, SAV.Language, gen); pk.CurrentLevel = Level; pk.Version = (int)version; - pk.Ball = 4; + pk.Ball = (int)Ball.Poke; pk.OT_Friendship = pk.PersonalInfo.BaseFriendship; int[] moves = SetEncounterMoves(pk, version); SetPINGA(pk, criteria); - if (pk.Format <= 2 && version != GameVersion.C) + if (gen <= 2 && version != GameVersion.C) return pk; SetMetData(pk); - if (pk.Format < 3) + if (gen < 3) return pk; - if (pk.GenNumber >= 4) + if (gen >= 4) pk.SetEggMetData(version, (GameVersion)SAV.Game); - if (pk.Format < 6) + if (gen < 6) return pk; - if (pk.Format == 6) + if (gen == 6) pk.SetHatchMemory6(); SetAltForm(pk, SAV); diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs b/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs index 052f0ab83..ab5036050 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs @@ -44,20 +44,23 @@ private static List[] GetChainAll(PKM pkm, IEncounterable Encounter int lvl = pkm.CurrentLevel; int maxLevel = lvl; - int pkGen = pkm.GenNumber; + int pkGen = Encounter.Generation; // Iterate generations backwards // Maximum level of an earlier generation (GenX) will never be greater than a later generation (GenX+Y). - int mingen = (pkm is PK2 || pkm.VC2) && !pkm.Gen2_NotTradeback ? 1 : pkGen; + int mingen = pkGen >= 3 ? pkGen : pkm.Gen2_NotTradeback ? 2 : 1; bool noxfrDecremented = true; for (int g = GensEvoChains.Length - 1; g >= mingen; g--) { - if (pkGen == 1 && pkm.Gen1_NotTradeback && g == 2) - continue; - if (pkGen <= 2 && 3 <= g && g <= 6) - continue; + if (pkGen <= 2) + { + if (3 <= g && g <= 6) + continue; + if (g == 2 && pkm.Gen1_NotTradeback) + continue; + } - if (g <= 4 && 2 < pkm.Format && g < pkm.Format && !pkm.HasOriginalMetLocation && lvl > pkm.Met_Level) + if (g <= 4 && pkm.Format > 2 && pkm.Format > g && !pkm.HasOriginalMetLocation && lvl > pkm.Met_Level) { // Met location was lost at this point but it also means the pokemon existed in generations 1 to 4 with maximum level equals to met level lvl = pkm.Met_Level; diff --git a/PKHeX.Core/Legality/Verifiers/BallVerifier.cs b/PKHeX.Core/Legality/Verifiers/BallVerifier.cs index cbd65c165..76dd3b830 100644 --- a/PKHeX.Core/Legality/Verifiers/BallVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/BallVerifier.cs @@ -71,7 +71,7 @@ private CheckResult VerifyBallStatic(LegalityAnalysis data, EncounterStatic s) { if (s.Location == 75 && s.Generation == 5) // Entree Forest (Dream World) return VerifyBallEquals(data, Legal.DreamWorldBalls); - return VerifyBallEquals(data, Legal.GetWildBalls(data.pkm)); + return VerifyBallEquals(data, Legal.GetWildBalls(data.Info.Generation, data.Info.Game)); } private CheckResult VerifyBallWild(LegalityAnalysis data, EncounterSlot w) @@ -88,7 +88,7 @@ private CheckResult VerifyBallWild(LegalityAnalysis data, EncounterSlot w) return VerifyBallEquals(data, (int)Safari); // Safari Ball if (Info.Generation == 4 && w.Type == SlotType.BugContest) return VerifyBallEquals(data, (int)Sport); // Sport Ball - return VerifyBallEquals(data, Legal.GetWildBalls(data.pkm)); + return VerifyBallEquals(data, Legal.GetWildBalls(data.Info.Generation, data.Info.Game)); } private CheckResult VerifyBallEgg(LegalityAnalysis data) diff --git a/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs b/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs index 06e6585ee..552a70a0c 100644 --- a/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs @@ -86,7 +86,7 @@ public static bool IsEdgeCaseLength(PKM pkm, IEncounterable e, string ot) bool eggEdge = pkm.IsEgg ? pkm.IsTradedEgg || pkm.Format == 3 : pkm.WasTradedEgg; if (!eggEdge) return false; - var len = Legal.GetMaxLengthOT(pkm.GenNumber, LanguageID.English); // max case + var len = Legal.GetMaxLengthOT(e.Generation, LanguageID.English); // max case return ot.Length <= len; }