mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-21 19:43:06 +00:00
IEncounterable: Add down-level interface
This commit is contained in:
parent
8c37d9b4b5
commit
231b3ffe57
5 changed files with 33 additions and 7 deletions
|
@ -7,7 +7,7 @@ namespace PKHeX.Core;
|
|||
/// Encounter Slot found in <see cref="GameVersion.ORAS"/>.
|
||||
/// </summary>
|
||||
public sealed record EncounterSlot6AO(EncounterArea6AO Parent, ushort Species, byte Form, byte LevelMin, byte LevelMax)
|
||||
: IEncounterable, IEncounterMatch, IEncounterConvertible<PK6>, IEncounterFormRandom
|
||||
: IEncounterable, IEncounterMatch, IEncounterConvertible<PK6>, IEncounterFormRandom, IEncounterDownlevel
|
||||
{
|
||||
public byte Generation => 6;
|
||||
public EntityContext Context => EntityContext.Gen6;
|
||||
|
@ -121,6 +121,8 @@ public sealed record EncounterSlot6AO(EncounterArea6AO Parent, ushort Species, b
|
|||
private const int FluteBoostMax = 4; // Black Flute increases levels.
|
||||
private const int DexNavBoost = 29 + FluteBoostMax; // Maximum DexNav chain (95) and Flute.
|
||||
|
||||
public byte GetDownleveledMin() => (byte)(LevelMin - FluteBoostMin);
|
||||
|
||||
public bool IsMatchExact(PKM pk, EvoCriteria evo)
|
||||
{
|
||||
var boostMax = Type != Rock_Smash ? DexNavBoost : FluteBoostMax;
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace PKHeX.Core;
|
|||
/// Generation 8 Nest Encounter (Regular Raid Dens)
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="EncounterStatic8Nest{T}"/>
|
||||
public sealed record EncounterStatic8N : EncounterStatic8Nest<EncounterStatic8N>
|
||||
public sealed record EncounterStatic8N : EncounterStatic8Nest<EncounterStatic8N>, IEncounterDownlevel
|
||||
{
|
||||
private readonly byte MinRank;
|
||||
private readonly byte MaxRank;
|
||||
|
@ -77,6 +77,10 @@ public sealed record EncounterStatic8N : EncounterStatic8Nest<EncounterStatic8N>
|
|||
return metLevel % 10 <= 5;
|
||||
}
|
||||
|
||||
private const byte SharedNestMinLevel = 20;
|
||||
|
||||
public byte GetDownleveledMin() => SharedNestMinLevel;
|
||||
|
||||
public bool IsDownLeveled(PKM pk)
|
||||
{
|
||||
var met = pk.MetLevel;
|
||||
|
@ -91,7 +95,7 @@ public sealed record EncounterStatic8N : EncounterStatic8Nest<EncounterStatic8N>
|
|||
|
||||
// shared nests can be down-leveled to any
|
||||
if (pk.MetLocation == SharedNest)
|
||||
return met >= 20;
|
||||
return met >= SharedNestMinLevel;
|
||||
|
||||
// native down-levels: only allow 1 rank down (1 badge 2star -> 25), (3badge 3star -> 35)
|
||||
return ((MinRank <= 1 && 1 <= MaxRank && met == 25)
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace PKHeX.Core;
|
|||
/// Generation 8 Nest Encounter (Distributed Crystal Data)
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="EncounterStatic8Nest{T}"/>
|
||||
public sealed record EncounterStatic8NC(GameVersion Version) : EncounterStatic8Nest<EncounterStatic8NC>(Version), ILocation
|
||||
public sealed record EncounterStatic8NC(GameVersion Version) : EncounterStatic8Nest<EncounterStatic8NC>(Version), ILocation, IEncounterDownlevel
|
||||
{
|
||||
ushort ILocation.Location => Watchtower;
|
||||
public const ushort Location = Watchtower;
|
||||
|
@ -20,6 +20,10 @@ public sealed record EncounterStatic8NC(GameVersion Version) : EncounterStatic8N
|
|||
return loc is SharedNest or Watchtower;
|
||||
}
|
||||
|
||||
private const byte SharedNestMinLevel = 20;
|
||||
|
||||
public byte GetDownleveledMin() => SharedNestMinLevel;
|
||||
|
||||
protected override bool IsMatchLevel(PKM pk)
|
||||
{
|
||||
var lvl = pk.MetLevel;
|
||||
|
@ -29,7 +33,7 @@ public sealed record EncounterStatic8NC(GameVersion Version) : EncounterStatic8N
|
|||
// Check downleveled (20-55)
|
||||
if (lvl > Level)
|
||||
return false;
|
||||
if (lvl is < 20 or > 55)
|
||||
if (lvl is < SharedNestMinLevel or > 55)
|
||||
return false;
|
||||
if (pk is { MetLocation: Watchtower, IsShiny: true })
|
||||
return false; // host cannot downlevel and be shiny
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace PKHeX.Core;
|
|||
/// Generation 8 Nest Encounter (Distributed Data)
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="EncounterStatic8Nest{T}"/>
|
||||
public sealed record EncounterStatic8ND : EncounterStatic8Nest<EncounterStatic8ND>
|
||||
public sealed record EncounterStatic8ND : EncounterStatic8Nest<EncounterStatic8ND>, IEncounterDownlevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Distribution raid index for <see cref="GameVersion.SWSH"/>
|
||||
|
@ -56,6 +56,10 @@ public sealed record EncounterStatic8ND : EncounterStatic8Nest<EncounterStatic8N
|
|||
};
|
||||
}
|
||||
|
||||
private const byte SharedNestMinLevel = 20;
|
||||
|
||||
public byte GetDownleveledMin() => SharedNestMinLevel;
|
||||
|
||||
protected override bool IsMatchLevel(PKM pk)
|
||||
{
|
||||
var lvl = pk.MetLevel;
|
||||
|
@ -73,7 +77,7 @@ public sealed record EncounterStatic8ND : EncounterStatic8Nest<EncounterStatic8N
|
|||
// Check downleveled (20-55)
|
||||
if (lvl > Level)
|
||||
return false;
|
||||
if (lvl is < 20 or > 55)
|
||||
if (lvl is < SharedNestMinLevel or > 55)
|
||||
return false;
|
||||
|
||||
if (lvl % 5 != 0)
|
||||
|
|
12
PKHeX.Core/PKM/Interfaces/Templates/IEncounterDownlevel.cs
Normal file
12
PKHeX.Core/PKM/Interfaces/Templates/IEncounterDownlevel.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
namespace PKHeX.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for encounters that can be down-leveled by an additional game situation.
|
||||
/// </summary>
|
||||
public interface IEncounterDownlevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the minimum level when forcibly down-leveled by an additional game situation.
|
||||
/// </summary>
|
||||
byte GetDownleveledMin();
|
||||
}
|
Loading…
Reference in a new issue