mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
Return evolution chains with more accurate min-max
Closes #3371 ty @Ninjistix !
This commit is contained in:
parent
94080eb71a
commit
682feab3d4
8 changed files with 33 additions and 24 deletions
|
@ -140,7 +140,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
var res = new CheckMoveResult[4];
|
||||
var enc = info.EncounterMatch;
|
||||
var level = pkm.HasOriginalMetLocation ? pkm.Met_Level : enc.LevelMin;
|
||||
var level = info.EvoChainsAllGens[enc.Generation][^1].MinLevel;
|
||||
var InitialMoves = Array.Empty<int>();
|
||||
var SpecialMoves = GetSpecialMoves(enc);
|
||||
var games = enc.Generation == 1 ? GBRestrictions.GetGen1Versions(enc) : GBRestrictions.GetGen2Versions(enc, pkm.Korean);
|
||||
|
|
|
@ -165,14 +165,14 @@ namespace PKHeX.Core
|
|||
|
||||
private static List<EvoCriteria> GetEvolutionChain(PKM pkm, IEncounterTemplate enc, int mostEvolvedSpecies, int maxlevel)
|
||||
{
|
||||
var chain = GetValidPreEvolutions(pkm, minLevel: enc.LevelMin);
|
||||
var min = enc.LevelMin;
|
||||
if (pkm.HasOriginalMetLocation && pkm.Met_Level != 0)
|
||||
min = pkm.Met_Level;
|
||||
var chain = GetValidPreEvolutions(pkm, minLevel: min);
|
||||
if (enc.Species == mostEvolvedSpecies)
|
||||
{
|
||||
if (chain.Count != 1)
|
||||
{
|
||||
chain.RemoveAll(z => z.Species != enc.Species);
|
||||
chain[0].MinLevel = enc.LevelMin;
|
||||
}
|
||||
return chain;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
return new List<EvoCriteria>(2)
|
||||
{
|
||||
new((int)Species.Shedinja, 0) { Level = maxLevel, MinLevel = 20 },
|
||||
new((int)Species.Shedinja, 0) { Level = maxLevel, MinLevel = Math.Max(minLevel, 20) },
|
||||
new((int)Species.Nincada, 0) { Level = maxLevel, MinLevel = minLevel },
|
||||
};
|
||||
}
|
||||
|
@ -360,14 +360,14 @@ namespace PKHeX.Core
|
|||
break; // impossible evolution
|
||||
|
||||
oneValid = true;
|
||||
UpdateMinValues(dl, evo);
|
||||
if (evo.RequiresLevelUp)
|
||||
lvl--;
|
||||
UpdateMinValues(dl, evo, minLevel);
|
||||
|
||||
species = link.Species;
|
||||
form = link.Form;
|
||||
var detail = evo.GetEvoCriteria(species, form, lvl);
|
||||
dl.Add(detail);
|
||||
if (evo.RequiresLevelUp)
|
||||
lvl--;
|
||||
break;
|
||||
}
|
||||
if (!oneValid)
|
||||
|
@ -379,30 +379,39 @@ namespace PKHeX.Core
|
|||
if (last.Species > maxSpeciesOrigin && dl.Any(d => d.Species <= maxSpeciesOrigin))
|
||||
dl.RemoveAt(dl.Count - 1);
|
||||
|
||||
// Last species is the wild/hatched species, the minimum level is 1 because it has not evolved from previous species
|
||||
// Last species is the wild/hatched species, the minimum level is because it has not evolved from previous species
|
||||
last = dl[^1];
|
||||
last.MinLevel = 1;
|
||||
last.MinLevel = minLevel;
|
||||
last.RequiresLvlUp = false;
|
||||
|
||||
// Rectify minimum levels
|
||||
for (int i = dl.Count - 2; i >= 0; i--)
|
||||
{
|
||||
var evo = dl[i];
|
||||
var prev = dl[i + 1];
|
||||
evo.MinLevel = Math.Max(prev.MinLevel + (evo.RequiresLvlUp ? 1 : 0), evo.MinLevel);
|
||||
}
|
||||
|
||||
return dl;
|
||||
}
|
||||
|
||||
private static void UpdateMinValues(IReadOnlyList<EvoCriteria> dl, EvolutionMethod evo)
|
||||
private static void UpdateMinValues(IReadOnlyList<EvoCriteria> dl, EvolutionMethod evo, int minLevel)
|
||||
{
|
||||
var last = dl[^1];
|
||||
if (!evo.RequiresLevelUp)
|
||||
{
|
||||
// Evolutions like elemental stones, trade, etc
|
||||
last.MinLevel = 1;
|
||||
last.MinLevel = minLevel;
|
||||
return;
|
||||
}
|
||||
if (evo.Level == 0)
|
||||
{
|
||||
// Friendship based Evolutions, Pichu -> Pikachu, Eevee -> Umbreon, etc
|
||||
last.MinLevel = 2;
|
||||
// Friendship based Level Up Evolutions, Pichu -> Pikachu, Eevee -> Umbreon, etc
|
||||
last.MinLevel = minLevel + 1;
|
||||
|
||||
var first = dl[0];
|
||||
if (dl.Count > 1 && !first.RequiresLvlUp)
|
||||
first.MinLevel = 2; // Raichu from Pikachu would have a minimum level of 1; accounting for Pichu (level up required) results in a minimum level of 2
|
||||
first.MinLevel = minLevel + 1; // Raichu from Pikachu would have a minimum level of 1; accounting for Pichu (level up required) results in a minimum level of 2
|
||||
}
|
||||
else // level up evolutions
|
||||
{
|
||||
|
|
|
@ -162,10 +162,11 @@ namespace PKHeX.Core
|
|||
var min = pkm is IBattleVersion b ? Math.Max(0, b.GetMinGeneration()) : 1;
|
||||
for (int i = min; i < evoChains.Length; i++)
|
||||
{
|
||||
if (evoChains[i].Count == 0)
|
||||
var evos = evoChains[i];
|
||||
if (evos.Count == 0)
|
||||
continue;
|
||||
|
||||
result[i] = GetValidMoves(pkm, evoChains[i], i, types, RemoveTransferHM).ToList();
|
||||
result[i] = GetValidMoves(pkm, evos, i, types, RemoveTransferHM).ToList();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -225,22 +226,21 @@ namespace PKHeX.Core
|
|||
for (var i = 0; i < chain.Count; i++)
|
||||
{
|
||||
var evo = chain[i];
|
||||
bool encounteredEvo = i == chain.Count - 1;
|
||||
|
||||
if (generation <= 2)
|
||||
{
|
||||
bool encounteredEvo = i == chain.Count - 1;
|
||||
if (encounteredEvo) // minimum level, otherwise next learnable level
|
||||
minLvLG1 = (pkm.HasOriginalMetLocation ? pkm.Met_Level : evo.MinLevel) + 1;
|
||||
else if (evo.RequiresLvlUp) // learns level up moves immediately after evolving
|
||||
minLvLG1 = evo.MinLevel;
|
||||
else
|
||||
minLvLG1 = evo.MinLevel + 1;
|
||||
else // learns level up moves immediately after evolving
|
||||
minLvLG1 = evo.MinLevel;
|
||||
|
||||
if (!ParseSettings.AllowGen2MoveReminder(pkm))
|
||||
minLvLG2 = minLvLG1;
|
||||
}
|
||||
|
||||
var maxLevel = evo.Level;
|
||||
if (i != 0 && chain[i - 1].RequiresLvlUp) // evolution
|
||||
if (!encounteredEvo) // evolution
|
||||
++maxLevel; // allow lvlmoves from the level it evolved to the next species
|
||||
var moves = GetMoves(pkm, evo.Species, evo.Form, maxLevel, minLvLG1, minLvLG2, version, types, RemoveTransferHM, generation);
|
||||
r.AddRange(moves);
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue