mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-15 00:37:11 +00:00
fa9a809751
* Extract/encapsulate inventory legal arrays to interface+class Hiding them behind methods allows these to be left as ReadOnlySpan<ushort> and thus never allocate on the heap. Also refactors out some logic for checking if an item is legal. End result feels more maintainable and is less bloaty (no more passing in a nullable func) Batch editing * Add HasType filter ``` =HasType=11 .HeldItem=Meadow Plate ``` slaps a meadow plate on any pkm with grass type Use `=PersonalType1=11` for only primary grass types; only-secondary-type grass will not match it.
33 lines
1.3 KiB
C#
33 lines
1.3 KiB
C#
using System;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
public sealed class ItemStorage4Pt : ItemStorage4, IItemStorage
|
|
{
|
|
public static readonly ItemStorage4Pt Instance = new();
|
|
|
|
private static ReadOnlySpan<ushort> Pouch_Key_Pt => new ushort[]
|
|
{
|
|
428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467,
|
|
};
|
|
|
|
public static ushort[] GetAllHeld()
|
|
{
|
|
return ArrayUtil.ConcatAll(Pouch_Items_Pt, Pouch_Mail_DP, Pouch_Medicine_DP, Pouch_Berries_DP, Pouch_Ball_DP, Pouch_TMHM_DP[..^8]);
|
|
}
|
|
|
|
public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true;
|
|
|
|
public ReadOnlySpan<ushort> GetItems(InventoryType type) => type switch
|
|
{
|
|
InventoryType.Items => Pouch_Items_DP,
|
|
InventoryType.KeyItems => Pouch_Key_Pt,
|
|
InventoryType.TMHMs => Pouch_TMHM_DP,
|
|
InventoryType.MailItems => Pouch_Mail_DP,
|
|
InventoryType.Medicine => Pouch_Medicine_DP,
|
|
InventoryType.Berries => Pouch_Berries_DP,
|
|
InventoryType.Balls => Pouch_Ball_DP,
|
|
InventoryType.BattleItems => Pouch_Battle_DP,
|
|
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
|
|
};
|
|
}
|