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>
|
|
|
|
|
/// Verifies the <see cref="PKM.ConsoleRegion"/> and <see cref="PKM.Country"/> of origin values.
|
|
|
|
|
/// </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)
|
|
|
|
|
{
|
2019-11-26 19:01:09 +00:00
|
|
|
|
var result = VerifyConsoleRegion(data.pkm, data.Info.Generation);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
data.AddLine(result);
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2019-11-26 19:01:09 +00:00
|
|
|
|
private CheckResult VerifyConsoleRegion(PKM pkm, int gen)
|
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
|
|
|
|
|
2020-02-12 02:35:54 +00:00
|
|
|
|
if (gen >= 8 || pkm.Format >= 8 || pkm.GG)
|
2019-11-26 19:01:09 +00:00
|
|
|
|
return VerifyNoDataPresent(pkm, consoleRegion);
|
|
|
|
|
return Verify3DSDataPresent(pkm, consoleRegion);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CheckResult Verify3DSDataPresent(PKM pkm, int consoleRegion)
|
|
|
|
|
{
|
2018-06-30 22:01:16 +00:00
|
|
|
|
if (!Legal.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-30 22:01:16 +00:00
|
|
|
|
|
2019-11-26 19:01:09 +00:00
|
|
|
|
private CheckResult VerifyNoDataPresent(PKM pkm, int consoleRegion)
|
|
|
|
|
{
|
|
|
|
|
if (consoleRegion != 0 || pkm.Country != 0 || pkm.Region != 0)
|
|
|
|
|
return GetInvalid(LGeoHardwareInvalid);
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetValid(LGeoHardwareValid);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|