2018-06-24 05:00:01 +00:00
|
|
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
namespace PKHeX.Core;
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Verifies the <see cref="PKM.HeldItem"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class ItemVerifier : Verifier
|
|
|
|
|
{
|
|
|
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.HeldItem;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public override void Verify(LegalityAnalysis data)
|
|
|
|
|
{
|
|
|
|
|
var pk = data.Entity;
|
|
|
|
|
if (!ItemRestrictions.IsHeldItemAllowed(pk))
|
|
|
|
|
data.AddLine(GetInvalid(LItemUnreleased));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
if (pk.Format == 3 && pk.HeldItem == 175) // Enigma Berry
|
|
|
|
|
VerifyEReaderBerry(data);
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
if (pk.IsEgg && pk.HeldItem != 0)
|
|
|
|
|
data.AddLine(GetInvalid(LItemEgg));
|
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
private void VerifyEReaderBerry(LegalityAnalysis data)
|
|
|
|
|
{
|
|
|
|
|
var status = EReaderBerrySettings.GetStatus();
|
|
|
|
|
var chk = GetEReaderCheckResult(status);
|
|
|
|
|
if (chk != null)
|
|
|
|
|
data.AddLine(chk);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
|
|
private CheckResult? GetEReaderCheckResult(EReaderBerryMatch status) => status switch
|
|
|
|
|
{
|
|
|
|
|
EReaderBerryMatch.NoMatch => GetInvalid(LEReaderInvalid),
|
|
|
|
|
EReaderBerryMatch.NoData => GetInvalid(LItemUnreleased),
|
|
|
|
|
EReaderBerryMatch.InvalidUSA => GetInvalid(LEReaderAmerica),
|
|
|
|
|
EReaderBerryMatch.InvalidJPN => GetInvalid(LEReaderJapan),
|
|
|
|
|
_ => null,
|
|
|
|
|
};
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|