mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Generate gen2 eggs via gen2 method, ignore gen1 versions
For searching, only return versions compatible with the save file Don't bother filtering out BU for Japanese-only.
This commit is contained in:
parent
989c4314ae
commit
f631cbbecd
3 changed files with 32 additions and 14 deletions
|
@ -7,7 +7,6 @@ namespace PKHeX.Core
|
|||
{
|
||||
public static class EncounterEggGenerator
|
||||
{
|
||||
// EncounterEgg
|
||||
public static IEnumerable<EncounterEgg> GenerateEggs(PKM pkm, bool all = false)
|
||||
{
|
||||
var table = EvolutionTree.GetEvolutionTree(pkm, Math.Max(2, pkm.Format));
|
||||
|
@ -98,9 +97,17 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
internal static class EncounterEggGenerator2
|
||||
{
|
||||
public static IEnumerable<IEncounterable> GenerateEggs(PKM pkm, IReadOnlyList<EvoCriteria> chain)
|
||||
public static IEnumerable<EncounterEgg> GenerateEggs(PKM pkm, bool all = false)
|
||||
{
|
||||
var canBeEgg = GetCanBeEgg(pkm);
|
||||
var table = EvolutionTree.GetEvolutionTree(pkm, 2);
|
||||
int maxSpeciesOrigin = GetMaxSpeciesOrigin(2);
|
||||
var evos = table.GetValidPreEvolutions(pkm, maxLevel: 100, maxSpeciesOrigin: maxSpeciesOrigin, skipChecks: true);
|
||||
return GenerateEggs(pkm, evos, all);
|
||||
}
|
||||
|
||||
public static IEnumerable<EncounterEgg> GenerateEggs(PKM pkm, IReadOnlyList<EvoCriteria> chain, bool all = false)
|
||||
{
|
||||
var canBeEgg = all || GetCanBeEgg(pkm);
|
||||
if (!canBeEgg)
|
||||
yield break;
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
return type switch
|
||||
{
|
||||
EncounterOrder.Egg => GetEggs(pk, needs, version),
|
||||
EncounterOrder.Egg => GetEggs(pk, needs, chain, version),
|
||||
EncounterOrder.Mystery => GetGifts(pk, needs, chain),
|
||||
EncounterOrder.Static => GetStatic(pk, needs, chain),
|
||||
EncounterOrder.Trade => GetTrades(pk, needs, chain),
|
||||
|
@ -205,14 +205,19 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
/// <param name="pk">Rough Pokémon data which contains the requested species, gender, and form.</param>
|
||||
/// <param name="needs">Moves which cannot be taught by the player.</param>
|
||||
/// <param name="chain">Origin possible evolution chain</param>
|
||||
/// <param name="version">Specific version to iterate for. Necessary for retrieving possible Egg Moves.</param>
|
||||
/// <returns>A consumable <see cref="IEncounterable"/> list of possible encounters.</returns>
|
||||
private static IEnumerable<EncounterEgg> GetEggs(PKM pk, IReadOnlyCollection<int> needs, GameVersion version)
|
||||
private static IEnumerable<EncounterEgg> GetEggs(PKM pk, IReadOnlyCollection<int> needs, IReadOnlyList<EvoCriteria> chain, GameVersion version)
|
||||
{
|
||||
if (GameVersion.CXD.Contains(version) || GameVersion.Gen7b.Contains(version))
|
||||
yield break; // no eggs from these games
|
||||
|
||||
var eggs = EncounterEggGenerator.GenerateEggs(pk, all: true);
|
||||
int gen = version.GetGeneration();
|
||||
if (gen < 2)
|
||||
yield break;
|
||||
var eggs = gen == 2
|
||||
? EncounterEggGenerator2.GenerateEggs(pk, chain, all: true)
|
||||
: EncounterEggGenerator.GenerateEggs(pk, chain, all: true);
|
||||
foreach (var egg in eggs)
|
||||
{
|
||||
if (needs.Count == 0)
|
||||
|
|
|
@ -141,14 +141,20 @@ namespace PKHeX.Core.Searching
|
|||
{
|
||||
if (Version > 0)
|
||||
return new[] {(GameVersion) Version};
|
||||
if (Generation != 0)
|
||||
{
|
||||
return fallback.GetGeneration() == Generation
|
||||
? GameUtil.GetVersionsWithinRange(sav, Generation).ToArray()
|
||||
: GameUtil.GameVersions;
|
||||
}
|
||||
|
||||
return GameUtil.GameVersions;
|
||||
return Generation switch
|
||||
{
|
||||
1 when !ParseSettings.AllowGen1Tradeback => new[] {GameVersion.RD, GameVersion.BU, GameVersion.GN, GameVersion.YW},
|
||||
2 when sav is SAV2 {Korean: true} => new[] {GameVersion.GD, GameVersion.SV},
|
||||
1 or 2 => new[]
|
||||
{
|
||||
GameVersion.RD, GameVersion.BU, GameVersion.GN, GameVersion.YW,
|
||||
GameVersion.GD, GameVersion.SV, GameVersion.C
|
||||
},
|
||||
|
||||
_ when fallback.GetGeneration() == Generation => GameUtil.GetVersionsWithinRange(sav, Generation).ToArray(),
|
||||
_ => GameUtil.GameVersions,
|
||||
};
|
||||
}
|
||||
|
||||
private static GameVersion GetFallbackVersion(ITrainerInfo sav)
|
||||
|
|
Loading…
Add table
Reference in a new issue