PKHeX/PKHeX.Core/Legality/Verifiers/ConsoleRegionVerifier.cs
Kurt 217156d2b9 Continued comparisons & implications
pk7->pk8 doesnt assign height/weight (zero), require zero for legal
p*7->pk8 assigns a tracker value, enforce something is present for legal
copy OT friendship (oops)
2020-02-11 18:35:54 -08:00

43 lines
1.5 KiB
C#

using static PKHeX.Core.LegalityCheckStrings;
namespace PKHeX.Core
{
/// <summary>
/// Verifies the <see cref="PKM.ConsoleRegion"/> and <see cref="PKM.Country"/> of origin values.
/// </summary>
public sealed class ConsoleRegionVerifier : Verifier
{
protected override CheckIdentifier Identifier => CheckIdentifier.Geography;
public override void Verify(LegalityAnalysis data)
{
var result = VerifyConsoleRegion(data.pkm, data.Info.Generation);
data.AddLine(result);
}
private CheckResult VerifyConsoleRegion(PKM pkm, int gen)
{
int consoleRegion = pkm.ConsoleRegion;
if (consoleRegion >= 7)
return GetInvalid(LGeoHardwareRange);
if (gen >= 8 || pkm.Format >= 8 || pkm.GG)
return VerifyNoDataPresent(pkm, consoleRegion);
return Verify3DSDataPresent(pkm, consoleRegion);
}
private CheckResult Verify3DSDataPresent(PKM pkm, int consoleRegion)
{
if (!Legal.IsConsoleRegionCountryValid(consoleRegion, pkm.Country))
return GetInvalid(LGeoHardwareInvalid);
return GetValid(LGeoHardwareValid);
}
private CheckResult VerifyNoDataPresent(PKM pkm, int consoleRegion)
{
if (consoleRegion != 0 || pkm.Country != 0 || pkm.Region != 0)
return GetInvalid(LGeoHardwareInvalid);
return GetValid(LGeoHardwareValid);
}
}
}