PKHeX/PKHeX.Core/Legality/Encounters/EncounterStatic8NC.cs
Kurt 15779513f5 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
2020-01-03 20:03:04 -08:00

58 lines
No EOL
1.9 KiB
C#

using System;
using static PKHeX.Core.Encounters8Nest;
namespace PKHeX.Core
{
/// <summary>
/// Generation 8 Nest Encounter (Distributed Crystal Data)
/// </summary>
public sealed class EncounterStatic8NC : EncounterStatic, IGigantamax, IDynamaxLevel
{
public static Func<PKM, EncounterStatic8NC, bool>? VerifyCorrelation { private get; set; }
public static Action<PKM, EncounterStatic8NC, EncounterCriteria>? GenerateData { private get; set; }
public bool CanGigantamax { get; set; }
public byte DynamaxLevel { get; set; }
public override int Location { get => SharedNest; set { } }
protected override bool IsMatchLocation(PKM pkm)
{
var loc = pkm.Met_Location;
return loc == SharedNest || EncounterArea8.IsWildArea8(loc);
}
public override bool IsMatch(PKM pkm, int lvl)
{
if (pkm is IDynamaxLevel d && d.DynamaxLevel < DynamaxLevel)
return false;
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);
}
public override bool IsMatchDeferred(PKM pkm)
{
if (base.IsMatchDeferred(pkm))
return true;
if (Ability != A4 && pkm.AbilityNumber == 4)
return true;
if (pkm is IGigantamax g && g.CanGigantamax != CanGigantamax)
return true;
return false;
}
protected override void SetPINGA(PKM pk, EncounterCriteria criteria)
{
if (GenerateData != null)
GenerateData(pk, this, criteria);
else
base.SetPINGA(pk, criteria);
}
}
}