From 15779513f535dd4a834267a5a455de0731c75ef1 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 3 Jan 2020 20:03:04 -0800 Subject: [PATCH] Add stubs for raid correlation verifiers/generators Not going to implement this within the base repo as z3 is too large of a dependency and is platform specific. If anyone wants to implement as a plugin project, just inject your new methods via the setters on the static func/action at the top of the 3 classes. Since z3's searches aren't instant, I'd recommend caching recent results in a dictionary, as re-parses are common. Something like the Wordfilter is what you'd be aiming for :) Closes #2617 --- .../Legality/Encounters/EncounterStatic8N.cs | 17 ++++++++++++++++- .../Legality/Encounters/EncounterStatic8NC.cs | 17 ++++++++++++++++- .../Legality/Encounters/EncounterStatic8ND.cs | 17 ++++++++++++++++- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic8N.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic8N.cs index a2b4c1a7a..dbf5de619 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic8N.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic8N.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using static PKHeX.Core.Encounters8Nest; @@ -9,6 +10,9 @@ namespace PKHeX.Core /// public sealed class EncounterStatic8N : EncounterStatic, IGigantamax, IDynamaxLevel { + public static Func? VerifyCorrelation { private get; set; } + public static Action? GenerateData { private get; set; } + public bool CanGigantamax { get; set; } public byte DynamaxLevel { get; set; } @@ -83,6 +87,9 @@ namespace PKHeX.Core if (Version != GameVersion.SWSH && pkm.Version != (int) Version && pkm.Met_Location != SharedNest) return false; + if (VerifyCorrelation != null && !VerifyCorrelation(pkm, this)) + return false; + return base.IsMatch(pkm, lvl); } @@ -97,5 +104,13 @@ namespace PKHeX.Core return false; } + + protected override void SetPINGA(PKM pk, EncounterCriteria criteria) + { + if (GenerateData != null) + GenerateData(pk, this, criteria); + else + base.SetPINGA(pk, criteria); + } } } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic8NC.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic8NC.cs index a2006223d..a7cd48f57 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic8NC.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic8NC.cs @@ -1,4 +1,5 @@ -using static PKHeX.Core.Encounters8Nest; +using System; +using static PKHeX.Core.Encounters8Nest; namespace PKHeX.Core { @@ -7,6 +8,9 @@ namespace PKHeX.Core /// public sealed class EncounterStatic8NC : EncounterStatic, IGigantamax, IDynamaxLevel { + public static Func? VerifyCorrelation { private get; set; } + public static Action? GenerateData { private get; set; } + public bool CanGigantamax { get; set; } public byte DynamaxLevel { get; set; } public override int Location { get => SharedNest; set { } } @@ -25,6 +29,9 @@ namespace PKHeX.Core if (Version != GameVersion.SWSH && pkm.Version != (int)Version && pkm.Met_Location != SharedNest) return false; + if (VerifyCorrelation != null && !VerifyCorrelation(pkm, this)) + return false; + return base.IsMatch(pkm, lvl); } @@ -39,5 +46,13 @@ namespace PKHeX.Core return false; } + + protected override void SetPINGA(PKM pk, EncounterCriteria criteria) + { + if (GenerateData != null) + GenerateData(pk, this, criteria); + else + base.SetPINGA(pk, criteria); + } } } \ No newline at end of file diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic8ND.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic8ND.cs index f967fe02e..28843a1b0 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic8ND.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic8ND.cs @@ -1,4 +1,5 @@ -using static PKHeX.Core.Encounters8Nest; +using System; +using static PKHeX.Core.Encounters8Nest; namespace PKHeX.Core { @@ -7,6 +8,9 @@ namespace PKHeX.Core /// public sealed class EncounterStatic8ND : EncounterStatic, IGigantamax, IDynamaxLevel { + public static Func? VerifyCorrelation { private get; set; } + public static Action? GenerateData { private get; set; } + public bool CanGigantamax { get; set; } public byte DynamaxLevel { get; set; } public override int Location { get => SharedNest; set { } } @@ -35,6 +39,9 @@ namespace PKHeX.Core if (Version != GameVersion.SWSH && pkm.Version != (int)Version && pkm.Met_Location != SharedNest) return false; + if (VerifyCorrelation != null && !VerifyCorrelation(pkm, this)) + return false; + return base.IsMatch(pkm, lvl); } @@ -49,5 +56,13 @@ namespace PKHeX.Core return false; } + + protected override void SetPINGA(PKM pk, EncounterCriteria criteria) + { + if (GenerateData != null) + GenerateData(pk, this, criteria); + else + base.SetPINGA(pk, criteria); + } } } \ No newline at end of file