mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-15 00:37:11 +00:00
e29cf2a903
Checks.cs initially started out small, but over the years it has grown to handle multiple types of checks. With all these checks next to eachother, it's hard to see the overall groups. Splitting them up (potentially further?) allows for more focused maintenance & understanding. Not sure if I'm happy with the overall bandaids used (checks no longer done within LegalityAnalysis so variable repointing is excessively used), but I'm happier the way it is now compared to the huge Checks.cs
38 lines
1.5 KiB
C#
38 lines
1.5 KiB
C#
using static PKHeX.Core.LegalityCheckStrings;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
public class ItemVerifier : Verifier
|
|
{
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.HeldItem;
|
|
public override void Verify(LegalityAnalysis data)
|
|
{
|
|
var pkm = data.pkm;
|
|
if (!Legal.IsHeldItemAllowed(pkm))
|
|
data.AddLine(GetInvalid(V204));
|
|
|
|
if (pkm.Format == 3 && pkm.HeldItem == 175) // Enigma Berry
|
|
VerifyEReaderBerry(data);
|
|
|
|
if (pkm.IsEgg && pkm.HeldItem != 0)
|
|
data.AddLine(GetInvalid(V419));
|
|
}
|
|
private void VerifyEReaderBerry(LegalityAnalysis data)
|
|
{
|
|
if (Legal.EReaderBerryIsEnigma) // no E-Reader berry data provided, can't hold berry.
|
|
{
|
|
data.AddLine(GetInvalid(V204));
|
|
return;
|
|
}
|
|
|
|
var matchUSA = Legal.EReaderBerriesNames_USA.Contains(Legal.EReaderBerryName);
|
|
var matchJP = Legal.EReaderBerriesNames_JP.Contains(Legal.EReaderBerryName);
|
|
if (!matchJP && !matchUSA) // Does not match any released E-Reader berry
|
|
data.AddLine(GetInvalid(V369));
|
|
else if (matchJP && !Legal.SavegameJapanese && Legal.SavegameLanguage >= 0) // E-Reader is region locked
|
|
data.AddLine(GetInvalid(V370));
|
|
else if (matchUSA && Legal.SavegameJapanese && Legal.SavegameLanguage >= 0) // E-Reader is region locked
|
|
data.AddLine(GetInvalid(V371));
|
|
}
|
|
}
|
|
}
|