2020-01-04 19:44:16 +00:00
|
|
|
|
using System;
|
|
|
|
|
using static PKHeX.Core.Encounters8Nest;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
|
|
|
|
public abstract class EncounterStatic8Nest<T> : EncounterStatic, IGigantamax, IDynamaxLevel where T : EncounterStatic8Nest<T>
|
|
|
|
|
{
|
2020-08-30 23:10:24 +00:00
|
|
|
|
public 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; }
|
|
|
|
|
public override int Location { get => SharedNest; set { } }
|
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
protected override bool IsMatchLevel(PKM pkm, DexLevel evo)
|
2020-01-04 19:44:16 +00:00
|
|
|
|
{
|
2020-08-21 23:35:49 +00:00
|
|
|
|
var lvl = pkm.Met_Level;
|
2020-01-04 19:44:16 +00:00
|
|
|
|
if (lvl == Level)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
// Check downleveled (20-55)
|
|
|
|
|
if (lvl > Level)
|
|
|
|
|
return false;
|
|
|
|
|
if (lvl < 20 || lvl > 55)
|
|
|
|
|
return false;
|
|
|
|
|
return lvl % 5 == 0;
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsMatchDeferred(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
if (base.IsMatchDeferred(pkm))
|
|
|
|
|
return true;
|
2020-08-17 06:06:49 +00:00
|
|
|
|
if (pkm is IGigantamax g && g.CanGigantamax != CanGigantamax && !g.CanToggleGigantamax(pkm.Species, pkm.AltForm, Species, Form))
|
2020-01-04 19:44:16 +00:00
|
|
|
|
return true;
|
2020-02-09 23:04:45 +00:00
|
|
|
|
if (Species == (int)Core.Species.Alcremie && pkm is IFormArgument a && a.FormArgument != 0)
|
|
|
|
|
return true;
|
|
|
|
|
if (Species == (int)Core.Species.Runerigus && pkm is IFormArgument r && r.FormArgument != 0)
|
|
|
|
|
return true;
|
2020-01-04 19:44:16 +00:00
|
|
|
|
|
2020-06-20 18:14:44 +00:00
|
|
|
|
if (Ability != -1) // Any
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
if (Ability == 4 && pkm.AbilityNumber != 4)
|
|
|
|
|
return true; // H
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void SetPINGA(PKM pk, EncounterCriteria criteria)
|
|
|
|
|
{
|
|
|
|
|
if (GenerateData != null)
|
|
|
|
|
GenerateData(pk, (T)this, criteria);
|
|
|
|
|
else
|
|
|
|
|
base.SetPINGA(pk, criteria);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|