From b9652a835db6b87367c0c6a5cdcaa3a52caa7760 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 12 Jun 2018 18:46:31 -0700 Subject: [PATCH] Weaken gen2 egg species checks for pre-evos in gen1 VC can inhabit both gens Add Tradeback setting setter for legality tests Add GBCartEra setting setter for legality tests Thanks @iiippppk ! --- PKHeX.Core/Legality/Core.cs | 4 ++-- .../Encounters/Generator/EncounterGenerator.cs | 3 +-- PKHeX.Core/Legality/Moves/MoveEgg.cs | 5 +++-- PKHeX.Core/PKM/PKM.cs | 4 ++-- ... - エビワラー - 68EC Gen2 Future-Gen Evo Egg.pk1 | Bin 0 -> 59 bytes .../107 ★ - エビワラー - F5486DD483CC.pk7 | Bin 0 -> 232 bytes Tests/PKHeX.Tests/Legality/LegalityTests.cs | 2 ++ 7 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 Tests/PKHeX.Tests/Legality/Legal/Generation 1 Tradeback/107 ★ - エビワラー - 68EC Gen2 Future-Gen Evo Egg.pk1 create mode 100644 Tests/PKHeX.Tests/Legality/Legal/Generation 7 Transfer/107 ★ - エビワラー - F5486DD483CC.pk7 diff --git a/PKHeX.Core/Legality/Core.cs b/PKHeX.Core/Legality/Core.cs index 999343290..5f4d2f91a 100644 --- a/PKHeX.Core/Legality/Core.cs +++ b/PKHeX.Core/Legality/Core.cs @@ -814,9 +814,9 @@ private static ICollection GetSplitBreedGeneration(int generation) } internal static int GetMaxSpeciesOrigin(PKM pkm) { - if (pkm.Format == 1 || pkm.VC1) // Gen1 VC could not trade with gen 2 yet + if (pkm.Format == 1) return GetMaxSpeciesOrigin(1); - if (pkm.Format == 2 || pkm.VC2) + if (pkm.Format == 2 || pkm.VC) return GetMaxSpeciesOrigin(2); return GetMaxSpeciesOrigin(pkm.GenNumber); } diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs index 684046a22..9796e850b 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs @@ -41,9 +41,8 @@ public static IEnumerable GetEncounters(PKM pkm, LegalInfo info) private static IEnumerable GetEncounters12(PKM pkm, LegalInfo info) { int baseSpecies = GetBaseSpecies(pkm); - bool g1 = pkm.VC1 || pkm.Format == 1; - if (g1 && baseSpecies > MaxSpeciesID_1 || baseSpecies > MaxSpeciesID_2) + if ((pkm.Format == 1 && baseSpecies > MaxSpeciesID_1) || baseSpecies > MaxSpeciesID_2) yield break; foreach (var z in GenerateFilteredEncounters(pkm)) diff --git a/PKHeX.Core/Legality/Moves/MoveEgg.cs b/PKHeX.Core/Legality/Moves/MoveEgg.cs index dc4cd0b14..1a49d5c88 100644 --- a/PKHeX.Core/Legality/Moves/MoveEgg.cs +++ b/PKHeX.Core/Legality/Moves/MoveEgg.cs @@ -7,11 +7,12 @@ internal static class MoveEgg { internal static int[] GetEggMoves(PKM pkm, int species, int formnum, GameVersion version) { - if (!pkm.InhabitedGeneration(pkm.GenNumber, species) || pkm.PersonalInfo.Gender == 255 && !FixedGenderFromBiGender.Contains(species)) + int gen = pkm.Format <= 2 || pkm.VC ? 2 : pkm.GenNumber; + if (!pkm.InhabitedGeneration(gen, species) || pkm.PersonalInfo.Gender == 255 && !FixedGenderFromBiGender.Contains(species)) return new int[0]; if (version == GameVersion.Any) version = (GameVersion)pkm.Version; - return GetEggMoves(pkm.GenNumber, species, formnum, version); + return GetEggMoves(gen, species, formnum, version); } private static int[] GetEggMoves(int gen, int species, int formnum, GameVersion version) { diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index de222f47d..0f463f40b 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -569,8 +569,8 @@ public bool InhabitedGeneration(int Generation, int species = -1) int gen = GenNumber; switch (Generation) { - case 1: return Format == 1 || VC1; - case 2: return Format == 2 || VC2; + case 1: return Format == 1 || VC; // species compat checked via sanity above + case 2: return Format == 2 || VC; case 3: return Gen3; case 4: return 3 <= gen && gen <= 4; case 5: return 3 <= gen && gen <= 5; diff --git a/Tests/PKHeX.Tests/Legality/Legal/Generation 1 Tradeback/107 ★ - エビワラー - 68EC Gen2 Future-Gen Evo Egg.pk1 b/Tests/PKHeX.Tests/Legality/Legal/Generation 1 Tradeback/107 ★ - エビワラー - 68EC Gen2 Future-Gen Evo Egg.pk1 new file mode 100644 index 0000000000000000000000000000000000000000..1d30b8d3ac2d53a04c8471ac89a8f2e5beec16f4 GIT binary patch literal 59 vcmZS7`LDykAi}`N$k4$61Y8XA4*%ic*QzTZK?GRY7!a^_Nwd_-rH=yuKo%7T literal 0 HcmV?d00001 diff --git a/Tests/PKHeX.Tests/Legality/Legal/Generation 7 Transfer/107 ★ - エビワラー - F5486DD483CC.pk7 b/Tests/PKHeX.Tests/Legality/Legal/Generation 7 Transfer/107 ★ - エビワラー - F5486DD483CC.pk7 new file mode 100644 index 0000000000000000000000000000000000000000..87e39090f8cce5f84901eb96103cd2aa802dc47b GIT binary patch literal 232 zcmX@pd?lBG!Q*Q-0|NsW5Ie{-FsQQt8Be*N0!e~kg~4Tm_XaNw{urPu?SKl10BL3v z$)EMIb^#3D3?2-r3=t?YU=Aa@A+n$w10xG7T;RRI5)7Lll5TJ{LTo%hwrwek2!paA JJ0l}V0sxr|6aWAK literal 0 HcmV?d00001 diff --git a/Tests/PKHeX.Tests/Legality/LegalityTests.cs b/Tests/PKHeX.Tests/Legality/LegalityTests.cs index e252c7a18..5323ae459 100644 --- a/Tests/PKHeX.Tests/Legality/LegalityTests.cs +++ b/Tests/PKHeX.Tests/Legality/LegalityTests.cs @@ -61,6 +61,8 @@ private static void VerifyAll(string folder, string name, bool IsValid) var pkm = PKMConverter.GetPKMfromBytes(data, prefer: format); Assert.IsNotNull(pkm, $"Failed to load PKM: {new FileInfo(file).Name}."); + Legal.AllowGBCartEra = fi.DirectoryName.Contains("GBCartEra"); + Legal.AllowGen1Tradeback = fi.DirectoryName.Contains("1 Tradeback"); var legality = new LegalityAnalysis(pkm); Assert.IsTrue(legality.Valid == IsValid, $"Failed to validate PKM as {(IsValid ? "Valid" : "Invalid")}: {fi.Directory.Name}\\{fi.Name}."); }