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>
|
2020-11-27 19:51:02 +00:00
|
|
|
|
/// Generation 8 Nest Encounter (Regular Raid Dens)
|
2019-11-19 03:23:01 +00:00
|
|
|
|
/// </summary>
|
2020-11-27 19:51:02 +00:00
|
|
|
|
/// <inheritdoc cref="EncounterStatic8Nest{T}"/>
|
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];
|
|
|
|
|
|
2020-12-22 01:05:05 +00:00
|
|
|
|
public override int Level { get => LevelMin; init { } }
|
2019-12-07 03:17:26 +00:00
|
|
|
|
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
|
|
|
|
|
};
|
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
protected override bool IsMatchLevel(PKM pkm, DexLevel evo)
|
2019-11-19 03:23:01 +00:00
|
|
|
|
{
|
2020-05-24 05:17:47 +00:00
|
|
|
|
var met = pkm.Met_Level;
|
|
|
|
|
var metLevel = met - 15;
|
2020-03-25 21:37:41 +00:00
|
|
|
|
var rank = ((uint)metLevel) / 10;
|
2019-11-20 02:02:57 +00:00
|
|
|
|
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;
|
2020-05-24 05:17:47 +00:00
|
|
|
|
if (rank < MinRank) // down-leveled
|
2020-05-31 20:28:14 +00:00
|
|
|
|
return IsDownLeveled(pkm, metLevel, met);
|
2020-01-06 02:46:30 +00:00
|
|
|
|
|
2020-05-31 20:28:14 +00:00
|
|
|
|
return metLevel % 10 <= 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsDownLeveled(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
var met = pkm.Met_Level;
|
|
|
|
|
var metLevel = met - 15;
|
2020-06-06 16:00:52 +00:00
|
|
|
|
return met != LevelMax && IsDownLeveled(pkm, metLevel, met);
|
2020-05-31 20:28:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsDownLeveled(PKM pkm, int metLevel, int met)
|
|
|
|
|
{
|
|
|
|
|
if (metLevel % 5 != 0)
|
|
|
|
|
return false;
|
2020-05-24 05:17:47 +00:00
|
|
|
|
|
2020-05-31 20:28:14 +00:00
|
|
|
|
// shared nests can be down-leveled to any
|
|
|
|
|
if (pkm.Met_Location == SharedNest)
|
|
|
|
|
return met >= 20;
|
2019-11-19 03:23:01 +00:00
|
|
|
|
|
2020-05-31 20:28:14 +00:00
|
|
|
|
// native down-levels: only allow 1 rank down (1 badge 2star -> 25), (3badge 3star -> 35)
|
|
|
|
|
return ((MinRank <= 1 && 1 <= MaxRank && met == 25)
|
|
|
|
|
|| (MinRank <= 2 && 2 <= MaxRank && met == 35)) && !pkm.IsShiny;
|
2019-11-19 03:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
public override bool IsMatch(PKM pkm, DexLevel evo)
|
2019-11-19 03:23:01 +00:00
|
|
|
|
{
|
2019-11-23 22:46:09 +00:00
|
|
|
|
if (pkm.FlawlessIVCount < FlawlessIVCount)
|
2019-11-19 03:23:01 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
return base.IsMatch(pkm, evo);
|
2019-11-19 03:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-22 04:03:02 +00:00
|
|
|
|
}
|