public static IEnumerable <EncounterEgg> GenerateEggs(PKM pkm, IReadOnlyList <EvoCriteria> 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; } if (!Breeding.CanHatchAsEgg(species, pkm.Form, generation)) { yield break; // can't originate from eggs } // version is a true indicator for all generation 3-5 origins var ver = (GameVersion)pkm.Version; if (!Breeding.CanGameGenerateEggs(ver)) { yield break; } int lvl = generation <= 3 ? 5 : 1; int max = GetMaxSpeciesOrigin(generation); var e = EvoBase.GetBaseSpecies(chain, 0); if (e.Species <= max && Breeding.CanHatchAsEgg(e.Species, e.Form, ver)) { yield return(new EncounterEgg(e.Species, e.Form, lvl, generation, ver)); if (generation > 5 && (pkm.WasTradedEgg || all) && HasOtherGamePair(ver)) { yield return(new EncounterEgg(e.Species, e.Form, lvl, generation, GetOtherTradePair(ver))); } } if (!Breeding.GetSplitBreedGeneration(generation).Contains(species)) { yield break; // no other possible species } var o = EvoBase.GetBaseSpecies(chain, 1); if (o.Species == e.Species) { yield break; } if (o.Species <= max && Breeding.CanHatchAsEgg(o.Species, o.Form, ver)) { yield return(new EncounterEgg(o.Species, o.Form, lvl, generation, ver)); if (generation > 5 && (pkm.WasTradedEgg || all) && HasOtherGamePair(ver)) { yield return(new EncounterEgg(o.Species, o.Form, lvl, generation, GetOtherTradePair(ver))); } } }
public static IEnumerable <EncounterEgg> GenerateEggs(PKM pkm, IReadOnlyList <EvoCriteria> chain, bool all = false) { int species = pkm.Species; if (!Breeding.CanHatchAsEgg(species)) { yield break; } var canBeEgg = all || GetCanBeEgg(pkm); if (!canBeEgg) { yield break; } // Gen2 was before split-breed species existed; try to ensure that the egg we try and match to can actually originate in the game. // Species must be < 251 // Form must be 0 (Unown cannot breed). var baseID = chain[^ 1];
public static IEnumerable <EncounterEgg> GenerateEggs(PKM pkm, IReadOnlyList <EvoCriteria> chain, bool all = false) { int species = pkm.Species; if (!Breeding.CanHatchAsEgg(species)) { yield break; } var canBeEgg = all || GetCanBeEgg(pkm); if (!canBeEgg) { yield break; } // Gen2 was before split-breed species existed; try to ensure that the egg we try and match to can actually originate in the game. // Species must be < 251 // Form must be 0 (Unown cannot breed). var baseID = chain[chain.Count - 1]; if ((baseID.Species >= Legal.MaxSpeciesID_2 || baseID.Form != 0) && chain.Count != 1) { baseID = chain[chain.Count - 2]; } if (baseID.Form != 0) { yield break; // Forms don't exist in Gen2, besides Unown (which can't breed). Nothing can form-change. } species = baseID.Species; if (species > Legal.MaxSpeciesID_2) { yield break; } if (ParseSettings.AllowGen2Crystal(pkm)) { yield return(new EncounterEgg(species, 0, 5, 2, GameVersion.C)); // gen2 egg } yield return(new EncounterEgg(species, 0, 5, 2, GameVersion.GS)); // gen2 egg }
public static IEnumerable <EncounterEgg> GenerateEggs(PKM pkm, EvoCriteria[] chain, int generation, bool all = false) { System.Diagnostics.Debug.Assert(generation >= 3); // if generating Gen2 eggs, use the other generator. int currentSpecies = pkm.Species; if (!Breeding.CanHatchAsEgg(currentSpecies)) { yield break; } var currentForm = pkm.Form; if (!Breeding.CanHatchAsEgg(currentSpecies, currentForm, generation)) { yield break; // can't originate from eggs } // version is a true indicator for all generation 3-5 origins var ver = (GameVersion)pkm.Version; if (!Breeding.CanGameGenerateEggs(ver)) { yield break; } var lvl = EggStateLegality.GetEggLevel(generation); int max = GetMaxSpeciesOrigin(generation); var(species, form) = GetBaseSpecies(chain, 0); if ((uint)species <= max) { // NOTE: THE SPLIT-BREED SECTION OF CODE SHOULD BE EXACTLY THE SAME AS THE BELOW SECTION if (FormInfo.IsBattleOnlyForm(species, form, generation)) { form = FormInfo.GetOutOfBattleForm(species, form, generation); } if (Breeding.CanHatchAsEgg(species, form, ver)) { yield return(new EncounterEgg(species, form, lvl, generation, ver)); if (generation > 5 && (pkm.WasTradedEgg || all) && HasOtherGamePair(ver)) { yield return(new EncounterEgg(species, form, lvl, generation, GetOtherTradePair(ver))); } } } if (!Breeding.GetSplitBreedGeneration(generation).Contains(currentSpecies)) { yield break; // no other possible species } var otherSplit = species; (species, form) = GetBaseSpecies(chain, 1); if ((uint)species == otherSplit) { yield break; } if (species <= max) { // NOTE: THIS SECTION OF CODE SHOULD BE EXACTLY THE SAME AS THE ABOVE SECTION if (FormInfo.IsBattleOnlyForm(species, form, generation)) { form = FormInfo.GetOutOfBattleForm(species, form, generation); } if (Breeding.CanHatchAsEgg(species, form, ver)) { yield return(new EncounterEgg(species, form, lvl, generation, ver)); if (generation > 5 && (pkm.WasTradedEgg || all) && HasOtherGamePair(ver)) { yield return(new EncounterEgg(species, form, lvl, generation, GetOtherTradePair(ver))); } } } }