PKHeX/PKHeX.Core/Legality/Verifiers/HyperTrainingVerifier.cs
Kurt 0b32cbf132 Update PKHeX.Core abstractions with latest logic
Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com>
Co-Authored-By: SciresM <8676005+SciresM@users.noreply.github.com>
Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com>
2022-02-04 17:35:15 -08:00

53 lines
1.5 KiB
C#

using static PKHeX.Core.LegalityCheckStrings;
namespace PKHeX.Core
{
/// <summary>
/// Verifies the <see cref="IHyperTrain"/> values.
/// </summary>
public sealed class HyperTrainingVerifier : Verifier
{
protected override CheckIdentifier Identifier => CheckIdentifier.Training;
public override void Verify(LegalityAnalysis data)
{
var pkm = data.pkm;
if (pkm is not IHyperTrain t)
return; // No Hyper Training before Gen7
if (!t.IsHyperTrained())
return;
if (!t.IsHyperTrainingAvailable())
{
data.AddLine(GetInvalid(LHyperPerfectUnavailable));
return;
}
if (pkm.CurrentLevel != 100)
{
data.AddLine(GetInvalid(LHyperBelow100));
return;
}
int max = pkm.MaxIV;
if (pkm.IVTotal == max * 6)
{
data.AddLine(GetInvalid(LHyperPerfectAll));
return;
}
// LGPE gold bottle cap applies to all IVs regardless
if (pkm.GG && t.IsHyperTrainedAll()) // already checked for 6IV, therefore we're flawed on at least one IV
return;
for (int i = 0; i < 6; i++) // Check individual IVs
{
if (pkm.GetIV(i) != max || !t.IsHyperTrained(i))
continue;
data.AddLine(GetInvalid(LHyperPerfectOne));
break;
}
}
}
}