PKHeX/PKHeX.Core/Legality/Verifiers/CXDVerifier.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

42 lines
1.4 KiB
C#

using static PKHeX.Core.LegalityCheckStrings;
namespace PKHeX.Core
{
public class CXDVerifier : Verifier
{
protected override CheckIdentifier Identifier => CheckIdentifier.Misc;
public override void Verify(LegalityAnalysis data)
{
var pkm = data.pkm;
if (data.EncounterMatch is EncounterStatic)
VerifyCXDStarterCorrelation(data);
else if (pkm.WasEgg) // can't obtain eggs in CXD
data.AddLine(GetInvalid(V80, CheckIdentifier.Encounter)); // invalid encounter
if (pkm.OT_Gender == 1)
data.AddLine(GetInvalid(V407, CheckIdentifier.Trainer));
}
private static void VerifyCXDStarterCorrelation(LegalityAnalysis data)
{
var pidiv = data.Info.PIDIV;
if (pidiv.Type != PIDType.CXD)
return;
bool valid;
var EncounterMatch = data.EncounterMatch;
var pkm = data.pkm;
switch (EncounterMatch.Species)
{
case 133:
valid = LockFinder.IsXDStarterValid(pidiv.OriginSeed, pkm.TID, pkm.SID); break;
case 196:
case 197:
valid = pidiv.Type == PIDType.CXD_ColoStarter; break;
default:
return;
}
if (!valid)
data.AddLine(GetInvalid(V400, CheckIdentifier.PID));
}
}
}