2018-06-24 05:00:01 +00:00
|
|
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Verifies the <see cref="IRegionOrigin.ConsoleRegion"/> and <see cref="IRegionOrigin.Country"/> of origin values.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class ConsoleRegionVerifier : Verifier
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.Geography;
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public override void Verify(LegalityAnalysis data)
|
|
|
|
|
{
|
|
|
|
|
if (data.Entity is not IRegionOrigin tr)
|
|
|
|
|
return;
|
|
|
|
|
var result = VerifyConsoleRegion(tr);
|
|
|
|
|
data.AddLine(result);
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
private CheckResult VerifyConsoleRegion(IRegionOrigin pk)
|
|
|
|
|
{
|
|
|
|
|
int consoleRegion = pk.ConsoleRegion;
|
|
|
|
|
if (consoleRegion >= 7)
|
|
|
|
|
return GetInvalid(LGeoHardwareRange);
|
2018-06-30 22:01:16 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
return Verify3DSDataPresent(pk, consoleRegion);
|
|
|
|
|
}
|
2019-11-26 19:01:09 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
private CheckResult Verify3DSDataPresent(IRegionOrigin pk, int consoleRegion)
|
|
|
|
|
{
|
|
|
|
|
if (!Locale3DS.IsConsoleRegionCountryValid(consoleRegion, pk.Country))
|
|
|
|
|
return GetInvalid(LGeoHardwareInvalid);
|
|
|
|
|
return GetValid(LGeoHardwareValid);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|