LootTable

Loot table managing weighted drop rolls with min/max quantities.

Constructor

new LootTable(entriesopt, configopt)

Parameters:
NameTypeAttributesDescription
entriesArray.<Object><optional>

Initial loot entries.

configObject<optional>

Optional configuration { id, name }.

Classes

LootTable

Methods

(static) fromJSON(data) → {LootTable}

Reconstruct a LootTable from JSON data.

Parameters:
NameTypeDescription
dataObject
Returns:
Type: 
LootTable

addEntry(entry) → {LootTable}

Add a drop entry to the loot table.

Parameters:
NameTypeDescription
entryObject

{ itemId, weight, minQuantity, maxQuantity, chance, item }

Returns:
Type: 
LootTable

addItem(itemId, weightopt, minQuantityopt, maxQuantityopt, chanceopt) → {LootTable}

Convenience method to add an item drop.

Parameters:
NameTypeAttributesDefaultDescription
itemIdstring
weightnumber<optional>
1
minQuantitynumber<optional>
1
maxQuantitynumber<optional>
1
chancenumber<optional>
1
Returns:
Type: 
LootTable

removeEntry(itemId) → {boolean}

Remove a drop entry by item id.

Parameters:
NameTypeDescription
itemIdstring
Returns:
Type: 
boolean

roll(optionsOrRandomopt) → {Array.<Object>}

Roll drops from this loot table. Supports weighted roll mode (default) and independent chance mode. Produces random quantities between minQuantity and maxQuantity inclusive.

Parameters:
NameTypeAttributesDescription
optionsOrRandomObject | function<optional>

Options object or custom random function.

Returns:

Array of generated drops { itemId, quantity, [item] }

Type: 
Array.<Object>

toJSON() → {Object}

Export to plain JSON representation.

Returns:
Type: 
Object