PKHeX/PKHeX.Core/Legality/Verifiers/ConsoleRegionVerifier.cs
Kurt ef425af835 Add memory / console region checks for pb7/pk8
yeah your initial hacks were hacks

It appears there's a bug (in the game) for link trade memories --
applied to the OT memory instead of HT memory?? Fun!
2019-11-26 11:01:09 -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.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);
}
}
}