From a8c28369b6a57fc4c820dc237140c97eb48d4545 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 12 Jan 2020 16:22:56 -0800 Subject: [PATCH] Add Yamask-1 max hp calc for formArg compare Closes #2632 ty @CanoeHope --- PKHeX.Core/Legality/Verifiers/FormVerifier.cs | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/PKHeX.Core/Legality/Verifiers/FormVerifier.cs b/PKHeX.Core/Legality/Verifiers/FormVerifier.cs index ec524dfed..695eeac07 100644 --- a/PKHeX.Core/Legality/Verifiers/FormVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/FormVerifier.cs @@ -285,6 +285,20 @@ namespace PKHeX.Core return GetInvalid(LFormArgumentNotAllowed); break; } + case (int)Species.Yamask when pkm.AltForm == 1: + { + if (pkm.IsEgg) + { + if (f.FormArgument != 0) + return GetInvalid(LFormArgumentNotAllowed); + break; + } + + var hp_max = GetYamask1MaxHP(pkm); + if (f.FormArgument > hp_max) + return GetInvalid(LFormArgumentHigh); + break; + } case (int)Species.Runerigus: { if (data.EncounterMatch.Species == (int)Species.Runerigus) @@ -296,7 +310,8 @@ namespace PKHeX.Core { if (f.FormArgument < 49) return GetInvalid(LFormArgumentLow); - if (f.FormArgument > 320) // calculate Yamask HP maximum? Arbitrary bound check. + var hp_max = GetYamask1MaxHP(pkm); + if (f.FormArgument > hp_max) return GetInvalid(LFormArgumentHigh); } break; @@ -320,5 +335,16 @@ namespace PKHeX.Core return GetValid(LFormArgumentValid); } + + private static int GetYamask1MaxHP(PKM pkm) + { + var lvl = pkm.CurrentLevel; // assume it was evolved at the current level (no further level ups) + var iv_hp = pkm is IHyperTrain ht && ht.HT_HP ? 31 : pkm.IV_HP; + const int base_hp = 38; + const int ev_hp = 252; // account for full EVs then removed + + // Manually calculate the stat of Galarian Yamask under the most favorable conditions + return ((iv_hp + (2 * base_hp) + (ev_hp / 4) + 100) * lvl / 100) + 10; + } } }