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