//
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
namespace MUnique.OpenMU.DataModel;
///
/// The constants for the players inventory.
///
public static class InventoryConstants
{
///
/// The first equippable item slot index.
///
public static readonly byte FirstEquippableItemSlotIndex = 0;
///
/// The last equippable item slot index.
///
public static readonly byte LastEquippableItemSlotIndex = 11;
///
/// The equippable slots count.
///
public static readonly byte EquippableSlotsCount = (byte)(LastEquippableItemSlotIndex - FirstEquippableItemSlotIndex + 1);
///
/// The left hand inventory slot index.
///
public static readonly byte LeftHandSlot = 0;
///
/// The right hand inventory slot index.
///
public static readonly byte RightHandSlot = 1;
///
/// The helm inventory slot index.
///
public static readonly byte HelmSlot = 2;
///
/// The armor inventory slot index.
///
public static readonly byte ArmorSlot = 3;
///
/// The pants inventory slot index.
///
public static readonly byte PantsSlot = 4;
///
/// The gloves inventory slot index.
///
public static readonly byte GlovesSlot = 5;
///
/// The boots inventory slot index.
///
public static readonly byte BootsSlot = 6;
///
/// The wings inventory slot index.
///
public static readonly byte WingsSlot = 7;
///
/// The pet inventory slot index.
///
public static readonly byte PetSlot = 8;
///
/// The pendant inventory slot index.
///
public static readonly byte PendantSlot = 9;
///
/// The first ring inventory slot index.
///
public static readonly byte Ring1Slot = 10;
///
/// The second ring inventory slot index.
///
public static readonly byte Ring2Slot = 11;
///
/// The size of a row.
///
public static readonly int RowSize = 8;
///
/// Number of rows in the inventory.
///
public static readonly byte InventoryRows = 8;
///
/// The maximum number of extensions.
///
public static readonly byte MaximumNumberOfExtensions = 4;
///
/// The number of rows of one extension.
///
public static readonly byte RowsOfOneExtension = 4;
///
/// Number of rows of the inventory extension.
///
public static readonly byte AllInventoryExtensionRows = (byte)(MaximumNumberOfExtensions * RowsOfOneExtension);
///
/// Index of the first personal store slot.
/// 12 = number of wearable item slots
/// 64 = number of inventory slots.
///
public static readonly byte FirstExtensionItemSlotIndex = (byte)(
EquippableSlotsCount + // 12
(InventoryRows * RowSize)); // 64
///
/// Index of the first personal store slot.
/// 12 = number of wearable item slots
/// 64 = number of inventory slots
/// 128 = number of extended inventory slots (64 are hidden in game, S6E3).
///
///
/// TODO: This is only valid in season 6! Before, there are no extensions and the store begins earlier.
///
public static readonly byte FirstStoreItemSlotIndex = (byte)(
EquippableSlotsCount + // 12
(InventoryRows * RowSize) + // 64
(AllInventoryExtensionRows * RowSize)); // 128
///
/// The number of personal store rows.
///
public static readonly byte StoreRows = 4;
///
/// The size of the personal store.
///
public static readonly byte StoreSize = (byte)(StoreRows * RowSize);
///
/// The number of temporary storage rows.
///
public static readonly byte TemporaryStorageRows = 4;
///
/// The number of temporary storage slots.
///
public static readonly byte TemporaryStorageSize = (byte)(TemporaryStorageRows * RowSize);
///
/// The number of rows in the warehouse (vault).
///
public static readonly byte WarehouseRows = 15;
///
/// The number of warehouse item slots.
///
public static readonly byte WarehouseSize = (byte)(WarehouseRows * RowSize);
///
/// Gets the size of the inventory with the specified number of extensions.
///
/// The number of inventory extensions.
/// The size of the inventory.
public static byte GetInventorySize(int numberOfExtensions)
{
var size = EquippableSlotsCount +
(InventoryRows * RowSize) +
(RowsOfOneExtension * RowSize * Math.Max(Math.Min(numberOfExtensions, MaximumNumberOfExtensions), 0));
return (byte)size;
}
///
/// Determines whether the item slot is of an defending item.
///
/// The item slot.
/// , if the slot is of an defending item.
public static bool IsDefenseItemSlot(byte itemSlot)
{
return (itemSlot >= HelmSlot && itemSlot <= WingsSlot)
|| itemSlot == Ring1Slot
|| itemSlot == Ring2Slot;
}
}