From b9e32c67a046350e302cead8e509c112e484884c Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 21 Nov 2019 20:02:08 -0800 Subject: [PATCH] Add encounter static deferral oop We've already been doing something similar for the deferral check; just merge the logic into the base object Closes #2489 --- PKHeX.Core/Legality/Encounters/EncounterStatic.cs | 9 +++++++++ PKHeX.Core/Legality/Encounters/EncounterStatic8N.cs | 10 ++++++++++ .../Encounters/Generator/EncounterStaticGenerator.cs | 11 +---------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic.cs index 5263cf94e..60fd9795d 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic.cs @@ -425,5 +425,14 @@ protected virtual bool IsMatchLevel(PKM pkm, int lvl) return true; } + + public virtual bool IsMatchDeferred(PKM pkm) + { + if (pkm.FatefulEncounter != Fateful) + return true; + if (Ability == 4 && pkm.AbilityNumber != 4) // BW/2 Jellicent collision with wild surf slot, resolved by duplicating the encounter with any abil + return true; + return false; + } } } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic8N.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic8N.cs index 0a7d6efb9..2be23dd79 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic8N.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic8N.cs @@ -70,5 +70,15 @@ public override bool IsMatch(PKM pkm, int lvl) return base.IsMatch(pkm, lvl); } + + public override bool IsMatchDeferred(PKM pkm) + { + if (base.IsMatchDeferred(pkm)) + return true; + if (pkm is IGigantamax g && g.CanGigantamax != CanGigantamax) + return true; + + return false; + } } } \ No newline at end of file diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterStaticGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterStaticGenerator.cs index b858dd89a..bfea769cd 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterStaticGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterStaticGenerator.cs @@ -66,7 +66,7 @@ private static IEnumerable GetMatchingStaticEncounters(PKM pkm, if (!GetIsMatchStatic(pkm, e, lvl)) continue; - if (GetIsMatchDeferred(pkm, e)) + if (e.IsMatchDeferred(pkm)) deferred.Add(e); else yield return e; @@ -75,15 +75,6 @@ private static IEnumerable GetMatchingStaticEncounters(PKM pkm, yield return e; } - private static bool GetIsMatchDeferred(PKM pkm, EncounterStatic e) - { - if (pkm.FatefulEncounter != e.Fateful) - return true; - if (e.Ability == 4 && pkm.AbilityNumber != 4) // BW/2 Jellicent collision with wild surf slot, resolved by duplicating the encounter with any abil - return true; - return false; - } - private static bool GetIsMatchStatic(PKM pkm, EncounterStatic e, int lvl) { if (!e.IsMatch(pkm, lvl))