PKHeX/PKHeX.Core/Legality/Verifiers/HyperTrainingVerifier.cs
Kurt e29cf2a903 Rework secondary check flow
Checks.cs initially started out small, but over the years it has grown
to handle multiple types of checks. With all these checks next to
eachother, it's hard to see the overall groups. Splitting them up
(potentially further?) allows for more focused maintenance &
understanding.

Not sure if I'm happy with the overall bandaids used (checks no longer
done within LegalityAnalysis so variable repointing is excessively
used), but I'm happier the way it is now compared to the huge Checks.cs
2018-06-23 22:00:01 -07:00

40 lines
1 KiB
C#

using static PKHeX.Core.LegalityCheckStrings;
namespace PKHeX.Core
{
public class HyperTrainingVerifier : Verifier
{
protected override CheckIdentifier Identifier => CheckIdentifier.Training;
public override void Verify(LegalityAnalysis data)
{
var pkm = data.pkm;
if (!(pkm is IHyperTrain t))
return; // No Hyper Training before Gen7
if (!t.IsHyperTrained())
return;
if (pkm.CurrentLevel != 100)
{
data.AddLine(GetInvalid(V40));
return;
}
int max = pkm.MaxIV;
if (pkm.IVTotal == max * 6)
{
data.AddLine(GetInvalid(V41));
return;
}
for (int i = 0; i < 6; i++) // Check individual IVs
{
if (pkm.GetIV(i) != max || !t.IsHyperTrained(i))
continue;
data.AddLine(GetInvalid(V42));
break;
}
}
}
}