From e571a0b95f6fbe43d929301203ae03b56fc49177 Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 2 Jun 2022 18:32:22 -0700 Subject: [PATCH] Check catchrate tradeback separately Closes #3510 Thanks @CodeWithMa ! --- .../Encounters/EncounterStatic/EncounterStatic1.cs | 2 +- .../Encounters/Generator/EncounterFinder.cs | 12 +++++++++--- PKHeX.Core/PKM/PK1.cs | 4 ++-- .../Generation 1 Only/135 - JOLTEON - 7E45.pk1 | Bin 0 -> 69 bytes 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 Tests/PKHeX.Core.Tests/Legality/Legal/Generation 1 Only/135 - JOLTEON - 7E45.pk1 diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1.cs index e22043121..8cb7b8a74 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1.cs @@ -62,7 +62,7 @@ { if (pkm is not PK1 pk1) return false; - if (PK1.IsCatchRateHeldItem(pk1.Catch_Rate)) + if (ParseSettings.AllowGen1Tradeback && PK1.IsCatchRateHeldItem(pk1.Catch_Rate)) return false; if (IsCatchRateValid(pk1)) return false; diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterFinder.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterFinder.cs index 421740c48..abb6967e3 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterFinder.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterFinder.cs @@ -126,10 +126,16 @@ namespace PKHeX.Core return false; } } - else if (pkm is PK1 pk1 && !ParseSettings.AllowGen1Tradeback) + else if (pkm is PK1 pk1) { - if (!Array.TrueForAll(info.Moves, z => z.Generation is 1) && !PK1.IsCatchRateHeldItem(pk1.Catch_Rate)) - return false; + var hasGen2 = Array.Exists(info.Moves, z => z.Generation is not 1); + if (hasGen2) + { + if (!ParseSettings.AllowGen1Tradeback) + return false; + if (!PK1.IsCatchRateHeldItem(pk1.Catch_Rate)) + return false; + } } info.Parse.Add(evo); diff --git a/PKHeX.Core/PKM/PK1.cs b/PKHeX.Core/PKM/PK1.cs index 4b4317224..a55a90c2c 100644 --- a/PKHeX.Core/PKM/PK1.cs +++ b/PKHeX.Core/PKM/PK1.cs @@ -80,7 +80,7 @@ namespace PKHeX.Core public override int Stat_SPD { get => Stat_SPC; set { } } #endregion - public static bool IsCatchRateHeldItem(int rate) => ParseSettings.AllowGen1Tradeback && Array.IndexOf(Legal.HeldItems_GSC, (ushort)rate) >= 0; + public static bool IsCatchRateHeldItem(int rate) => rate == 0 || Array.IndexOf(Legal.HeldItems_GSC, (ushort)rate) >= 0; private static bool IsCatchRatePreEvolutionRate(int baseSpecies, int finalSpecies, int rate) { @@ -113,7 +113,7 @@ namespace PKHeX.Core private static bool IsValidCatchRateAnyPreEvo(int species, int rate) { - if (rate is 0 || IsCatchRateHeldItem(rate)) + if (IsCatchRateHeldItem(rate)) return true; if (species == (int)Core.Species.Pikachu && rate == 0xA3) // Light Ball (starter) return true; diff --git a/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 1 Only/135 - JOLTEON - 7E45.pk1 b/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 1 Only/135 - JOLTEON - 7E45.pk1 new file mode 100644 index 0000000000000000000000000000000000000000..a1b71f6e60a82e55532a0a25dbfbf2555d5e4db0 GIT binary patch literal 69 zcmZR~_@BYxD#;)&uB$Gin`EBLV9Ut>2gz=7{2FqS46Y0s3@QvB4E7BHaJkOD?#V5E Iy#YV~0D-y;cK`qY literal 0 HcmV?d00001