2020-06-19 23:51:15 +00:00
|
|
|
|
using static PKHeX.Core.Species;
|
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
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
|
2020-05-16 22:15:41 +00:00
|
|
|
|
{
|
2022-03-05 06:30:23 +00:00
|
|
|
|
/// <summary>
|
2022-06-18 18:04:24 +00:00
|
|
|
|
/// Checks if the species is allowed to have a non-zero value for <see cref="IDynamaxLevel.DynamaxLevel"/>.
|
2022-03-05 06:30:23 +00:00
|
|
|
|
/// </summary>
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public static bool CanHaveDynamaxLevel(this IDynamaxLevel _, PKM pk)
|
2020-05-16 22:15:41 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
if (pk.IsEgg)
|
|
|
|
|
return false;
|
|
|
|
|
return pk is PK8 && CanHaveDynamaxLevel(pk.Species);
|
2020-05-16 22:15:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public static byte GetSuggestedDynamaxLevel(this IDynamaxLevel _, PKM pk) => _.CanHaveDynamaxLevel(pk) ? (byte)10 : (byte)0;
|
2020-09-03 21:28:51 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
/// <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);
|
2020-05-16 22:15:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|