From 2ef12f635f5a0d251076222cb23c5cf43ac8f8d7 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 20 Jun 2018 15:59:57 -0700 Subject: [PATCH] Continued refactoring move sylveon check to requireslevelup need to make this generic for transfer species gaps --- .../Encounters/Verifiers/EvolutionVerifier.cs | 2 +- PKHeX.Core/Legality/Evolutions/EvolutionChain.cs | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/EvolutionVerifier.cs b/PKHeX.Core/Legality/Encounters/Verifiers/EvolutionVerifier.cs index 0adeed353..d1d26d65d 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/EvolutionVerifier.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/EvolutionVerifier.cs @@ -16,7 +16,7 @@ public static class EvolutionVerifier /// public static CheckResult VerifyEvolution(PKM pkm, LegalInfo info) { - return IsValidEvolution(pkm, info) + return IsValidEvolution(pkm, info) && info.EvoChainsAllGens[pkm.Format].Length >= 1 ? new CheckResult(CheckIdentifier.Evolution) : new CheckResult(Severity.Invalid, V86, CheckIdentifier.Evolution); } diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs b/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs index 5965e27ae..fa53bfb75 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs @@ -40,6 +40,7 @@ internal static EvoCriteria[][] GetEvolutionChainsAllGens(PKM pkm, IEncounterabl private static EvoCriteria[][] TrimEvoChain(PKM pkm, IEncounterable Encounter, EvoCriteria[] CompleteEvoChain, int maxgen, int mingen, EvoCriteria[][] GensEvoChains) { int lvl = pkm.CurrentLevel; + int maxLevel = lvl; int pkGen = pkm.GenNumber; // Iterate generations backwards because level will be decreased from current level in each generation @@ -64,25 +65,28 @@ private static EvoCriteria[][] TrimEvoChain(PKM pkm, IEncounterable Encounter, E // If the pokemon origin is illegal (e.g. Gen3 Infernape) the list will be emptied -- species lineage did not exist at any evolution stage. while (CompleteEvoChain.Length != 0 && CompleteEvoChain[0].Species > maxspeciesgen) { - // Eevee requires a single levelup to be Sylveon, it can be deduced in gen 5 and before it existed with maximum one level below current - if (CompleteEvoChain[0].Species == 700 && g == 5) - lvl--; - if (CompleteEvoChain[0].RequiresLvlUp) { + // Eevee requires a single levelup to be Sylveon, it can be deduced in gen 5 and before it existed with maximum one level below current + if (g == 5 && CompleteEvoChain[0].Species == 700) + lvl--; + // This is a gen 3 pokemon in a gen 4 phase evolution that requieres level up and then transfered to gen 5+ // We can deduce that it existed in gen 4 until met level, // but if current level is met level we can also deduce it existed in gen 3 until maximum met level -1 - if (g == 3 && pkm.Format > 4 && lvl == pkm.CurrentLevel && CompleteEvoChain[0].Species > MaxSpeciesID_3) + else if (g == 3 && pkm.Format > 4 && lvl == maxLevel && CompleteEvoChain[0].Species > maxspeciesgen) lvl--; // The same condition for gen2 evolution of gen 1 pokemon, level of the pokemon in gen 1 games would be CurrentLevel -1 one level below gen 2 level - else if (g == 1 && pkm.Format == 2 && lvl == pkm.CurrentLevel && CompleteEvoChain[0].Species > MaxSpeciesID_1) + else if (g == 1 && pkm.Format == 2 && lvl == maxLevel && CompleteEvoChain[0].Species > maxspeciesgen) lvl--; } CompleteEvoChain = CompleteEvoChain.Skip(1).ToArray(); } + if (CompleteEvoChain.Length == 0) + continue; + // Alolan form evolutions, remove from gens 1-6 chains if (EvolveToAlolanForms.Contains(CompleteEvoChain[0].Species)) {