Provide min level to evochain fetch

Feels pretty brittle with all the optional parameters; if things get
funky for SW/SH it may warrant a rewrite of this portion

Closes #2345 ty @iiippppk !
This commit is contained in:
Kurt 2019-07-02 08:34:28 -07:00
parent b5945624eb
commit 7a2b27ebbe
3 changed files with 5 additions and 5 deletions

View File

@ -503,11 +503,11 @@ internal static bool IsTradeEvolved(IReadOnlyList<EvoCriteria>[] chain, int pkmF
internal static bool IsEvolutionValid(PKM pkm, int minSpecies = -1, int minLevel = -1)
{
var curr = EvolutionChain.GetValidPreEvolutions(pkm);
var curr = EvolutionChain.GetValidPreEvolutions(pkm, minLevel: minLevel);
var min = curr.FindLast(z => z.Species == minSpecies);
if (min != null && min.Level < minLevel)
return false;
var poss = EvolutionChain.GetValidPreEvolutions(pkm, lvl: 100, skipChecks: true);
var poss = EvolutionChain.GetValidPreEvolutions(pkm, lvl: 100, minLevel: minLevel, skipChecks: true);
if (minSpecies != -1)
{

View File

@ -160,7 +160,7 @@ internal static int GetEvoChainSpeciesIndex(IReadOnlyList<EvoCriteria> chain, in
private static List<EvoCriteria> GetEvolutionChain(PKM pkm, IEncounterable Encounter, int maxspec, int maxlevel)
{
var vs = GetValidPreEvolutions(pkm);
var vs = GetValidPreEvolutions(pkm, minLevel: Encounter.LevelMin);
if (Encounter.Species == maxspec)
{
if (vs.Count != 1)
@ -231,7 +231,7 @@ private static void CheckLastEncounterRemoval(IEncounterable Encounter, IReadOnl
}
}
internal static List<EvoCriteria> GetValidPreEvolutions(PKM pkm, int maxspeciesorigin = -1, int lvl = -1, bool skipChecks = false)
internal static List<EvoCriteria> GetValidPreEvolutions(PKM pkm, int maxspeciesorigin = -1, int lvl = -1, int minLevel = 1, bool skipChecks = false)
{
if (lvl < 0)
lvl = pkm.CurrentLevel;
@ -257,7 +257,7 @@ internal static List<EvoCriteria> GetValidPreEvolutions(PKM pkm, int maxspecieso
int tree = maxspeciesorigin == MaxSpeciesID_2 ? 2 : pkm.Format;
var et = EvolutionTree.GetEvolutionTree(pkm, tree);
return et.GetValidPreEvolutions(pkm, maxLevel: lvl, maxSpeciesOrigin: maxspeciesorigin, skipChecks: skipChecks);
return et.GetValidPreEvolutions(pkm, maxLevel: lvl, maxSpeciesOrigin: maxspeciesorigin, skipChecks: skipChecks, minLevel: minLevel);
}
private static int GetMinLevelGeneration(PKM pkm, int generation)