2018-06-24 05:00:01 +00:00
|
|
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2018-07-02 02:17:37 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Verifies the <see cref="PKM.HeldItem"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class ItemVerifier : Verifier
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.HeldItem;
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-06-24 05:00:01 +00:00
|
|
|
|
public override void Verify(LegalityAnalysis data)
|
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
2020-01-17 03:27:29 +00:00
|
|
|
|
if (!ItemRestrictions.IsHeldItemAllowed(pkm))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LItemUnreleased));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
if (pkm.Format == 3 && pkm.HeldItem == 175) // Enigma Berry
|
|
|
|
|
VerifyEReaderBerry(data);
|
|
|
|
|
|
|
|
|
|
if (pkm.IsEgg && pkm.HeldItem != 0)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LItemEgg));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-06-24 05:00:01 +00:00
|
|
|
|
private void VerifyEReaderBerry(LegalityAnalysis data)
|
|
|
|
|
{
|
2020-07-19 03:51:55 +00:00
|
|
|
|
var status = EReaderBerrySettings.GetStatus();
|
|
|
|
|
var chk = GetEReaderCheckResult(status);
|
|
|
|
|
if (chk != null)
|
|
|
|
|
data.AddLine(chk);
|
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2020-07-19 03:51:55 +00:00
|
|
|
|
private CheckResult? GetEReaderCheckResult(EReaderBerryMatch status)
|
|
|
|
|
{
|
|
|
|
|
return status switch
|
2018-10-06 02:58:30 +00:00
|
|
|
|
{
|
2020-07-19 03:51:55 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|