Included min level of evolutions in the Lineage of a Pokemon, used to check evolution legality and to check in what evolutionary forms any pokemon inhabited previous generations

This commit is contained in:
javierhimura
2017-02-15 21:21:23 +01:00
parent 7f9803905d
commit 7720e93600
2 changed files with 22 additions and 3 deletions

View File

@@ -4,12 +4,13 @@ public class DexLevel
{
public int Species;
public int Level;
public int MinLevel;
public int Form = -1;
public int Flag = -1;
public DexLevel Copy(int lvl)
{
return new DexLevel {Species = Species, Level = lvl, Form = Form, Flag = -1};
return new DexLevel {Species = Species, Level = lvl, MinLevel = MinLevel, Form = Form, Flag = -1};
}
public bool Matches(int species, int form)
{

View File

@@ -153,7 +153,7 @@ private int getIndex(EvolutionMethod evo)
return Personal.getFormeIndex(evolvesToSpecies, evolvesToForm);
}
public IEnumerable<DexLevel> getValidPreEvolutions(PKM pkm, int lvl, bool skipChecks = false)
public IEnumerable<DexLevel> getValidPreEvolutions(PKM pkm, int lvl,bool skipChecks = false)
{
int index = getIndex(pkm);
int maxSpeciesOrigin = Legal.getMaxSpeciesOrigin(pkm);
@@ -354,7 +354,7 @@ public bool Valid(PKM pkm, int lvl, bool skipChecks)
return false;
}
}
public DexLevel GetDexLevel(int species, int lvl)
{
@@ -416,6 +416,22 @@ public IEnumerable<DexLevel> getExplicitLineage(PKM pkm, int lvl, bool skipCheck
continue;
oneValid = true;
if (evo.Level == 0 && !evo.RequiresLevelUp) //Evolutions like elemental stones
dl.Last().MinLevel = 1;
else if(evo.Level ==0) //Evolutions like frienship, picho -> pikachu, eeve -> umbreon, etc
{
dl.Last().MinLevel = 2;
if (dl.Count() > 1 && dl.First().MinLevel == 1)
dl.First().MinLevel = 2;
}
else
{
dl.Last().MinLevel = evo.Level;
if (dl.Count() > 1 && dl.First().MinLevel == 1)
dl.First().MinLevel = evo.Level; //Pokemon like Nidoqueen, its minimun level is Nidorina minimun level
if (dl.Count() > 1 && dl.First().MinLevel == 2)
dl.First().MinLevel = evo.Level + 1; //Pokemon like Crobat, its minimun level is Golbat minimun level + 1
}
int species = evo.Species;
// Gen7 Personal Formes -- unmap the forme personal entry ID to the actual species ID since species are consecutive
@@ -436,6 +452,8 @@ public IEnumerable<DexLevel> getExplicitLineage(PKM pkm, int lvl, bool skipCheck
if (dl.Any(d => d.Species <= maxSpeciesOrigin) && dl.Last().Species > maxSpeciesOrigin)
dl.RemoveAt(dl.Count - 1);
//Last species is the wild/hatched species, the minimu is 1 because it has not evolved from previous species
dl.Last().MinLevel = 1;
return dl;
}
}