mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-03-21 17:48:28 -05:00
FR/LG VC: disallow unavailable held items
Also ban Berry Juice from being released in mainline fix casting issue
This commit is contained in:
parent
fa0ac2a9ab
commit
bde5729883
|
|
@ -54,7 +54,7 @@ public sealed class ItemStorage3RS : IItemStorage
|
|||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
|
||||
];
|
||||
|
||||
internal static ReadOnlySpan<ushort> Unreleased => [005]; // Safari Ball
|
||||
internal static ReadOnlySpan<ushort> Unreleased => [005, 044]; // Safari Ball, Berry Juice
|
||||
|
||||
public static ushort[] GetAllHeld() => [..General, ..Balls, ..Berry, ..MachineOnlyTM];
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// For a species with a potentially valid FR/LG origin encounter, flag if not permitted.
|
||||
/// </summary>
|
||||
public static bool IsForeignFRLG(ushort species) => IsForeign(ForeignFRLG, species);
|
||||
public static bool IsForeignFRLG(ushort species) => IsForeign(ForeignFRLG, species, ShiftFRLG);
|
||||
|
||||
public static bool IsForeign(ReadOnlySpan<byte> bitSet, int species)
|
||||
public static bool IsForeign(ReadOnlySpan<byte> 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<byte> bitSet, int species)
|
|||
0xFF, 0xFF, 0xFB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0x03,
|
||||
];
|
||||
|
||||
private static ReadOnlySpan<ushort> 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
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user