2019-10-26 19:33:58 +00:00
|
|
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
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;
|
2022-03-26 21:53:15 +00:00
|
|
|
|
if (data.EncounterMatch is EncounterStatic3 s3)
|
|
|
|
|
VerifyCXDStarterCorrelation(data, s3);
|
2018-07-26 21:55:45 +00:00
|
|
|
|
else if (pkm.Egg_Location != 0) // can't obtain eggs in CXD
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEncInvalid, CheckIdentifier.Encounter)); // invalid encounter
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
if (pkm.OT_Gender == 1)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LG3OTGender, CheckIdentifier.Trainer));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2022-03-26 21:53:15 +00:00
|
|
|
|
private static void VerifyCXDStarterCorrelation(LegalityAnalysis data, EncounterStatic3 enc)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2022-03-26 21:53:15 +00:00
|
|
|
|
var (type, seed) = data.Info.PIDIV;
|
|
|
|
|
if (type is not (PIDType.CXD or PIDType.CXDAnti or PIDType.CXD_ColoStarter))
|
2020-12-29 08:37:59 +00:00
|
|
|
|
return; // already flagged as invalid
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
var pkm = data.pkm;
|
2022-03-26 21:53:15 +00:00
|
|
|
|
bool valid = enc.Species switch
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2022-03-26 21:53:15 +00:00
|
|
|
|
(int)Species.Eevee => LockFinder.IsXDStarterValid(seed, pkm.TID, pkm.SID),
|
|
|
|
|
(int)Species.Espeon or (int)Species.Umbreon => type == PIDType.CXD_ColoStarter,
|
2021-08-20 20:49:20 +00:00
|
|
|
|
_ => true,
|
2020-12-30 04:25:05 +00:00
|
|
|
|
};
|
2018-06-24 05:00:01 +00:00
|
|
|
|
if (!valid)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEncConditionBadRNGFrame, CheckIdentifier.PID));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|