From 54525da20b002eec920b6458f33cea6631080dcf Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 20 Apr 2024 13:59:24 -0500 Subject: [PATCH] Add tradeback wipe of Gen2 initial moves --- .../Encounters/Information/EncounterDate.cs | 2 +- .../Legality/LearnSource/Group/LearnGroup2.cs | 20 +++++++++++++++++- .../Verify/LearnVerifierHistory.cs | 3 ++- .../0061 - Poliwhirl - 4B4A648BA093.pk7 | Bin 0 -> 260 bytes .../0149 - Dragonite - B1A1E209D2E0.pk7 | Bin 0 -> 260 bytes .../0149 - Dragonite - D1C5E209D2E0.pk7 | Bin 0 -> 260 bytes 6 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 Tests/PKHeX.Core.Tests/Legality/Illegal/Gen2 Tradeback/0061 - Poliwhirl - 4B4A648BA093.pk7 create mode 100644 Tests/PKHeX.Core.Tests/Legality/Illegal/Gen2 Tradeback/0149 - Dragonite - B1A1E209D2E0.pk7 create mode 100644 Tests/PKHeX.Core.Tests/Legality/Illegal/Gen2 Tradeback/0149 - Dragonite - D1C5E209D2E0.pk7 diff --git a/PKHeX.Core/Legality/Encounters/Information/EncounterDate.cs b/PKHeX.Core/Legality/Encounters/Information/EncounterDate.cs index 70f0abe40..2d1101c67 100644 --- a/PKHeX.Core/Legality/Encounters/Information/EncounterDate.cs +++ b/PKHeX.Core/Legality/Encounters/Information/EncounterDate.cs @@ -70,7 +70,7 @@ public static bool IsValidDate3DS(DateOnly date) /// public static bool IsValidDateSwitch(DateOnly date) { - if (date.Year is < 2000 or > 2050) + if (date.Year is < 2000 or > 2060) return false; return true; } diff --git a/PKHeX.Core/Legality/LearnSource/Group/LearnGroup2.cs b/PKHeX.Core/Legality/LearnSource/Group/LearnGroup2.cs index 6390e76cc..ba637d17e 100644 --- a/PKHeX.Core/Legality/LearnSource/Group/LearnGroup2.cs +++ b/PKHeX.Core/Legality/LearnSource/Group/LearnGroup2.cs @@ -38,7 +38,25 @@ public sealed class LearnGroup2 : ILearnGroup if (enc is EncounterEgg { Generation: Generation } egg) CheckEncounterMoves(result, current, egg); - return MoveResult.AllParsed(result); + bool vc1 = pk.VC1; + if (!vc1 && MoveResult.AllParsed(result)) + return true; + + // Uh-oh, not all moves are verified yet. + // To visit Gen1, we need to invalidate moves that can't be learned in Gen1 or re-learned in Gen2. + for (int i = 0; i < result.Length; i++) + { + if (current[i] <= Legal.MaxMoveID_1) + continue; + var move = result[i]; + if (!move.IsParsed) + continue; + var method = move.Info.Method; + if ((vc1 && move.Generation == 2) || method is LearnMethod.Initial || method.IsEggSource()) + result[i] = MoveResult.Unobtainable(); + } + + return false; } private static void CheckEncounterMoves(PKM pk, Span result, ReadOnlySpan current, IEncounterTemplate enc) diff --git a/PKHeX.Core/Legality/LearnSource/Verify/LearnVerifierHistory.cs b/PKHeX.Core/Legality/LearnSource/Verify/LearnVerifierHistory.cs index 3afbd592a..752ad3e39 100644 --- a/PKHeX.Core/Legality/LearnSource/Verify/LearnVerifierHistory.cs +++ b/PKHeX.Core/Legality/LearnSource/Verify/LearnVerifierHistory.cs @@ -32,7 +32,8 @@ public static void Verify(Span result, ReadOnlySpan current, MarkRelearnMoves(result, current, pk); // Knock off initial moves if available. - MarkSpecialMoves(result, current, enc, pk); + if (enc.Generation != 2) // Handle trade-backs in Gen2 separately. + MarkSpecialMoves(result, current, enc, pk); } // Iterate games to identify move sources. diff --git a/Tests/PKHeX.Core.Tests/Legality/Illegal/Gen2 Tradeback/0061 - Poliwhirl - 4B4A648BA093.pk7 b/Tests/PKHeX.Core.Tests/Legality/Illegal/Gen2 Tradeback/0061 - Poliwhirl - 4B4A648BA093.pk7 new file mode 100644 index 0000000000000000000000000000000000000000..39d8780631d0436cef34a3a9a36565fb0f03d737 GIT binary patch literal 260 zcmbQdpgVO84g-T510xH9 sk6WJ`T#*EeAdu}?$|A|2VaU!1_XW_S4E&7zj8hqwF}!8y073`=0GXv2`~Uy| literal 0 HcmV?d00001 diff --git a/Tests/PKHeX.Core.Tests/Legality/Illegal/Gen2 Tradeback/0149 - Dragonite - B1A1E209D2E0.pk7 b/Tests/PKHeX.Core.Tests/Legality/Illegal/Gen2 Tradeback/0149 - Dragonite - B1A1E209D2E0.pk7 new file mode 100644 index 0000000000000000000000000000000000000000..8ee95d4ff0ac5a1df58feb3fe62bcd4c46a82f59 GIT binary patch literal 260 zcmaEGiSrQy!@`YI85kHW4Hy_M2njQEu!OQYG$efx0*ax74h9Yeh6BuSVHbuXhD3&R zhJ1!RhD?SMhE%xBS11dpo&ljAB>4aTfBOIiZw3#b>IkSRB#M#U5Q)d2%)rRP4i~_! bPZ_R8f<+L>wk>7hXHYg|XJmp);9vj%nqC() literal 0 HcmV?d00001 diff --git a/Tests/PKHeX.Core.Tests/Legality/Illegal/Gen2 Tradeback/0149 - Dragonite - D1C5E209D2E0.pk7 b/Tests/PKHeX.Core.Tests/Legality/Illegal/Gen2 Tradeback/0149 - Dragonite - D1C5E209D2E0.pk7 new file mode 100644 index 0000000000000000000000000000000000000000..db39343379c2177684e522878c1907aa9a0bd88c GIT binary patch literal 260 zcmaEGiSrQy!_kXV85kHW4Hy_M2njQEu!OQYG$efx0*ax74h9Yeh6BuSVHbuXhD3&R zhJ1!RhD?SMhE%wW0>f7@n**qU8KD6v_W%EX`v3-S1`nX>2)KGUgOS}3&IU4+85mjE e;R3kzDZ|xBum}R#j-@Pe44Q`Qj7)F|91H;ax);0v literal 0 HcmV?d00001