From a10048814226154191fee4287beb429617bc226d Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 17 Jul 2018 16:54:23 -0700 Subject: [PATCH] add gen12 generator kadabra catch rate case https://projectpokemon.org/home/forums/topic/46259-yellow-kadabra/ Thanks Cloud AC ! update misc verifier for catchrate to better indicate for any->nontradeback scenarios --- .../Encounters/Generator/EncounterGenerator.cs | 6 +++++- PKHeX.Core/Legality/Verifiers/MiscVerifier.cs | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs index af1819d77..852775c19 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs @@ -184,6 +184,10 @@ namespace PKHeX.Core private static IEnumerable GenerateFilteredEncounters(PKM pkm) { bool crystal = pkm.Format == 2 && pkm.Met_Location != 0 || pkm.Format >= 7 && pkm.OT_Gender == 1; + bool kadabra = pkm.Species == 64 && pkm is PK1 pk1 + && (pk1.Catch_Rate == PersonalTable.RB[64].CatchRate + || pk1.Catch_Rate == PersonalTable.Y[64].CatchRate); // catch rate outsider, return gen1 first always + var g1i = new PeekEnumerator(get1()); var g2i = new PeekEnumerator(get2()); var deferred = new List(); @@ -193,7 +197,7 @@ namespace PKHeX.Core var obj = move.Peek(); if ((obj.Generation == 1 && (pkm.Korean || (obj.Encounter is EncounterTrade t && !IsEncounterTrade1Valid(pkm, t)))) - || (obj.Generation == 2 && (pkm.Korean && (obj.Encounter is IVersion v && v.Version == GameVersion.C)))) + || (obj.Generation == 2 && (pkm.Korean && (obj.Encounter is IVersion v && v.Version == GameVersion.C) || kadabra))) deferred.Add(obj); else yield return obj; diff --git a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs index f3d80cc8f..edfff77dd 100644 --- a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs @@ -83,13 +83,13 @@ namespace PKHeX.Core } private void VerifyMiscG1CatchRate(LegalityAnalysis data, PK1 pk1) { - var EncounterMatch = data.EncounterMatch; + var e = data.EncounterMatch; var catch_rate = pk1.Catch_Rate; switch (pk1.TradebackStatus) { case TradebackType.Any: case TradebackType.WasTradeback: - if (catch_rate == 0 || Legal.HeldItems_GSC.Contains((ushort)catch_rate)) + if (catch_rate == 0 || (Legal.HeldItems_GSC.Contains((ushort)catch_rate) && !RateMatchesEncounter(e.Species))) data.AddLine(GetValid(V394)); else if (pk1.TradebackStatus == TradebackType.WasTradeback) data.AddLine(GetInvalid(V395)); @@ -97,17 +97,26 @@ namespace PKHeX.Core goto case TradebackType.Gen1_NotTradeback; break; case TradebackType.Gen1_NotTradeback: - if ((EncounterMatch as EncounterStatic)?.Version == GameVersion.Stadium || EncounterMatch is EncounterTradeCatchRate) + if ((e as EncounterStatic)?.Version == GameVersion.Stadium || e is EncounterTradeCatchRate) // Encounters detected by the catch rate, cant be invalid if match this encounters data.AddLine(GetValid(V398)); else if (pk1.Species == 149 && catch_rate == PersonalTable.Y[149].CatchRate || Legal.Species_NotAvailable_CatchRate.Contains(pk1.Species) && catch_rate == PersonalTable.RB[pk1.Species].CatchRate) data.AddLine(GetInvalid(V396)); - else if (!data.Info.EvoChainsAllGens[1].Any(e => catch_rate == PersonalTable.RB[e.Species].CatchRate || catch_rate == PersonalTable.Y[e.Species].CatchRate)) + else if (!data.Info.EvoChainsAllGens[1].Any(c => RateMatchesEncounter(c.Species))) data.AddLine(GetInvalid(pk1.Gen1_NotTradeback ? V397 : V399)); else data.AddLine(GetValid(V398)); break; } + + bool RateMatchesEncounter(int species) + { + if (catch_rate == PersonalTable.RB[species].CatchRate) + return true; + if (catch_rate == PersonalTable.Y[species].CatchRate) + return true; + return false; + } } private static void VerifyMiscFatefulEncounter(LegalityAnalysis data) {