Add egg level check

Catches level 12 charizards and level 50 tyranitars that were bred
This commit is contained in:
Kaphotics
2016-04-07 18:19:21 -07:00
parent 52ab0bd8d7
commit e8cc1a386d
2 changed files with 14 additions and 2 deletions

View File

@@ -292,6 +292,8 @@ private LegalityCheck verifyLevel()
int lvl = pk6.CurrentLevel;
if (lvl < pk6.Met_Level)
return new LegalityCheck(Severity.Invalid, "Current level is below met level.");
if (pk6.WasEgg && !Legal.getEvolutionValid(pk6))
return new LegalityCheck(Severity.Invalid, "Level is below evolution requirements.");
if (lvl > pk6.Met_Level && lvl > 1 && lvl != 100 && pk6.EXP == PKX.getEXP(pk6.Stat_Level, pk6.Species))
return new LegalityCheck(Severity.Fishy, "Current experience matches level threshold.");

View File

@@ -351,6 +351,15 @@ internal static bool getIsFossil(PK6 pk6)
return false;
}
internal static bool getEvolutionValid(PK6 pk6)
{
var curr = getValidPreEvolutions(pk6);
var poss = getValidPreEvolutions(pk6, 100);
if (SplitBreed.Contains(getBaseSpecies(pk6, 1)))
return curr.Count() >= poss.Count() - 1;
return curr.Count() >= poss.Count();
}
internal static IEnumerable<int> getLineage(PK6 pk6)
{
List<int> res = new List<int>();
@@ -453,9 +462,10 @@ private static IEnumerable<EncounterArea> getSlots(PK6 pk6, IEnumerable<Encounte
}
return slotLocations;
}
private static IEnumerable<DexLevel> getValidPreEvolutions(PK6 pk6)
private static IEnumerable<DexLevel> getValidPreEvolutions(PK6 pk6, int lvl = -1)
{
int lvl = pk6.CurrentLevel;
if (lvl < 0)
lvl = pk6.CurrentLevel;
if (pk6.Species == 292 && pk6.Met_Level + 1 <= lvl && lvl >= 20)
return new List<DexLevel>
{