mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-16 09:08:02 +00:00
21cdf4f642
wonder if it's possible to provide a more lightweight core by pulling out legality stuff to a separate project?
46 lines
2.1 KiB
C#
46 lines
2.1 KiB
C#
using System.Linq;
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
/// <summary>
|
|
/// Verify Evolution Information for a matched <see cref="IEncounterable"/>
|
|
/// </summary>
|
|
public static class EvolutionVerifier
|
|
{
|
|
/// <summary>
|
|
/// Verifies Evolution scenarios of an <see cref="IEncounterable"/> for an input <see cref="PKM"/> and relevant <see cref="LegalInfo"/>.
|
|
/// </summary>
|
|
/// <param name="pkm">Source data to verify</param>
|
|
/// <param name="info">Source supporting information to verify with</param>
|
|
/// <returns></returns>
|
|
public static CheckResult VerifyEvolution(PKM pkm, LegalInfo info)
|
|
{
|
|
return IsValidEvolution(pkm, info)
|
|
? new CheckResult(CheckIdentifier.Evolution)
|
|
: new CheckResult(Severity.Invalid, V86, CheckIdentifier.Evolution);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks if the Evolution from the source <see cref="IEncounterable"/> is valid.
|
|
/// </summary>
|
|
/// <param name="pkm">Source data to verify</param>
|
|
/// <param name="info">Source supporting information to verify with</param>
|
|
/// <returns>Evolution is valid or not</returns>
|
|
private static bool IsValidEvolution(PKM pkm, LegalInfo info)
|
|
{
|
|
int species = pkm.Species;
|
|
if (info.EncounterMatch.Species == species)
|
|
return true;
|
|
if (info.EncounterMatch.EggEncounter && species == 350 && pkm.Format >= 5 && !pkm.IsUntraded) // Prism Scale
|
|
return true;
|
|
if (!Legal.IsEvolutionValid(pkm, info.EncounterMatch.Species))
|
|
return false;
|
|
// If current species evolved with a move evolution and encounter species is not current species check if the evolution by move is valid
|
|
// Only the evolution by move is checked, if there is another evolution before the evolution by move is covered in IsEvolutionValid
|
|
if (Legal.SpeciesEvolutionWithMove.Contains(pkm.Species))
|
|
return Legal.IsEvolutionValidWithMove(pkm, info);
|
|
return true;
|
|
}
|
|
}
|
|
}
|