diff --git a/PKHeX.Core/Legality/Breeding.cs b/PKHeX.Core/Legality/Breeding.cs index ae383af0a..4ad33d1b6 100644 --- a/PKHeX.Core/Legality/Breeding.cs +++ b/PKHeX.Core/Legality/Breeding.cs @@ -91,12 +91,16 @@ internal static bool GetCanInheritMoves(int species) /// Checks if the can be obtained from a daycare egg. /// /// Chained with the other 2 overloads for incremental checks with different parameters. + /// Current species public static bool CanHatchAsEgg(int species) => !NoHatchFromEgg.Contains(species); /// /// Checks if the - can exist as a hatched egg in the requested . /// /// Chained with the other 2 overloads for incremental checks with different parameters. + /// Current species + /// Current form + /// Generation of origin public static bool CanHatchAsEgg(int species, int form, int generation) { if (form == 0) @@ -116,6 +120,9 @@ public static bool CanHatchAsEgg(int species, int form, int generation) /// Checks if the - can exist as a hatched egg in the requested . /// /// Chained with the other 2 overloads for incremental checks with different parameters. + /// Current species + /// Current form + /// Game of origin public static bool CanHatchAsEgg(int species, int form, GameVersion game) { // Sanity check form for origin diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator3.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator3.cs index 2c4a6f647..dac00547b 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator3.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator3.cs @@ -187,7 +187,7 @@ private static IEnumerable GenerateRawEncounters3(PKM pkm, Legal if (pkm.Version != (int)GameVersion.CXD) // no eggs in C/XD { - foreach (var z in GenerateEggs(pkm)) + foreach (var z in GenerateEggs(pkm, 3)) yield return z; } diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs index 837c97481..dbd724d8e 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs @@ -51,7 +51,7 @@ private static IEnumerable GenerateRawEncounters4(PKM pkm, Legal } if (pkm.WasBredEgg) { - foreach (var z in GenerateEggs(pkm)) + foreach (var z in GenerateEggs(pkm, 4)) yield return z; } foreach (var z in GetValidEncounterTrades(pkm, chain)) diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator5.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator5.cs index bc0d97ce8..6bd58f667 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator5.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator5.cs @@ -25,7 +25,7 @@ public static IEnumerable GetEncounters(PKM pkm) if (pkm.WasBredEgg) { - foreach (var z in GenerateEggs(pkm)) + foreach (var z in GenerateEggs(pkm, 5)) { yield return z; ++ctr; } if (ctr == 0) yield break; } diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator6.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator6.cs index 7b1d96923..8b51a72b7 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator6.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator6.cs @@ -48,7 +48,7 @@ public static IEnumerable GetEncounters(PKM pkm) if (pkm.WasBredEgg) { - foreach (var z in GenerateEggs(pkm)) + foreach (var z in GenerateEggs(pkm, 6)) { yield return z; ++ctr; } if (ctr == 0) yield break; } diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator7.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator7.cs index 69afa40f1..63ecc995f 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator7.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator7.cs @@ -114,7 +114,7 @@ private static IEnumerable GetEncountersMainline(PKM pkm, IReadO if (pkm.WasBredEgg) { - foreach (var z in GenerateEggs(pkm)) + foreach (var z in GenerateEggs(pkm, 7)) { yield return z; ++ctr; } if (ctr == 0) yield break; } diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator8.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator8.cs index d562f0ac4..fdf81fa42 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator8.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator8.cs @@ -33,7 +33,7 @@ private static IEnumerable GetEncountersMainline(PKM pkm, IReadO if (pkm.WasBredEgg) { - foreach (var z in GenerateEggs(pkm)) + foreach (var z in GenerateEggs(pkm, 8)) { yield return z; ++ctr; } if (ctr == 0) yield break; } diff --git a/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs index f397ec725..b747e6645 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs @@ -230,7 +230,7 @@ private static IEnumerable GetEggs(PKM pk, IReadOnlyCollection GenerateEggs(PKM pkm, bool all = false) + public static IEnumerable GenerateEggs(PKM pkm, int generation, bool all = false) { - var table = EvolutionTree.GetEvolutionTree(pkm, Math.Max(2, pkm.Format)); - int maxSpeciesOrigin = GetMaxSpeciesOrigin(pkm.Generation); + var table = EvolutionTree.GetEvolutionTree(pkm, pkm.Format); + int maxSpeciesOrigin = GetMaxSpeciesOrigin(generation); var evos = table.GetValidPreEvolutions(pkm, maxLevel: 100, maxSpeciesOrigin: maxSpeciesOrigin, skipChecks: true); - return GenerateEggs(pkm, evos, all); + return GenerateEggs(pkm, evos, generation, all); } - public static IEnumerable GenerateEggs(PKM pkm, IReadOnlyList chain, bool all = false) + public static IEnumerable GenerateEggs(PKM pkm, IReadOnlyList chain, int generation, bool all = false) { + System.Diagnostics.Debug.Assert(generation >= 3); // if generating Gen2 eggs, use the other generator. int species = pkm.Species; if (!Breeding.CanHatchAsEgg(species)) yield break; - - int generation = pkm.Generation; - if (generation <= 2) - yield break; // can't get eggs; if generating Gen2 eggs, use the other generator. if (!Breeding.CanHatchAsEgg(species, pkm.Form, generation)) yield break; // can't originate from eggs diff --git a/PKHeX.Core/Legality/MoveListSuggest.cs b/PKHeX.Core/Legality/MoveListSuggest.cs index 7830c5cc4..d025f4f9d 100644 --- a/PKHeX.Core/Legality/MoveListSuggest.cs +++ b/PKHeX.Core/Legality/MoveListSuggest.cs @@ -108,7 +108,7 @@ public static int[] GetSuggestedCurrentMoves(this LegalityAnalysis analysis, Mov /// Gets the current array of four moves that might be legal. /// /// Use instead of calling directly; this method just puts default values in without considering the final moveset. - public static IReadOnlyList GetSuggestedRelearn(this IEncounterable enc, PKM pkm) + public static IReadOnlyList GetSuggestedRelearn(this IEncounterTemplate enc, PKM pkm) { if (VerifyRelearnMoves.ShouldNotHaveRelearnMoves(enc, pkm)) return Empty; @@ -148,7 +148,8 @@ private static IReadOnlyList GetSuggestedRelearnEgg(this IEncounterTemplate // Split-breed species like Budew & Roselia may be legal for one, and not the other. // If we're not a split-breed or are already legal, return. var result = enc.GetEggRelearnMoves(parse, pkm); - var split = Breeding.GetSplitBreedGeneration(enc.Generation); + int generation = enc.Generation; + var split = Breeding.GetSplitBreedGeneration(generation); if (!split.Contains(enc.Species) || enc.Generation <= 2) return result; @@ -159,7 +160,7 @@ private static IReadOnlyList GetSuggestedRelearnEgg(this IEncounterTemplate return result; // Try again with the other split-breed species if possible. - var incense = EncounterEggGenerator.GenerateEggs(tmp).FirstOrDefault(); + var incense = EncounterEggGenerator.GenerateEggs(tmp, generation).FirstOrDefault(); if (incense is null || incense.Species == enc.Species) return result;