Constructor
new Inventory(inventoryConfig)
- Source:
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
inventoryConfig |
InventoryConfig | The inventory configuration Properties
|
Members
full
- Source:
Properties:
Type | Description |
---|---|
boolean | Whether the inventory is full |
itemSlots
- Source:
Properties:
Type | Description |
---|---|
Array.<ClubCrawler.Objects.Inventory.InventoryItemSlot> | The inventory item slots in the inventory |
nextFreeSlot
- Source:
Properties:
Type | Description |
---|---|
number | The index of the next free slot |
Methods
addItem(gameItem) → {boolean}
- Source:
Adds an item to the inventory
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
gameItem |
Object | An item to add to the inventory Properties
|
Fires:
Returns:
- Whether the item could be added
- Type
- boolean
getInstance(index, additionalConfigopt)
- Source:
gets an instance of an item at a slot index
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
index |
number | the slot to get |
||
additionalConfig |
Object |
<optional> |
{}
|
additional config params to give instance on construction |
pop(indexopt, additionalConfigopt)
- Source:
Gets an instance of an item at the slot index and clears that slot
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
index |
number |
<optional> |
0
|
the slot to get |
additionalConfig |
Object |
<optional> |
{}
|
additional config params to give instance on construction |
setNextFreeItemSlot()
- Source:
Finds the next empty slot in inventory and sets nextFreeSlot to that index
swapSlots(slot1, slot2)
- Source:
Swaps the positions of two slots.
Parameters:
Name | Type | Description |
---|---|---|
slot1 |
InventoryItemSlot | A slot |
slot2 |
InventoryItemSlot | A slot |