2019-10-26 19:33:58 +00:00
|
|
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
|
|
/// <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
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.Misc;
|
|
|
|
|
|
|
|
|
|
public override void Verify(LegalityAnalysis data)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
var pk = data.Entity;
|
|
|
|
|
if (data.EncounterMatch is EncounterStatic3 s3)
|
|
|
|
|
VerifyCXDStarterCorrelation(data, s3);
|
|
|
|
|
else if (pk.Egg_Location != 0 && pk is not PB8 {Egg_Location: Locations.Default8bNone}) // can't obtain eggs in CXD
|
|
|
|
|
data.AddLine(GetInvalid(LEncInvalid, CheckIdentifier.Encounter)); // invalid encounter
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
if (pk.OT_Gender == 1)
|
|
|
|
|
data.AddLine(GetInvalid(LG3OTGender, CheckIdentifier.Trainer));
|
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
private static void VerifyCXDStarterCorrelation(LegalityAnalysis data, EncounterStatic3 enc)
|
|
|
|
|
{
|
|
|
|
|
var (type, seed) = data.Info.PIDIV;
|
|
|
|
|
if (type is not (PIDType.CXD or PIDType.CXDAnti or PIDType.CXD_ColoStarter))
|
|
|
|
|
return; // already flagged as invalid
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
var pk = data.Entity;
|
|
|
|
|
bool valid = enc.Species switch
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
(int)Species.Eevee => LockFinder.IsXDStarterValid(seed, pk.TID, pk.SID),
|
|
|
|
|
(int)Species.Espeon or (int)Species.Umbreon => type == PIDType.CXD_ColoStarter,
|
|
|
|
|
_ => true,
|
|
|
|
|
};
|
|
|
|
|
if (!valid)
|
|
|
|
|
data.AddLine(GetInvalid(LEncConditionBadRNGFrame, CheckIdentifier.PID));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|