mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-22 18:33:14 +00:00
fc754b346b
[Language Reference](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces) Updates all the files, one less level of indentation. Some small changes were made to API surfaces, renaming `PKM pkm` -> `PKM pk`, and `LegalityAnalysis.pkm` -> `LegalityAnalysis.Entity`
41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using static PKHeX.Core.LegalityCheckStrings;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Verifies the <see cref="PKM.HeldItem"/>.
|
|
/// </summary>
|
|
public sealed class ItemVerifier : Verifier
|
|
{
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.HeldItem;
|
|
|
|
public override void Verify(LegalityAnalysis data)
|
|
{
|
|
var pk = data.Entity;
|
|
if (!ItemRestrictions.IsHeldItemAllowed(pk))
|
|
data.AddLine(GetInvalid(LItemUnreleased));
|
|
|
|
if (pk.Format == 3 && pk.HeldItem == 175) // Enigma Berry
|
|
VerifyEReaderBerry(data);
|
|
|
|
if (pk.IsEgg && pk.HeldItem != 0)
|
|
data.AddLine(GetInvalid(LItemEgg));
|
|
}
|
|
|
|
private void VerifyEReaderBerry(LegalityAnalysis data)
|
|
{
|
|
var status = EReaderBerrySettings.GetStatus();
|
|
var chk = GetEReaderCheckResult(status);
|
|
if (chk != null)
|
|
data.AddLine(chk);
|
|
}
|
|
|
|
private CheckResult? GetEReaderCheckResult(EReaderBerryMatch status) => status switch
|
|
{
|
|
EReaderBerryMatch.NoMatch => GetInvalid(LEReaderInvalid),
|
|
EReaderBerryMatch.NoData => GetInvalid(LItemUnreleased),
|
|
EReaderBerryMatch.InvalidUSA => GetInvalid(LEReaderAmerica),
|
|
EReaderBerryMatch.InvalidJPN => GetInvalid(LEReaderJapan),
|
|
_ => null,
|
|
};
|
|
}
|