mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-12 17:35:21 -05:00
Get lineage using the source generation of the pokemon (#769)
* Added function get max species by source game of a pokemon * Tweak get lineage function to take into account the source generation of the pokemon
This commit is contained in:
@@ -369,7 +369,7 @@ private CheckResult verifyEncounter()
|
||||
|
||||
if (pkm.VC)
|
||||
{
|
||||
int baseSpecies = Legal.getEvolutionChain(pkm, null).Min(entry => entry.Species);
|
||||
int baseSpecies = Legal.getBaseSpecies(pkm);
|
||||
if ((pkm.VC1 && baseSpecies > Legal.MaxSpeciesID_1) ||
|
||||
(pkm.VC2 && baseSpecies > Legal.MaxSpeciesID_2))
|
||||
return new CheckResult(Severity.Invalid, "VC: Unobtainable species.", CheckIdentifier.Encounter);
|
||||
|
||||
@@ -365,6 +365,40 @@ private static EvolutionTree getEvolutionTable(PKM pkm)
|
||||
return Evolves6;
|
||||
}
|
||||
}
|
||||
|
||||
private static int getMaxSpeciesOrigin(int generation)
|
||||
{
|
||||
switch (generation)
|
||||
{
|
||||
case 1:
|
||||
return Legal.MaxSpeciesID_1;
|
||||
case 2:
|
||||
return Legal.MaxSpeciesID_2;
|
||||
case 3:
|
||||
return Legal.MaxSpeciesID_3;
|
||||
case 4:
|
||||
return Legal.MaxSpeciesID_4;
|
||||
case 5:
|
||||
return Legal.MaxSpeciesID_5;
|
||||
case 6:
|
||||
return Legal.MaxSpeciesID_6;
|
||||
case 7:
|
||||
return Legal.MaxSpeciesID_7;
|
||||
default:
|
||||
return Legal.MaxSpeciesID_7;
|
||||
}
|
||||
}
|
||||
|
||||
internal static int getMaxSpeciesOrigin(PKM pkm)
|
||||
{
|
||||
if (pkm.Format == 1 || pkm.VC1) //Gen1 VC could not trade with gen 2 yet
|
||||
return getMaxSpeciesOrigin(1);
|
||||
else if (pkm.Format == 2 || pkm.VC2)
|
||||
return getMaxSpeciesOrigin(2);
|
||||
else
|
||||
return getMaxSpeciesOrigin(pkm.GenNumber);
|
||||
}
|
||||
|
||||
internal static IEnumerable<MysteryGift> getValidGifts(PKM pkm)
|
||||
{
|
||||
switch (pkm.GenNumber)
|
||||
|
||||
@@ -354,6 +354,7 @@ public void Insert(EvolutionStage evo)
|
||||
|
||||
public IEnumerable<DexLevel> getExplicitLineage(PKM pkm, int lvl, bool skipChecks, int maxSpecies)
|
||||
{
|
||||
int maxSpeciesOrigin = Legal.getMaxSpeciesOrigin(pkm);
|
||||
List<DexLevel> dl = new List<DexLevel> { new DexLevel { Species = pkm.Species, Level = lvl, Form = pkm.AltForm } };
|
||||
for (int i = Chain.Count-1; i >= 0; i--) // reverse evolution!
|
||||
{
|
||||
@@ -376,6 +377,8 @@ public IEnumerable<DexLevel> getExplicitLineage(PKM pkm, int lvl, bool skipCheck
|
||||
if (!oneValid)
|
||||
break;
|
||||
}
|
||||
if (dl.Any(d=>d.Species <= maxSpeciesOrigin) && dl.Last().Species > maxSpeciesOrigin)
|
||||
dl.RemoveAt(dl.Count - 1);//remove future gen preevolutions, no munchlax in a gen3 snorlax, no pichu in a gen1 vc raichu, etc
|
||||
return dl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user