2020-01-04 19:44:16 +00:00
|
|
|
|
using System.Collections.Generic;
|
2019-11-21 01:07:51 +00:00
|
|
|
|
using System.Linq;
|
2019-11-24 06:23:43 +00:00
|
|
|
|
using static PKHeX.Core.Encounters8Nest;
|
2019-11-21 01:07:51 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
2019-11-19 03:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generation 8 Nest Encounter (Raid)
|
|
|
|
|
/// </summary>
|
2020-01-04 19:44:16 +00:00
|
|
|
|
public sealed class EncounterStatic8N : EncounterStatic8Nest<EncounterStatic8N>
|
2019-11-19 03:23:01 +00:00
|
|
|
|
{
|
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;
|
|
|
|
|
|
|
|
|
|
private IReadOnlyList<byte> NestLocations => Encounters8Nest.NestLocations[NestID];
|
|
|
|
|
|
2019-11-24 06:23:43 +00:00
|
|
|
|
public override int Location { get => SharedNest; set { } }
|
2019-12-07 03:17:26 +00:00
|
|
|
|
public override int Level { get => LevelMin; set { } }
|
|
|
|
|
public override int LevelMin => LevelCaps[MinRank * 2];
|
|
|
|
|
public override int LevelMax => LevelCaps[(MaxRank * 2) + 1];
|
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;
|
2019-11-23 22:46:09 +00:00
|
|
|
|
DynamaxLevel = (byte)(MinRank + 1u);
|
|
|
|
|
FlawlessIVCount = val;
|
2019-11-19 03:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-25 16:52:03 +00:00
|
|
|
|
private static readonly int[] LevelCaps =
|
2019-11-19 03:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
15, 20, // 0
|
|
|
|
|
25, 30, // 1
|
|
|
|
|
35, 40, // 2
|
|
|
|
|
45, 50, // 3
|
|
|
|
|
55, 60, // 4
|
|
|
|
|
};
|
|
|
|
|
|
2019-11-25 16:52:03 +00:00
|
|
|
|
public static bool IsHighestLevelTier(int lvl) => ArrayUtil.WithinRange(lvl, 55, 60);
|
|
|
|
|
|
2019-11-19 03:23:01 +00:00
|
|
|
|
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;
|
2019-12-26 20:59:16 +00:00
|
|
|
|
if (rank > MaxRank)
|
2019-11-19 03:23:01 +00:00
|
|
|
|
return false;
|
2019-12-26 20:59:16 +00:00
|
|
|
|
if (rank < MinRank) // downleveled
|
|
|
|
|
{
|
2019-12-27 08:17:59 +00:00
|
|
|
|
if (metLevel % 5 != 0)
|
|
|
|
|
return false;
|
2020-01-06 02:46:30 +00:00
|
|
|
|
|
|
|
|
|
// shared nests can be downleveled to any; native downlevels: only allow 1 rank down (?)
|
|
|
|
|
if (pkm.Met_Location != SharedNest && MinRank - rank > 1)
|
2019-12-26 20:59:16 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2019-11-19 03:23:01 +00:00
|
|
|
|
|
|
|
|
|
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-24 06:23:43 +00:00
|
|
|
|
return loc == SharedNest || (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)
|
|
|
|
|
{
|
2019-11-23 22:46:09 +00:00
|
|
|
|
if (pkm.FlawlessIVCount < FlawlessIVCount)
|
2019-11-19 03:23:01 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return base.IsMatch(pkm, lvl);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-22 04:03:02 +00:00
|
|
|
|
}
|