Extends
Classes
Members
currency :number
Currency alias for gold.
- number
- Source
equipment :Object
Equipment mapping getter mirroring the equipment system slots. Non-null slots are enumerable so Object.entries(equipment) reflects only equipped items, while direct slot property access (e.g. equipment.mainHand or equipment.weapon) returns the item or null.
- Object
- Source
isFull
Check if inventory is full.
- Source
isFull :boolean
Check if inventory is full.
- boolean
- Source
(readonly) properties
The entity that this component is attached to.
- Inherited From
- Source
Methods
addCurrency(amount) → {number}
Add currency (gold).
| Name | Type | Description |
|---|---|---|
amount | number |
- Source
Total currency.
- Type:
- number
addItem(item, quantity) → {boolean}
Add an item to inventory.
| Name | Type | Default | Description |
|---|---|---|---|
item | Item | ||
quantity | number | 1 |
- Source
True if added successfully.
- Type:
- boolean
addItem(itemOrId, quantityopt, optionsopt) → {boolean}
Add an item to the inventory. Stacks with existing matching slots up to maxStack, then allocates new slots. Enforces maxSlots capacity limits to prevent overflow.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
itemOrId | Object | | |||
quantity | number | <optional> | 1 | |
options | Object | <optional> |
- Source
True if added successfully, false if rejected due to capacity.
- Type:
- boolean
canAddItem(itemOrId, quantityopt) → {boolean}
Check whether an item quantity can be added without exceeding capacity limits.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
itemOrId | Object | | |||
quantity | number | <optional> | 1 |
- Source
- Type:
- boolean
consume(itemId, target) → {boolean}
Consume a consumable item, applying its effects to the target and decrementing count. Supports targets that are Combatant, Stats, or custom entities.
| Name | Type | Description |
|---|---|---|
itemId | string | |
target | Object | Target Combatant or Stats. |
- Source
True if consumed successfully, false otherwise.
- Type:
- boolean
consumeItem(itemId, target) → {boolean}
Alias for consume.
| Name | Type | Description |
|---|---|---|
itemId | string | |
target | Object |
- Source
- Type:
- boolean
createSnapshot() → {Object}
Create persistence snapshot of inventory, equipment, and currency.
- Source
- Type:
- Object
deserialize(props)
Populates the component properties from a data object. Override this method for custom property handling.
| Name | Type | Description |
|---|---|---|
props | object | The properties object (usually from JSON). |
- Inherited From
- Source
equip(slotOrItemId, maybeItemIdopt) → {Object|boolean}
Equip an item from inventory into designated equipment slot.
| Name | Type | Attributes | Description |
|---|---|---|---|
slotOrItemId | string | ||
maybeItemId | string | <optional> |
- Source
- Type:
- Object |
boolean
getItemCount(itemId) → {number}
Get total count of an item.
| Name | Type | Description |
|---|---|---|
itemId | string |
- Source
- Type:
- number
getItemCount(itemId) → {number}
Get total quantity of an item across all slots.
| Name | Type | Description |
|---|---|---|
itemId | string |
- Source
- Type:
- number
getItemMaxStack(item) → {number}
Resolve the maxStack limit for an item.
| Name | Type | Description |
|---|---|---|
item | Object |
- Source
- Type:
- number
hasCurrency(amount) → {boolean}
Check if inventory has at least currency amount.
| Name | Type | Description |
|---|---|---|
amount | number |
- Source
- Type:
- boolean
hasItem(itemId, quantity) → {boolean}
Check if inventory contains an item.
| Name | Type | Default | Description |
|---|---|---|---|
itemId | string | ||
quantity | number | 1 |
- Source
- Type:
- boolean
hasItem(itemId, quantityopt) → {boolean}
Check if inventory contains at least quantity of an item.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
itemId | string | |||
quantity | number | <optional> | 1 |
- Source
- Type:
- boolean
loadJSON(data)
Load state from plain JSON representation.
| Name | Type | Description |
|---|---|---|
data | Object |
- Source
removeCurrency(amount) → {boolean}
Deduct currency (gold) if sufficient.
| Name | Type | Description |
|---|---|---|
amount | number |
- Source
True if deducted, false if insufficient.
- Type:
- boolean
removeItem(itemId, quantity) → {boolean}
Remove an item from inventory.
| Name | Type | Default | Description |
|---|---|---|---|
itemId | string | ||
quantity | number | 1 |
- Source
True if removed successfully.
- Type:
- boolean
removeItem(itemId, quantityopt) → {boolean}
Remove an item quantity from the inventory.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
itemId | string | |||
quantity | number | <optional> | 1 |
- Source
True if removed successfully, false if insufficient items.
- Type:
- boolean
restoreSnapshot(snapshot, optionsopt) → {boolean}
Restore inventory, equipment, and currency from persistence snapshot.
| Name | Type | Attributes | Description |
|---|---|---|---|
snapshot | Object | ||
options | Object | <optional> |
- Source
- Type:
- boolean
toJSON() → {Object}
Export to plain JSON representation.
- Source
- Type:
- Object
unequip(slot) → {Object|boolean}
Unequip an item from equipment slot back into inventory. Rejects if inventory has no capacity to store the unequipped item.
| Name | Type | Description |
|---|---|---|
slot | string |
- Source
Unequipped item or false if failed.
- Type:
- Object |
boolean
useItem(itemId, target) → {boolean}
Alias for consume.
| Name | Type | Description |
|---|---|---|
itemId | string | |
target | Object |
- Source
- Type:
- boolean