2019-11-21 01:07:51 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
2019-11-19 03:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generation 8 Nest Encounter (Raid)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class EncounterStatic8N : EncounterStatic, IGigantamax, IDynamaxLevel
|
|
|
|
|
{
|
|
|
|
|
public bool CanGigantamax { get; set; }
|
|
|
|
|
public byte DynamaxLevel { get; set; }
|
|
|
|
|
|
2019-11-20 02:02:57 +00:00
|
|
|
|
private readonly uint MinRank;
|
|
|
|
|
private readonly uint MaxRank;
|
2019-11-21 01:07:51 +00:00
|
|
|
|
private readonly byte NestID;
|
|
|
|
|
|
2019-11-21 07:02:31 +00:00
|
|
|
|
private const int OnlineNest = 162;
|
|
|
|
|
|
2019-11-21 01:07:51 +00:00
|
|
|
|
private IReadOnlyList<byte> NestLocations => Encounters8Nest.NestLocations[NestID];
|
|
|
|
|
|
2019-11-21 07:02:31 +00:00
|
|
|
|
public override int Location { get => OnlineNest; set { } }
|
2019-11-19 03:23:01 +00:00
|
|
|
|
|
2019-11-21 01:07:51 +00:00
|
|
|
|
public EncounterStatic8N(byte nestID, uint minRank, uint maxRank, byte val)
|
2019-11-19 03:23:01 +00:00
|
|
|
|
{
|
2019-11-21 01:07:51 +00:00
|
|
|
|
NestID = nestID;
|
2019-11-19 03:23:01 +00:00
|
|
|
|
MinRank = minRank;
|
|
|
|
|
MaxRank = maxRank;
|
|
|
|
|
DynamaxLevel = val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly int[] LevelCaps =
|
|
|
|
|
{
|
|
|
|
|
15, 20, // 0
|
|
|
|
|
25, 30, // 1
|
|
|
|
|
35, 40, // 2
|
|
|
|
|
45, 50, // 3
|
|
|
|
|
55, 60, // 4
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
protected override int GetMinimalLevel() => LevelCaps[MinRank * 2];
|
|
|
|
|
|
|
|
|
|
protected override bool IsMatchLevel(PKM pkm, int lvl)
|
|
|
|
|
{
|
|
|
|
|
var metLevel = pkm.Met_Level - 15;
|
2019-11-20 02:02:57 +00:00
|
|
|
|
var rank = (uint)(metLevel / 10);
|
|
|
|
|
if (rank > 4)
|
2019-11-19 03:23:01 +00:00
|
|
|
|
return false;
|
|
|
|
|
if (rank < MinRank || MaxRank < rank)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return metLevel % 10 <= 5;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-21 01:07:51 +00:00
|
|
|
|
protected override bool IsMatchLocation(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
var loc = pkm.Met_Location;
|
2019-11-21 07:02:31 +00:00
|
|
|
|
return loc == OnlineNest || loc <= 255 && NestLocations.Contains((byte)loc);
|
2019-11-21 01:07:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-19 03:23:01 +00:00
|
|
|
|
public override bool IsMatch(PKM pkm, int lvl)
|
|
|
|
|
{
|
|
|
|
|
if (pkm is IDynamaxLevel d && d.DynamaxLevel < DynamaxLevel)
|
|
|
|
|
return false;
|
|
|
|
|
|
2019-11-21 01:07:51 +00:00
|
|
|
|
if (pkm.FlawlessIVCount < MinRank + 1)
|
2019-11-19 03:23:01 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return base.IsMatch(pkm, lvl);
|
|
|
|
|
}
|
2019-11-22 04:02:08 +00:00
|
|
|
|
|
|
|
|
|
public override bool IsMatchDeferred(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
if (base.IsMatchDeferred(pkm))
|
|
|
|
|
return true;
|
2019-11-22 04:05:20 +00:00
|
|
|
|
if (Ability == Encounters8Nest.A3 && pkm.AbilityNumber == 4)
|
|
|
|
|
return false;
|
2019-11-22 04:02:08 +00:00
|
|
|
|
if (pkm is IGigantamax g && g.CanGigantamax != CanGigantamax)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2019-11-19 03:23:01 +00:00
|
|
|
|
}
|
2019-11-22 04:03:02 +00:00
|
|
|
|
}
|