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 specific origin data of <see cref="GameVersion.CXD"/> encounters.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class CXDVerifier : Verifier
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.Misc;
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-06-24 05:00:01 +00:00
|
|
|
|
public override void Verify(LegalityAnalysis data)
|
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
if (data.EncounterMatch is EncounterStatic)
|
|
|
|
|
VerifyCXDStarterCorrelation(data);
|
2018-07-26 21:55:45 +00:00
|
|
|
|
else if (pkm.Egg_Location != 0) // can't obtain eggs in CXD
|
2018-06-24 05:00:01 +00:00
|
|
|
|
data.AddLine(GetInvalid(V80, CheckIdentifier.Encounter)); // invalid encounter
|
|
|
|
|
|
|
|
|
|
if (pkm.OT_Gender == 1)
|
|
|
|
|
data.AddLine(GetInvalid(V407, CheckIdentifier.Trainer));
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-06-24 05:00:01 +00:00
|
|
|
|
private static void VerifyCXDStarterCorrelation(LegalityAnalysis data)
|
|
|
|
|
{
|
|
|
|
|
var pidiv = data.Info.PIDIV;
|
|
|
|
|
if (pidiv.Type != PIDType.CXD)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool valid;
|
|
|
|
|
var EncounterMatch = data.EncounterMatch;
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
switch (EncounterMatch.Species)
|
|
|
|
|
{
|
|
|
|
|
case 133:
|
|
|
|
|
valid = LockFinder.IsXDStarterValid(pidiv.OriginSeed, pkm.TID, pkm.SID); break;
|
|
|
|
|
case 196:
|
|
|
|
|
case 197:
|
|
|
|
|
valid = pidiv.Type == PIDType.CXD_ColoStarter; break;
|
|
|
|
|
default:
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!valid)
|
|
|
|
|
data.AddLine(GetInvalid(V400, CheckIdentifier.PID));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|