2018-06-20 00:14:22 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
using static PKHeX.Core.Legal;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
|
|
|
|
public static class EvolutionChain
|
|
|
|
|
{
|
2022-05-31 04:43:52 +00:00
|
|
|
|
internal static EvolutionHistory GetEvolutionChainsAllGens(PKM pkm, IEncounterTemplate enc)
|
2018-06-20 00:14:22 +00:00
|
|
|
|
{
|
2022-04-24 04:33:17 +00:00
|
|
|
|
var chain = GetEvolutionChain(pkm, enc, pkm.Species, (byte)pkm.CurrentLevel);
|
|
|
|
|
if (chain.Length == 0 || pkm.IsEgg || enc is EncounterInvalid)
|
2021-08-01 05:38:04 +00:00
|
|
|
|
return GetChainSingle(pkm, chain);
|
2018-06-20 00:50:10 +00:00
|
|
|
|
|
2021-08-01 05:38:04 +00:00
|
|
|
|
return GetChainAll(pkm, enc, chain);
|
2018-06-21 04:38:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-31 04:43:52 +00:00
|
|
|
|
private static EvolutionHistory GetChainSingle(PKM pkm, EvoCriteria[] fullChain)
|
2018-06-21 04:38:56 +00:00
|
|
|
|
{
|
2022-05-31 04:43:52 +00:00
|
|
|
|
var count = Math.Max(2, pkm.Format) + 1;
|
|
|
|
|
return new EvolutionHistory(fullChain, count)
|
|
|
|
|
{
|
|
|
|
|
[pkm.Format] = fullChain,
|
|
|
|
|
};
|
2018-06-20 00:14:22 +00:00
|
|
|
|
}
|
2018-06-21 04:38:56 +00:00
|
|
|
|
|
2022-05-31 04:43:52 +00:00
|
|
|
|
private static EvolutionHistory GetChainAll(PKM pkm, IEncounterTemplate enc, EvoCriteria[] fullChain)
|
2018-06-20 00:14:22 +00:00
|
|
|
|
{
|
2022-05-31 04:43:52 +00:00
|
|
|
|
int maxgen = ParseSettings.AllowGen1Tradeback && pkm.Context == EntityContext.Gen1 ? 2 : pkm.Format;
|
|
|
|
|
var GensEvoChains = new EvolutionHistory(fullChain, maxgen + 1);
|
2018-06-20 00:14:22 +00:00
|
|
|
|
|
2022-04-24 04:33:17 +00:00
|
|
|
|
var head = 0; // inlined FIFO queue indexing
|
|
|
|
|
var mostEvolved = fullChain[head++];
|
2018-06-21 01:25:23 +00:00
|
|
|
|
|
2022-04-24 04:33:17 +00:00
|
|
|
|
var lvl = (byte)pkm.CurrentLevel;
|
|
|
|
|
var maxLevel = lvl;
|
2018-06-21 04:38:56 +00:00
|
|
|
|
|
2018-06-21 01:25:23 +00:00
|
|
|
|
// Iterate generations backwards
|
|
|
|
|
// Maximum level of an earlier generation (GenX) will never be greater than a later generation (GenX+Y).
|
2022-05-31 04:43:52 +00:00
|
|
|
|
int mingen = enc.Generation;
|
|
|
|
|
if (mingen is 1 or 2)
|
|
|
|
|
mingen = GBRestrictions.GetTradebackStatusInitial(pkm) == PotentialGBOrigin.Gen2Only ? 2 : 1;
|
|
|
|
|
|
2018-06-23 03:16:31 +00:00
|
|
|
|
bool noxfrDecremented = true;
|
2018-06-21 04:38:56 +00:00
|
|
|
|
for (int g = GensEvoChains.Length - 1; g >= mingen; g--)
|
2018-06-20 00:14:22 +00:00
|
|
|
|
{
|
2022-05-31 04:43:52 +00:00
|
|
|
|
if (g == 6 && enc.Generation < 3)
|
2022-04-24 04:33:17 +00:00
|
|
|
|
g = 2; // skip over 6543 as it never existed in these.
|
2020-05-31 19:12:48 +00:00
|
|
|
|
|
2022-04-24 04:33:17 +00:00
|
|
|
|
if (g <= 4 && pkm.Format > 2 && pkm.Format > g && !pkm.HasOriginalMetLocation)
|
2018-06-20 00:14:22 +00:00
|
|
|
|
{
|
|
|
|
|
// Met location was lost at this point but it also means the pokemon existed in generations 1 to 4 with maximum level equals to met level
|
2022-04-24 04:33:17 +00:00
|
|
|
|
var met = pkm.Met_Level;
|
|
|
|
|
if (lvl > pkm.Met_Level)
|
|
|
|
|
lvl = (byte)met;
|
2018-06-20 00:14:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-21 01:25:23 +00:00
|
|
|
|
int maxspeciesgen = g == 2 && pkm.VC1 ? MaxSpeciesID_1 : GetMaxSpeciesOrigin(g);
|
2018-06-20 00:14:22 +00:00
|
|
|
|
|
|
|
|
|
// Remove future gen evolutions after a few special considerations:
|
|
|
|
|
// If the pokemon origin is illegal (e.g. Gen3 Infernape) the list will be emptied -- species lineage did not exist at any evolution stage.
|
2018-06-21 01:25:23 +00:00
|
|
|
|
while (mostEvolved.Species > maxspeciesgen)
|
2018-06-20 00:14:22 +00:00
|
|
|
|
{
|
2022-04-24 04:33:17 +00:00
|
|
|
|
if (head >= fullChain.Length)
|
2018-07-19 23:42:45 +00:00
|
|
|
|
{
|
|
|
|
|
if (g <= 2 && pkm.VC1)
|
2022-05-31 04:43:52 +00:00
|
|
|
|
GensEvoChains.Invalidate(); // invalidate here since we haven't reached the regular invalidation
|
2018-06-21 04:38:56 +00:00
|
|
|
|
return GensEvoChains;
|
2018-07-19 23:42:45 +00:00
|
|
|
|
}
|
2018-06-21 01:25:23 +00:00
|
|
|
|
if (mostEvolved.RequiresLvlUp)
|
2022-05-31 04:43:52 +00:00
|
|
|
|
ReviseMaxLevel(ref lvl, pkm, g, maxLevel);
|
|
|
|
|
|
2022-04-24 04:33:17 +00:00
|
|
|
|
mostEvolved = fullChain[head++];
|
2018-06-20 00:14:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Alolan form evolutions, remove from gens 1-6 chains
|
2022-05-31 04:43:52 +00:00
|
|
|
|
if (g < 7 && HasAlolanForm(mostEvolved.Species) && pkm.Format >= 7 && mostEvolved.Form > 0)
|
2018-06-20 00:14:22 +00:00
|
|
|
|
{
|
2022-05-31 04:43:52 +00:00
|
|
|
|
if (head >= fullChain.Length)
|
|
|
|
|
return GensEvoChains;
|
|
|
|
|
mostEvolved = fullChain[head++];
|
2018-06-20 00:14:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-31 04:43:52 +00:00
|
|
|
|
var tmp = GetEvolutionChain(pkm, enc, mostEvolved.Species, lvl);
|
|
|
|
|
if (tmp.Length == 0)
|
2018-06-20 00:50:10 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
2022-05-31 04:43:52 +00:00
|
|
|
|
GensEvoChains[g] = tmp;
|
|
|
|
|
if (g == 1)
|
|
|
|
|
{
|
|
|
|
|
CleanGen1(pkm, enc, GensEvoChains);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (g >= 3 && !pkm.HasOriginalMetLocation && g >= enc.Generation && noxfrDecremented)
|
2018-06-20 00:14:22 +00:00
|
|
|
|
{
|
2022-05-31 04:43:52 +00:00
|
|
|
|
bool isTransferred = HasMetLocationUpdatedTransfer(enc.Generation, g);
|
2018-06-23 02:40:17 +00:00
|
|
|
|
if (!isTransferred)
|
|
|
|
|
continue;
|
|
|
|
|
|
2022-05-31 04:43:52 +00:00
|
|
|
|
noxfrDecremented = g > (enc.Generation != 3 ? 4 : 5);
|
2018-06-23 03:16:31 +00:00
|
|
|
|
|
2018-06-23 02:40:17 +00:00
|
|
|
|
// Remove previous evolutions below transfer level
|
|
|
|
|
// For example a gen3 Charizard in format 7 with current level 36 and met level 36, thus could never be Charmander / Charmeleon in Gen5+.
|
2019-02-24 21:57:10 +00:00
|
|
|
|
// chain level for Charmander is 35, is below met level.
|
2018-06-23 02:40:17 +00:00
|
|
|
|
int minlvl = GetMinLevelGeneration(pkm, g);
|
2022-05-31 04:43:52 +00:00
|
|
|
|
|
|
|
|
|
ref var genChain = ref GensEvoChains[g];
|
2022-04-24 04:33:17 +00:00
|
|
|
|
int minIndex = Array.FindIndex(genChain, e => e.LevelMax >= minlvl);
|
|
|
|
|
if (minIndex != -1)
|
|
|
|
|
genChain = genChain.AsSpan(minIndex).ToArray();
|
2018-06-20 00:14:22 +00:00
|
|
|
|
}
|
2022-05-31 04:43:52 +00:00
|
|
|
|
}
|
|
|
|
|
return GensEvoChains;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ReviseMaxLevel(ref byte lvl, PKM pkm, int g, byte maxLevel)
|
|
|
|
|
{
|
|
|
|
|
// This is a Gen3 pokemon in a Gen4 phase evolution that requires level up and then transferred to Gen5+
|
|
|
|
|
// We can deduce that it existed in Gen4 until met level,
|
|
|
|
|
// but if current level is met level we can also deduce it existed in Gen3 until maximum met level -1
|
|
|
|
|
if (g == 3 && pkm.Format > 4 && lvl == maxLevel)
|
|
|
|
|
lvl--;
|
|
|
|
|
|
|
|
|
|
// The same condition for Gen2 evolution of Gen1 pokemon, level of the pokemon in Gen1 games would be CurrentLevel -1 one level below Gen2 level
|
|
|
|
|
else if (g == 1 && pkm.Format == 2 && lvl == maxLevel)
|
|
|
|
|
lvl--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void CleanGen1(PKM pkm, IEncounterTemplate enc, EvolutionHistory chains)
|
|
|
|
|
{
|
|
|
|
|
// Remove Gen7 pre-evolutions and chain break scenarios
|
|
|
|
|
if (pkm.VC1)
|
|
|
|
|
{
|
|
|
|
|
var index = Array.FindLastIndex(chains.Gen7, z => z.Species <= MaxSpeciesID_1);
|
|
|
|
|
if (index == -1)
|
2018-06-20 00:14:22 +00:00
|
|
|
|
{
|
2022-05-31 04:43:52 +00:00
|
|
|
|
chains.Invalidate(); // needed a Gen1 species present; invalidate the chain.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-23 05:48:10 +00:00
|
|
|
|
|
2022-05-31 04:43:52 +00:00
|
|
|
|
TrimSpeciesAbove(enc, MaxSpeciesID_1, ref chains.Gen1);
|
|
|
|
|
}
|
2018-06-20 00:14:22 +00:00
|
|
|
|
|
2022-05-31 04:43:52 +00:00
|
|
|
|
private static void TrimSpeciesAbove(IEncounterTemplate enc, int species, ref EvoCriteria[] chain)
|
|
|
|
|
{
|
|
|
|
|
var span = chain.AsSpan();
|
|
|
|
|
|
|
|
|
|
// Remove post-evolutions
|
|
|
|
|
if (span[0].Species > species)
|
|
|
|
|
{
|
|
|
|
|
if (span.Length == 1)
|
|
|
|
|
{
|
|
|
|
|
chain = Array.Empty<EvoCriteria>();
|
|
|
|
|
return;
|
2018-06-20 00:14:22 +00:00
|
|
|
|
}
|
2022-05-31 04:43:52 +00:00
|
|
|
|
|
|
|
|
|
span = span[1..];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove pre-evolutions
|
|
|
|
|
if (span[^1].Species > species)
|
|
|
|
|
{
|
|
|
|
|
if (span.Length == 1)
|
|
|
|
|
{
|
|
|
|
|
chain = Array.Empty<EvoCriteria>();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
span = span[..^1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (span.Length != chain.Length)
|
|
|
|
|
chain = span.ToArray();
|
|
|
|
|
|
|
|
|
|
// Update min level for the encounter to prevent certain level up moves.
|
|
|
|
|
if (span.Length != 0)
|
|
|
|
|
{
|
|
|
|
|
ref var last = ref span[^1];
|
|
|
|
|
last = last with { LevelMin = enc.LevelMin };
|
2018-06-20 00:14:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-23 00:59:02 +00:00
|
|
|
|
|
2021-06-03 19:04:19 +00:00
|
|
|
|
private static bool HasMetLocationUpdatedTransfer(int originalGeneration, int currentGeneration) => originalGeneration switch
|
2020-11-02 22:46:26 +00:00
|
|
|
|
{
|
2021-06-03 19:04:19 +00:00
|
|
|
|
< 3 => currentGeneration >= 3,
|
|
|
|
|
<= 4 => currentGeneration != originalGeneration,
|
2021-08-20 20:49:20 +00:00
|
|
|
|
_ => false,
|
2021-06-03 19:04:19 +00:00
|
|
|
|
};
|
2020-11-02 22:46:26 +00:00
|
|
|
|
|
2022-04-24 04:33:17 +00:00
|
|
|
|
private static EvoCriteria[] GetEvolutionChain(PKM pkm, IEncounterTemplate enc, int mostEvolvedSpecies, byte maxlevel)
|
2018-06-20 00:14:22 +00:00
|
|
|
|
{
|
2022-03-07 07:25:47 +00:00
|
|
|
|
int min = enc.LevelMin;
|
2022-01-14 08:11:33 +00:00
|
|
|
|
if (pkm.HasOriginalMetLocation && pkm.Met_Level != 0)
|
|
|
|
|
min = pkm.Met_Level;
|
2022-05-31 04:43:52 +00:00
|
|
|
|
|
2022-01-14 08:11:33 +00:00
|
|
|
|
var chain = GetValidPreEvolutions(pkm, minLevel: min);
|
2022-05-31 04:43:52 +00:00
|
|
|
|
return TrimChain(chain, enc, mostEvolvedSpecies, maxlevel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static EvoCriteria[] TrimChain(EvoCriteria[] chain, IEncounterTemplate enc, int mostEvolvedSpecies, byte maxlevel)
|
|
|
|
|
{
|
2021-08-01 05:38:04 +00:00
|
|
|
|
if (enc.Species == mostEvolvedSpecies)
|
2022-05-31 04:43:52 +00:00
|
|
|
|
return TrimChainSingle(chain, enc);
|
2018-06-20 00:14:22 +00:00
|
|
|
|
|
|
|
|
|
// Evolution chain is in reverse order (devolution)
|
2018-06-23 00:59:02 +00:00
|
|
|
|
// Find the index of the minimum species to determine the end of the chain
|
2022-04-24 04:33:17 +00:00
|
|
|
|
int minIndex = Array.FindLastIndex(chain, z => z.Species == enc.Species);
|
|
|
|
|
bool last = minIndex < 0 || minIndex == chain.Length - 1;
|
2018-06-20 00:14:22 +00:00
|
|
|
|
|
2018-06-23 00:59:02 +00:00
|
|
|
|
// If we remove a pre-evolution, update the chain if appropriate.
|
|
|
|
|
if (!last)
|
2018-06-20 00:14:22 +00:00
|
|
|
|
{
|
2018-06-23 00:59:02 +00:00
|
|
|
|
// Remove chain species after the encounter
|
2022-04-24 04:33:17 +00:00
|
|
|
|
if (minIndex + 1 == chain.Length)
|
|
|
|
|
return Array.Empty<EvoCriteria>(); // no species left in chain
|
2018-06-23 00:59:02 +00:00
|
|
|
|
|
2022-04-24 04:33:17 +00:00
|
|
|
|
chain = chain.AsSpan(0, minIndex + 1).ToArray();
|
2021-08-01 05:38:04 +00:00
|
|
|
|
CheckLastEncounterRemoval(enc, chain);
|
2018-06-20 00:14:22 +00:00
|
|
|
|
}
|
2018-06-23 00:59:02 +00:00
|
|
|
|
|
2022-05-31 04:43:52 +00:00
|
|
|
|
return TrimChainMore(chain, mostEvolvedSpecies, maxlevel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static EvoCriteria[] TrimChainMore(EvoCriteria[] chain, int mostEvolvedSpecies, byte maxlevel)
|
|
|
|
|
{
|
2019-02-24 21:57:10 +00:00
|
|
|
|
// maxspec is used to remove future geneneration evolutions, to gather evolution chain of a pokemon in previous generations
|
2022-04-24 04:33:17 +00:00
|
|
|
|
var maxSpeciesIndex = Array.FindIndex(chain, z => z.Species == mostEvolvedSpecies);
|
|
|
|
|
if (maxSpeciesIndex > 0)
|
|
|
|
|
chain = chain.AsSpan(maxSpeciesIndex).ToArray();
|
2018-06-23 00:59:02 +00:00
|
|
|
|
|
2019-02-24 21:57:10 +00:00
|
|
|
|
// Gen3->4 and Gen4->5 transfer sets the Met Level property to the Pokémon's current level.
|
|
|
|
|
// Removes evolutions impossible before the transfer level.
|
|
|
|
|
// For example a FireRed Charizard with a current level (in XY) is 50 but Met Level is 20; it couldn't be a Charizard in Gen3 and Gen4 games
|
2022-04-24 04:33:17 +00:00
|
|
|
|
var clampIndex = Array.FindIndex(chain, z => z.LevelMin > maxlevel);
|
|
|
|
|
if (clampIndex != -1)
|
|
|
|
|
chain = Array.FindAll(chain, z => z.LevelMin <= maxlevel);
|
2018-06-23 00:59:02 +00:00
|
|
|
|
|
|
|
|
|
// Reduce the evolution chain levels to max level to limit any later analysis/results.
|
2022-05-31 04:43:52 +00:00
|
|
|
|
SanitizeMaxLevel(chain, maxlevel);
|
|
|
|
|
|
|
|
|
|
return chain;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void SanitizeMaxLevel(EvoCriteria[] chain, byte maxlevel)
|
|
|
|
|
{
|
2022-04-24 04:33:17 +00:00
|
|
|
|
for (var i = 0; i < chain.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
ref var c = ref chain[i];
|
|
|
|
|
c = c with { LevelMax = Math.Min(c.LevelMax, maxlevel) };
|
|
|
|
|
}
|
2022-05-31 04:43:52 +00:00
|
|
|
|
}
|
2018-06-23 00:59:02 +00:00
|
|
|
|
|
2022-05-31 04:43:52 +00:00
|
|
|
|
private static EvoCriteria[] TrimChainSingle(EvoCriteria[] chain, IEncounterTemplate enc)
|
|
|
|
|
{
|
|
|
|
|
if (chain.Length == 1)
|
|
|
|
|
return chain;
|
|
|
|
|
var index = Array.FindLastIndex(chain, z => z.Species == enc.Species);
|
|
|
|
|
if (index == -1)
|
|
|
|
|
return Array.Empty<EvoCriteria>();
|
|
|
|
|
return new[] { chain[index] };
|
2018-06-20 00:14:22 +00:00
|
|
|
|
}
|
2018-06-23 00:59:02 +00:00
|
|
|
|
|
2022-04-24 04:33:17 +00:00
|
|
|
|
private static void CheckLastEncounterRemoval(IEncounterTemplate enc, EvoCriteria[] chain)
|
2018-06-23 00:59:02 +00:00
|
|
|
|
{
|
2020-06-28 03:18:29 +00:00
|
|
|
|
// Last entry from chain is removed, turn next entry into the encountered Pokémon
|
2022-04-24 04:33:17 +00:00
|
|
|
|
ref var last = ref chain[^1];
|
|
|
|
|
last = last with { LevelMin = enc.LevelMin, LevelUpRequired = 1 };
|
2018-06-23 00:59:02 +00:00
|
|
|
|
|
2022-04-24 04:33:17 +00:00
|
|
|
|
ref var first = ref chain[0];
|
2018-06-23 00:59:02 +00:00
|
|
|
|
if (first.RequiresLvlUp)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-04-24 04:33:17 +00:00
|
|
|
|
if (first.LevelMin == 2)
|
2018-06-23 00:59:02 +00:00
|
|
|
|
{
|
2019-02-24 21:57:10 +00:00
|
|
|
|
// Example: Raichu in Gen2 or later
|
2018-06-23 00:59:02 +00:00
|
|
|
|
// Because Pichu requires a level up, the minimum level of the resulting Raichu must be be >2
|
|
|
|
|
// But after removing Pichu (because the origin species is Pikachu), the Raichu minimum level should be 1.
|
2022-04-24 04:33:17 +00:00
|
|
|
|
first = first with { LevelMin = 1, LevelUpRequired = 0 };
|
2018-06-23 00:59:02 +00:00
|
|
|
|
}
|
2019-02-24 21:57:10 +00:00
|
|
|
|
else // in-game trade or evolution stone can evolve immediately
|
2018-06-23 00:59:02 +00:00
|
|
|
|
{
|
2022-04-24 04:33:17 +00:00
|
|
|
|
first = first with { LevelMin = enc.LevelMin };
|
2018-06-23 00:59:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-24 04:33:17 +00:00
|
|
|
|
internal static EvoCriteria[] GetValidPreEvolutions(PKM pkm, int maxspeciesorigin = -1, int maxLevel = -1, int minLevel = 1, bool skipChecks = false)
|
2018-06-20 00:14:22 +00:00
|
|
|
|
{
|
2020-06-28 03:18:29 +00:00
|
|
|
|
if (maxLevel < 0)
|
|
|
|
|
maxLevel = pkm.CurrentLevel;
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2020-12-11 04:42:30 +00:00
|
|
|
|
if (maxspeciesorigin == -1 && pkm.InhabitedGeneration(2) && pkm.Format <= 2 && pkm.Generation == 1)
|
2018-06-20 00:14:22 +00:00
|
|
|
|
maxspeciesorigin = MaxSpeciesID_2;
|
|
|
|
|
|
2022-05-31 04:43:52 +00:00
|
|
|
|
var context = pkm.Context;
|
|
|
|
|
if (context < EntityContext.Gen2)
|
|
|
|
|
context = EntityContext.Gen2;
|
|
|
|
|
var et = EvolutionTree.GetEvolutionTree(context);
|
2022-04-24 04:33:17 +00:00
|
|
|
|
return et.GetValidPreEvolutions(pkm, maxLevel: (byte)maxLevel, maxSpeciesOrigin: maxspeciesorigin, skipChecks: skipChecks, minLevel: (byte)minLevel);
|
2018-06-20 00:14:22 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2018-06-20 00:14:22 +00:00
|
|
|
|
private static int GetMinLevelGeneration(PKM pkm, int generation)
|
|
|
|
|
{
|
|
|
|
|
if (!pkm.InhabitedGeneration(generation))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (pkm.Format <= 2)
|
|
|
|
|
return 2;
|
|
|
|
|
|
2020-12-11 04:42:30 +00:00
|
|
|
|
var origin = pkm.Generation;
|
2019-02-22 04:41:04 +00:00
|
|
|
|
if (!pkm.HasOriginalMetLocation && generation != origin)
|
2018-06-20 00:14:22 +00:00
|
|
|
|
return pkm.Met_Level;
|
|
|
|
|
|
2019-09-10 07:21:51 +00:00
|
|
|
|
// gen 3 and prior can't obtain anything at level 1
|
2019-02-22 04:41:04 +00:00
|
|
|
|
if (origin <= 3)
|
2018-06-20 00:14:22 +00:00
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|