diff --git a/PKHeX.Core/Items/ItemStorage3RS.cs b/PKHeX.Core/Items/ItemStorage3RS.cs index 42b79f262..ac5becced 100644 --- a/PKHeX.Core/Items/ItemStorage3RS.cs +++ b/PKHeX.Core/Items/ItemStorage3RS.cs @@ -54,7 +54,7 @@ public sealed class ItemStorage3RS : IItemStorage 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ]; - internal static ReadOnlySpan Unreleased => [005]; // Safari Ball + internal static ReadOnlySpan Unreleased => [005, 044]; // Safari Ball, Berry Juice public static ushort[] GetAllHeld() => [..General, ..Balls, ..Berry, ..MachineOnlyTM]; diff --git a/PKHeX.Core/Legality/Verifiers/Misc/MiscVerifierG3.cs b/PKHeX.Core/Legality/Verifiers/Misc/MiscVerifierG3.cs index 58ad89a09..7ed7604a6 100644 --- a/PKHeX.Core/Legality/Verifiers/Misc/MiscVerifierG3.cs +++ b/PKHeX.Core/Legality/Verifiers/Misc/MiscVerifierG3.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using static PKHeX.Core.LegalityCheckResultCode; using static PKHeX.Core.CheckIdentifier; @@ -24,19 +25,22 @@ internal void Verify(LegalityAnalysis data, G3PKM pk) data.AddLine(GetInvalid(TradeNotAvailable)); else if (IsForeignFRLG(pk.Species)) data.AddLine(GetInvalid(TradeNotAvailable)); + + if (UnavailableHeld.BinarySearch((ushort)pk.HeldItem) >= 0) + data.AddLine(GetInvalid(ItemUnreleased)); } /// /// For a species with a potentially valid FR/LG origin encounter, flag if not permitted. /// - public static bool IsForeignFRLG(ushort species) => IsForeign(ForeignFRLG, species); + public static bool IsForeignFRLG(ushort species) => IsForeign(ForeignFRLG, species, ShiftFRLG); - public static bool IsForeign(ReadOnlySpan bitSet, int species) + public static bool IsForeign(ReadOnlySpan bitSet, int species, [ConstantExpected] int shift) { - species -= ShiftFRLG; + species -= shift; var offset = species >> 3; - if (offset >= bitSet.Length) + if ((uint)offset >= bitSet.Length) return false; var bit = species & 7; @@ -62,4 +66,39 @@ public static bool IsForeign(ReadOnlySpan bitSet, int species) 0xFF, 0xFF, 0xFB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0x03, ]; + + private static ReadOnlySpan UnavailableHeld => + [ + 039, 041, 042, 043, // Flutes (Yellow is obtainable via Coins) + 046, 047, // Shoal Salt, Shoal Shell + 048, 049, 050, 051, // Shards + 081, // Fluffy Tail + + 121, 122, 123, 124, 125, 126, 127, 128, 129, // Mail + + 168, // Liechi Berry (Mirage Island) + 169, // Ganlon Berry (Event) + 170, // Salac Berry (Event) + 171, // Petaya Berry (Event) + 172, // Apicot Berry (Event) + 173, // Lansat Berry (Event) + 174, // Starf Berry (Event) + 175, // Enigma Berry (Event) + + 179, // BrightPowder + 180, // White Herb + 185, // Mental Herb + 186, // Choice Band + 191, // Soul Dew + 192, // DeepSeaTooth + 193, // DeepSeaScale + + 198, // Scope Lens + + 202, // Light Ball + + 219, // Shell Bell + + 254, 255, 256, 257, 258, 259, // Scarves + ]; }