Constructor
new LootTable(entriesopt, configopt)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
entries | Array.<Object> | <optional> | Initial loot entries. |
config | Object | <optional> | Optional configuration { id, name }. |
- Source
Classes
Methods
(static) fromJSON(data) → {LootTable}
Reconstruct a LootTable from JSON data.
Parameters:
| Name | Type | Description |
|---|---|---|
data | Object |
- Source
Returns:
- Type:
- LootTable
addEntry(entry) → {LootTable}
Add a drop entry to the loot table.
Parameters:
| Name | Type | Description |
|---|---|---|
entry | Object | { itemId, weight, minQuantity, maxQuantity, chance, item } |
- Source
Returns:
- Type:
- LootTable
addItem(itemId, weightopt, minQuantityopt, maxQuantityopt, chanceopt) → {LootTable}
Convenience method to add an item drop.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
itemId | string | |||
weight | number | <optional> | 1 | |
minQuantity | number | <optional> | 1 | |
maxQuantity | number | <optional> | 1 | |
chance | number | <optional> | 1 |
- Source
Returns:
- Type:
- LootTable
removeEntry(itemId) → {boolean}
Remove a drop entry by item id.
Parameters:
| Name | Type | Description |
|---|---|---|
itemId | string |
- Source
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:
| Name | Type | Attributes | Description |
|---|---|---|---|
optionsOrRandom | Object | | <optional> | Options object or custom random function. |
- Source
Returns:
Array of generated drops { itemId, quantity, [item] }
- Type:
- Array.<Object>
toJSON() → {Object}
Export to plain JSON representation.
- Source
Returns:
- Type:
- Object