mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
88830e0d00
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)
86 lines
3 KiB
C#
86 lines
3 KiB
C#
using static PKHeX.Core.LegalityCheckStrings;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Verifies the <see cref="PKM.Gender"/>.
|
|
/// </summary>
|
|
public sealed class GenderVerifier : Verifier
|
|
{
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.Gender;
|
|
|
|
public override void Verify(LegalityAnalysis data)
|
|
{
|
|
var pk = data.Entity;
|
|
var pi = pk.PersonalInfo;
|
|
if (pi.Genderless != (pk.Gender == 2))
|
|
{
|
|
// DP/HGSS shedinja glitch -- only generation 4 spawns
|
|
bool ignore = pk is { Format: 4, Species: (int)Species.Shedinja } && pk.Met_Level != pk.CurrentLevel;
|
|
if (!ignore)
|
|
data.AddLine(GetInvalid(LGenderInvalidNone));
|
|
return;
|
|
}
|
|
|
|
// Check for PID relationship to Gender & Nature if applicable
|
|
int gen = data.Info.Generation;
|
|
if (gen is 3 or 4 or 5)
|
|
{
|
|
// Gender-PID & Nature-PID relationship check
|
|
var result = IsValidGenderPID(data) ? GetValid(LPIDGenderMatch) : GetInvalid(LPIDGenderMismatch);
|
|
data.AddLine(result);
|
|
|
|
if (gen != 5)
|
|
VerifyNaturePID(data);
|
|
return;
|
|
}
|
|
|
|
// Check fixed gender cases
|
|
if ((pi.OnlyFemale && pk.Gender != 1) || (pi.OnlyMale && pk.Gender != 0))
|
|
data.AddLine(GetInvalid(LGenderInvalidNone));
|
|
}
|
|
|
|
private static void VerifyNaturePID(LegalityAnalysis data)
|
|
{
|
|
var pk = data.Entity;
|
|
var result = pk.EncryptionConstant % 25 == pk.Nature
|
|
? GetValid(LPIDNatureMatch, CheckIdentifier.Nature)
|
|
: GetInvalid(LPIDNatureMismatch, CheckIdentifier.Nature);
|
|
data.AddLine(result);
|
|
}
|
|
|
|
private static bool IsValidGenderPID(LegalityAnalysis data)
|
|
{
|
|
var pk = data.Entity;
|
|
bool genderValid = pk.IsGenderValid();
|
|
if (!genderValid)
|
|
return IsValidGenderMismatch(pk);
|
|
|
|
// check for mixed->fixed gender incompatibility by checking the gender of the original species
|
|
var original = data.EncounterMatch.Species;
|
|
if (Legal.FixedGenderFromBiGender.Contains(original))
|
|
return IsValidFixedGenderFromBiGender(pk, original);
|
|
|
|
return true;
|
|
}
|
|
|
|
private static bool IsValidFixedGenderFromBiGender(PKM pk, ushort original)
|
|
{
|
|
var current = pk.Gender;
|
|
if (current == 2) // shedinja, genderless
|
|
return true;
|
|
var gender = EntityGender.GetFromPID(original, pk.EncryptionConstant);
|
|
return gender == current;
|
|
}
|
|
|
|
private static bool IsValidGenderMismatch(PKM pk) => pk.Species switch
|
|
{
|
|
// Shedinja evolution gender glitch, should match original Gender
|
|
(int) Species.Shedinja when pk.Format == 4 => pk.Gender == EntityGender.GetFromPIDAndRatio(pk.EncryptionConstant, 0x7F), // 50M-50F
|
|
|
|
// Evolved from Azurill after transferring to keep gender
|
|
(int) Species.Marill or (int) Species.Azumarill when pk.Format >= 6 => pk.Gender == 1 && (pk.EncryptionConstant & 0xFF) > 0x3F,
|
|
|
|
_ => false,
|
|
};
|
|
}
|