Inventory

ClubCrawler.Objects.Inventory. Inventory

The player's inventory

Constructor

new Inventory(inventoryConfig)

Source:
Parameters:
Name Type Description
inventoryConfig InventoryConfig

The inventory configuration

Properties
Name Type Description
inventorySize number

The inventory size

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
Name Type Attributes Default Description
itemType String <optional>
"general"

The game item type. Items of type weapon can only have 1 copy in inventory with identical name. Stackables increase quanity by one. General can have duplicates.

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