From c751c987a9cf3254366ec2fba56b2647ba22b2ab Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 10 Jan 2018 15:40:33 -0800 Subject: [PATCH] Add DebutGeneration get https://projectpokemon.org/home/forums/topic/43378-generation-search-in-pkmdb-andor-batch-editor/ (less than) < and (greater than) > not currently supported (no plan to add, would need to rewrite value eval logic) --- PKHeX.Core/Legality/Core.cs | 20 ++++++++++++++++++++ PKHeX.Core/PKM/PKM.cs | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/PKHeX.Core/Legality/Core.cs b/PKHeX.Core/Legality/Core.cs index 29964e451..444403160 100644 --- a/PKHeX.Core/Legality/Core.cs +++ b/PKHeX.Core/Legality/Core.cs @@ -1106,6 +1106,26 @@ internal static IEnumerable GetFutureGenEvolutions(int generation) default: return Enumerable.Empty(); } } + internal static int GetDebutGeneration(int species) + { + if (species <= 0) + return 0; + if (species <= MaxSpeciesID_1) + return 1; + if (species <= MaxSpeciesID_2) + return 2; + if (species <= MaxSpeciesID_3) + return 3; + if (species <= MaxSpeciesID_4) + return 4; + if (species <= MaxSpeciesID_5) + return 5; + if (species <= MaxSpeciesID_6) + return 6; + if (species <= MaxSpeciesID_7_USUM) + return 7; + return -1; + } internal static int GetMaxLanguageID(int generation) { diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index cea9896bc..99935ecf4 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -321,8 +321,9 @@ public int GenNumber if (VC1) return 1; if (VC2) return 2; return -1; - } + } } + public int DebutGeneration => Legal.GetDebutGeneration(Species); public bool PKRS_Infected => PKRS_Strain > 0; public bool PKRS_Cured => PKRS_Days == 0 && PKRS_Strain > 0; public virtual bool ChecksumValid => Checksum == CalculateChecksum();