mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 13:58:33 +00:00
In this pull request I've changed a ton of method signatures to reflect the more-narrow types of Species, Move# and Form; additionally, I've narrowed other large collections that stored lists of species / permitted values, and reworked them to be more performant with the latest API spaghetti that PKHeX provides. Roamer met locations, usually in a range of [max-min]<64, can be quickly checked using a bitflag operation on a UInt64. Other collections (like "Is this from Colosseum or XD") were eliminated -- shadow state is not transferred COLO<->XD, so having a Shadow ID or matching the met location from a gift/wild encounter is a sufficient check for "originated in XD".
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using static PKHeX.Core.Species;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Exposes info about Dynamax potential
|
|
/// </summary>
|
|
public interface IDynamaxLevel
|
|
{
|
|
/// <summary>
|
|
/// Dynamax Level used by <see cref="GameVersion.SWSH"/> format entity data.
|
|
/// </summary>
|
|
byte DynamaxLevel { get; set; }
|
|
}
|
|
|
|
public static class DynamaxLevelExtensions
|
|
{
|
|
/// <summary>
|
|
/// Checks if the species is allowed to have a non-zero value for <see cref="IDynamaxLevel.DynamaxLevel"/>.
|
|
/// </summary>
|
|
public static bool CanHaveDynamaxLevel(this IDynamaxLevel _, PKM pk)
|
|
{
|
|
if (pk.IsEgg)
|
|
return false;
|
|
return pk is PK8 && CanHaveDynamaxLevel(pk.Species);
|
|
}
|
|
|
|
public static byte GetSuggestedDynamaxLevel(this IDynamaxLevel _, PKM pk, byte requested = 10) => _.CanHaveDynamaxLevel(pk) ? requested : (byte)0;
|
|
|
|
/// <summary>
|
|
/// Checks if the species is prevented from gaining any <see cref="IDynamaxLevel.DynamaxLevel"/> via candy in <see cref="GameVersion.SWSH"/>.
|
|
/// </summary>
|
|
private static bool CanHaveDynamaxLevel(ushort species)
|
|
{
|
|
return species is not ((int)Zacian or (int)Zamazenta or (int)Eternatus);
|
|
}
|
|
}
|