PKHeX/PKHeX.Core/Legality/Verifiers/CXDVerifier.cs
Kurt 88830e0d00
Update from .NET Framework 4.6 to .NET 7 (#3729)
Updates from net46->net7, dropping support for mono in favor of using the latest runtime (along with the performance/API improvements). Releases will be posted as 64bit only for now.

Refactors a good amount of internal API methods to be more performant and more customizable for future updates & fixes.

Adds functionality for Batch Editor commands to `>`, `<` and <=/>=

TID/SID properties renamed to TID16/SID16 for clarity; other properties exposed for Gen7 / display variants.

Main window has a new layout to account for DPI scaling (8 point grid)

Fixed: Tatsugiri and Paldean Tauros now output Showdown form names as Showdown expects
Changed: Gen9 species now interact based on the confirmed National Dex IDs (closes #3724)
Fixed: Pokedex set all no longer clears species with unavailable non-base forms (closes #3720)
Changed: Hyper Training suggestions now apply for level 50 in SV. (closes #3714)
Fixed: B2/W2 hatched egg met locations exclusive to specific versions are now explicitly checked (closes #3691)
Added: Properties for ribbon/mark count (closes #3659)
Fixed: Traded SV eggs are now checked correctly (closes #3692)
2023-01-21 20:02:33 -08:00

56 lines
1.9 KiB
C#

using static PKHeX.Core.LegalityCheckStrings;
namespace PKHeX.Core;
/// <summary>
/// Verifies the specific origin data of <see cref="GameVersion.CXD"/> encounters.
/// </summary>
public sealed class CXDVerifier : Verifier
{
protected override CheckIdentifier Identifier => CheckIdentifier.Misc;
public override void Verify(LegalityAnalysis data)
{
var pk = data.Entity;
if (data.EncounterMatch is EncounterStatic3 s3)
VerifyCXDStarterCorrelation(data, s3);
if (pk.OT_Gender == 1)
data.AddLine(GetInvalid(LG3OTGender, CheckIdentifier.Trainer));
}
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
bool valid;
if (enc.Species is (int)Species.Espeon or (int)Species.Umbreon)
{
valid = type == PIDType.CXD_ColoStarter;
}
else if (enc.Species == (int)Species.Eevee)
{
var pk = data.Entity;
if (type == PIDType.CXD_ColoStarter && pk.Species == (int)Species.Umbreon)
{
// reset pidiv type to be CXD -- ColoStarter is same correlation as Eevee->Umbreon
data.Info.PIDIV = new PIDIV(PIDType.CXD, seed);
valid = true;
}
else
{
valid = LockFinder.IsXDStarterValid(seed, pk.TID16, pk.SID16);
if (valid) // unroll seed to origin that generated TID16/SID16->pkm
data.Info.PIDIV = new PIDIV(PIDType.CXD, XDRNG.Prev4(seed));
}
}
else
{
return;
}
if (!valid)
data.AddLine(GetInvalid(LEncConditionBadRNGFrame, CheckIdentifier.PID));
}
}