2020-01-04 19:44:16 +00:00
|
|
|
|
using System;
|
|
|
|
|
using static PKHeX.Core.Encounters8Nest;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2020-11-27 19:51:02 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generation 8 Nest Encounter (Raid)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <inheritdoc cref="EncounterStatic"/>
|
2020-12-24 04:40:59 +00:00
|
|
|
|
public abstract record EncounterStatic8Nest<T> : EncounterStatic, IGigantamax, IDynamaxLevel where T : EncounterStatic8Nest<T>
|
2020-01-04 19:44:16 +00:00
|
|
|
|
{
|
2020-11-27 19:51:02 +00:00
|
|
|
|
public sealed override int Generation => 8;
|
2020-01-04 19:44:16 +00:00
|
|
|
|
public static Func<PKM, T, bool>? VerifyCorrelation { private get; set; }
|
|
|
|
|
public static Action<PKM, T, EncounterCriteria>? GenerateData { private get; set; }
|
|
|
|
|
|
|
|
|
|
public bool CanGigantamax { get; set; }
|
|
|
|
|
public byte DynamaxLevel { get; set; }
|
2020-12-22 01:05:05 +00:00
|
|
|
|
public override int Location { get => SharedNest; init { } }
|
2020-01-04 19:44:16 +00:00
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
public override bool IsMatch(PKM pkm, DexLevel evo)
|
2020-01-04 19:44:16 +00:00
|
|
|
|
{
|
|
|
|
|
if (pkm is IDynamaxLevel d && d.DynamaxLevel < DynamaxLevel)
|
|
|
|
|
return false;
|
|
|
|
|
|
2020-12-03 05:39:45 +00:00
|
|
|
|
// Required Ability
|
|
|
|
|
if (Ability == 4 && pkm.AbilityNumber != 4)
|
|
|
|
|
return false; // H
|
|
|
|
|
|
2020-01-04 19:44:16 +00:00
|
|
|
|
if (Version != GameVersion.SWSH && pkm.Version != (int)Version && pkm.Met_Location != SharedNest)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (VerifyCorrelation != null && !VerifyCorrelation(pkm, (T)this))
|
|
|
|
|
return false;
|
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
return base.IsMatch(pkm, evo);
|
2020-01-04 19:44:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-27 19:51:02 +00:00
|
|
|
|
public sealed override bool IsMatchDeferred(PKM pkm)
|
2020-01-04 19:44:16 +00:00
|
|
|
|
{
|
|
|
|
|
if (base.IsMatchDeferred(pkm))
|
|
|
|
|
return true;
|
2020-12-11 04:42:30 +00:00
|
|
|
|
if (pkm is IGigantamax g && g.CanGigantamax != CanGigantamax && !g.CanToggleGigantamax(pkm.Species, pkm.Form, Species, Form))
|
2020-01-04 19:44:16 +00:00
|
|
|
|
return true;
|
2020-12-29 08:58:08 +00:00
|
|
|
|
if (Species == (int)Core.Species.Alcremie && pkm is IFormArgument {FormArgument: not 0})
|
2020-02-09 23:04:45 +00:00
|
|
|
|
return true;
|
2020-12-29 08:58:08 +00:00
|
|
|
|
if (Species == (int)Core.Species.Runerigus && pkm is IFormArgument {FormArgument: not 0})
|
2020-02-09 23:04:45 +00:00
|
|
|
|
return true;
|
2020-01-04 19:44:16 +00:00
|
|
|
|
|
2020-06-20 18:14:44 +00:00
|
|
|
|
if (Ability != -1) // Any
|
|
|
|
|
{
|
2020-12-03 05:39:45 +00:00
|
|
|
|
// HA-Only is a strict match. Ability Capsule and Patch can potentially change these.
|
2020-06-20 18:14:44 +00:00
|
|
|
|
if (Ability == 0 && pkm.AbilityNumber == 4)
|
|
|
|
|
return true; // 0/1
|
|
|
|
|
if (Ability == 1 && pkm.AbilityNumber != 1)
|
|
|
|
|
return true; // 0
|
|
|
|
|
if (Ability == 2 && pkm.AbilityNumber != 2)
|
|
|
|
|
return true; // 1
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-16 01:30:29 +00:00
|
|
|
|
if (Shiny != Shiny.Random)
|
|
|
|
|
{
|
|
|
|
|
if (Shiny == Shiny.Never && pkm.IsShiny)
|
|
|
|
|
return true;
|
|
|
|
|
if (Shiny == Shiny.Always && !pkm.IsShiny)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-04 19:44:16 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-27 19:51:02 +00:00
|
|
|
|
protected sealed override void SetPINGA(PKM pk, EncounterCriteria criteria)
|
2020-01-04 19:44:16 +00:00
|
|
|
|
{
|
|
|
|
|
if (GenerateData != null)
|
|
|
|
|
GenerateData(pk, (T)this, criteria);
|
|
|
|
|
else
|
|
|
|
|
base.SetPINGA(pk, criteria);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|