Add sanity check for min level eggs

Closes #3797
This commit is contained in:
Kurt 2023-02-18 23:19:50 -08:00
parent 3e5c31a7b5
commit 77cac48d34
11 changed files with 21 additions and 5 deletions

View file

@ -155,9 +155,6 @@ public sealed record EncounterEgg(ushort Species, byte Form, byte Level, int Gen
{
var learnset = GameData.GetLearnset(version, Species, Form);
var baseMoves = learnset.GetBaseEggMoves(Level);
if (baseMoves.Length == 0) return; pk.Move1 = baseMoves[0];
if (baseMoves.Length == 1) return; pk.Move2 = baseMoves[1];
if (baseMoves.Length == 2) return; pk.Move3 = baseMoves[2];
if (baseMoves.Length == 3) return; pk.Move4 = baseMoves[3];
pk.SetMoves(baseMoves);
}
}

View file

@ -235,6 +235,9 @@ public sealed class EncounterGenerator2 : IEncounterGenerator
private static IEnumerable<EncounterEgg> GetEggs(PKM pk, EvoCriteria[] chain)
{
var devolved = chain[^1];
if (!devolved.InsideLevelRange(EggLevel))
yield break;
// Ensure most devolved species is the same as the egg species.
var (species, form) = GetBaby(devolved);
if (species != devolved.Species)

View file

@ -338,6 +338,8 @@ public sealed class EncounterGenerator3 : IEncounterGenerator
private static IEnumerable<EncounterEgg> GetEggs(EvoCriteria[] chain, GameVersion version)
{
var devolved = chain[^1];
if (!devolved.InsideLevelRange(EggLevel))
yield break;
// Ensure most devolved species is the same as the egg species.
var (species, form) = GetBaby(devolved);

View file

@ -335,6 +335,8 @@ public sealed class EncounterGenerator4 : IEncounterGenerator
private static IEnumerable<EncounterEgg> GetEggs(EvoCriteria[] chain, GameVersion version)
{
var devolved = chain[^1];
if (!devolved.InsideLevelRange(EggLevel))
yield break;
// Ensure most devolved species is the same as the egg species.
var (species, form) = GetBaby(devolved);

View file

@ -266,6 +266,8 @@ public sealed class EncounterGenerator5 : IEncounterGenerator
private static IEnumerable<EncounterEgg> GetEggs(EvoCriteria[] chain, GameVersion version)
{
var devolved = chain[^1];
if (!devolved.InsideLevelRange(EggLevel))
yield break;
// Ensure most devolved species is the same as the egg species.
var (species, form) = GetBaby(devolved);

View file

@ -307,6 +307,8 @@ public sealed class EncounterGenerator6 : IEncounterGenerator
private static IEnumerable<EncounterEgg> GetEggs(PKM pk, EvoCriteria[] chain, GameVersion version)
{
var devolved = chain[^1];
if (!devolved.InsideLevelRange(EggLevel))
yield break;
// Ensure most devolved species is the same as the egg species.
var (species, form) = GetBaby(devolved);

View file

@ -308,6 +308,8 @@ public sealed class EncounterGenerator7 : IEncounterGenerator
private static IEnumerable<EncounterEgg> GetEggs(PKM pk, EvoCriteria[] chain, GameVersion version)
{
var devolved = chain[^1];
if (!devolved.InsideLevelRange(EggLevel))
yield break;
// Ensure most devolved species is the same as the egg species.
var (species, form) = GetBaby(devolved);

View file

@ -248,6 +248,8 @@ public sealed class EncounterGenerator8 : IEncounterGenerator
private static IEnumerable<EncounterEgg> GetEggs(EvoCriteria[] chain, GameVersion version)
{
var devolved = chain[^1];
if (!devolved.InsideLevelRange(EggLevel))
yield break;
// Ensure most devolved species is the same as the egg species.
var (species, form) = GetBaby(devolved);

View file

@ -382,6 +382,8 @@ public sealed class EncounterGenerator8b : IEncounterGenerator
private static IEnumerable<EncounterEgg> GetEggs(EvoCriteria[] chain, GameVersion version)
{
var devolved = chain[^1];
if (!devolved.InsideLevelRange(EggLevel))
yield break;
// Ensure most devolved species is the same as the egg species.
var (species, form) = GetBaby(devolved);

View file

@ -253,6 +253,8 @@ public sealed class EncounterGenerator9 : IEncounterGenerator
private static IEnumerable<EncounterEgg> GetEggs(PKM pk, EvoCriteria[] chain, GameVersion version)
{
var devolved = chain[^1];
if (!devolved.InsideLevelRange(EggLevel))
yield break;
if (version == 0 && pk.IsEgg)
version = GameVersion.SL;

View file

@ -84,7 +84,7 @@ public static class EncounterOrigin
private static int GetLevelOriginMin(PKM pk, bool hasMet)
{
if (pk.Format == 3)
if (pk.Format <= 3)
{
if (pk.IsEgg)
return 5;