2022-08-27 06:43:36 +00:00
|
|
|
using static PKHeX.Core.Encounters8Nest;
|
2019-11-24 06:23:43 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Generation 8 Nest Encounter (Distributed Data)
|
|
|
|
/// </summary>
|
|
|
|
/// <inheritdoc cref="EncounterStatic8Nest{T}"/>
|
|
|
|
public sealed record EncounterStatic8ND : EncounterStatic8Nest<EncounterStatic8ND>
|
2019-11-19 03:23:01 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
2022-06-18 18:04:24 +00:00
|
|
|
/// Distribution raid index for <see cref="GameVersion.SWSH"/>
|
2019-11-19 03:23:01 +00:00
|
|
|
/// </summary>
|
2022-06-18 18:04:24 +00:00
|
|
|
public byte Index { get; init; }
|
|
|
|
|
|
|
|
public EncounterStatic8ND(byte lvl, byte dyna, byte flawless, GameVersion game = GameVersion.SWSH) : base(game)
|
2019-11-19 03:23:01 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
Level = lvl;
|
|
|
|
DynamaxLevel = dyna;
|
|
|
|
FlawlessIVCount = flawless;
|
|
|
|
}
|
2021-04-18 18:01:42 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
protected override bool IsMatchLevel(PKM pk, EvoCriteria evo)
|
|
|
|
{
|
|
|
|
var lvl = pk.Met_Level;
|
2019-11-24 06:23:43 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
if (lvl <= 25) // 1 or 2 stars
|
2020-12-26 17:31:21 +00:00
|
|
|
{
|
2022-08-27 06:43:36 +00:00
|
|
|
var met = pk.Met_Location;
|
|
|
|
if (met <= byte.MaxValue && InaccessibleRank12DistributionLocations.Contains((byte)met))
|
2022-06-18 18:04:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
2021-04-23 05:32:17 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
if (lvl == Level)
|
|
|
|
return true;
|
2021-04-23 05:32:17 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
// Check downleveled (20-55)
|
|
|
|
if (lvl > Level)
|
|
|
|
return false;
|
|
|
|
if (lvl is < 20 or > 55)
|
|
|
|
return false;
|
2020-12-26 17:31:21 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
if (lvl % 5 != 0)
|
|
|
|
return false;
|
2020-12-26 17:31:21 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
// shared nests can be down-leveled to any
|
|
|
|
if (pk.Met_Location == SharedNest)
|
|
|
|
return true;
|
2020-12-26 17:31:21 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
// native down-levels: only allow 1 rank down (1 badge 2star -> 25), (3badge 3star -> 35)
|
|
|
|
var badges = (lvl - 20) / 5;
|
|
|
|
return badges is 1 or 3 && !pk.IsShiny;
|
|
|
|
}
|
2020-12-26 17:31:21 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
protected override bool IsMatchLocation(PKM pk)
|
|
|
|
{
|
|
|
|
var loc = pk.Met_Location;
|
|
|
|
return loc is SharedNest || Index switch
|
2019-11-24 06:23:43 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
>= 40 => EncounterArea8.IsWildArea(loc),
|
|
|
|
>= 25 => EncounterArea8.IsWildArea8(loc) || EncounterArea8.IsWildArea8Armor(loc),
|
|
|
|
_ => EncounterArea8.IsWildArea8(loc),
|
|
|
|
};
|
|
|
|
}
|
2019-11-24 06:23:43 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override bool IsMatchExact(PKM pk, EvoCriteria evo)
|
|
|
|
{
|
|
|
|
if (pk.FlawlessIVCount < FlawlessIVCount)
|
|
|
|
return false;
|
2019-11-24 06:23:43 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
return base.IsMatchExact(pk, evo);
|
2019-11-19 03:23:01 +00:00
|
|
|
}
|
2020-06-22 15:07:50 +00:00
|
|
|
}
|