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

23 lines
902 B
C#

using static PKHeX.Core.LegalityCheckStrings;
namespace PKHeX.Core
{
public class ConsoleRegionVerifier : Verifier
{
protected override CheckIdentifier Identifier => CheckIdentifier.Geography;
public override void Verify(LegalityAnalysis data)
{
var result = VerifyConsoleRegion(data.pkm);
data.AddLine(result);
}
private static CheckResult VerifyConsoleRegion(PKM pkm)
{
int consoleRegion = pkm.ConsoleRegion;
if (consoleRegion >= 7)
return new CheckResult(Severity.Invalid, V301, CheckIdentifier.Geography);
return Legal.IsConsoleRegionCountryValid(consoleRegion, pkm.Country)
? new CheckResult(Severity.Valid, V303, CheckIdentifier.Geography)
: new CheckResult(Severity.Invalid, V302, CheckIdentifier.Geography);
}
}
}