PKHeX/PKHeX.Core/PKM/Interfaces/IDynamaxLevel.cs
Kurt fc754b346b
File scoped namespaces (#3529)
[Language Reference](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces)

Updates all the files, one less level of indentation.

Some small changes were made to API surfaces, renaming `PKM pkm` -> `PKM pk`, and `LegalityAnalysis.pkm` -> `LegalityAnalysis.Entity`
2022-06-18 11:04:24 -07:00

34 lines
1.1 KiB
C#

using static PKHeX.Core.Species;
namespace PKHeX.Core;
/// <summary>
/// Dynamax Level used by <see cref="GameVersion.SWSH"/> format entity data.
/// </summary>
public interface IDynamaxLevel
{
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) => _.CanHaveDynamaxLevel(pk) ? (byte)10 : (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(int species)
{
return species is not ((int)Zacian or (int)Zamazenta or (int)Eternatus);
}
}