RollTable

RollTable

The RollTable entity which implements randomized rollable tables

Constructor

new RollTable()

Source:

Members

(static) config

Source:

results :Array.<Object>

Source:

A convenience accessor for the array of TableResult embedded documents

Type:

Methods

(async) draw(roll, results, displayChat, rollModeopt) → {Promise.<{roll: Roll, results: Array.<object>}>}

Source:

Draw a result from the RollTable based on the table formula or a provided Roll instance

Parameters:
Name Type Attributes Description
roll Roll | null

An existing Roll instance to use for drawing from the table

results Array.<object>

One or more table results which have been drawn

displayChat boolean

Whether to automatically display the results in chat

rollMode string | null <optional>

The chat roll mode to use when displaying the result

Returns:

A Promise which resolves to an object containing the executed roll and the produced results

Type
Promise.<{roll: Roll, results: Array.<object>}>

(async) drawMany(number, rollopt, displayChatopt, rollModeopt) → {Promise.<{roll: Roll, results: Array.<object>}>}

Source:

Draw multiple results from a RollTable, constructing a final synthetic Roll as a dice pool of inner rolls.

Parameters:
Name Type Attributes Description
number number

The number of results to draw

roll Roll <optional>

An optional pre-configured Roll instance which defines the dice roll to use

displayChat boolean <optional>

Automatically display the drawn results in chat? Default is true

rollMode string <optional>

Customize the roll mode used to display the drawn results

Returns:
Type
Promise.<{roll: Roll, results: Array.<object>}>

getTableResult()

Source:

(async) normalize() → {Promise}

Source:

Normalize the probabilities of rolling each item in the RollTable based on their assigned weights

Returns:
Type
Promise

prepareEmbeddedEntities()

Source:

(async) reset() → {Promise}

Source:

Reset the state of the RollTable to return any drawn items to the table

Returns:
Type
Promise

roll(rollopt, _depth) → {Object}

Source:

Evaluate a RollTable by rolling its formula and retrieving a drawn result.

Note that this function only performs the roll and identifies the result, the RollTable#draw function should be called to formalize the draw from the table.

Example
// Draw results using the default table formula
const defaultResults = table.roll();

// Draw results using a custom roll formula
const roll = new Roll("1d20 + @abilities.wis.mod", actor.getRollData());
const customResults = table.roll({roll});
Parameters:
Name Type Attributes Description
roll Roll <optional>

An alternative dice Roll to use instead of the default formula for the table

_depth number

An internal flag used to track recursion depth

Returns:

An object containing the executed roll and the produced results

Type
Object

(async) toMessage(results, rollopt, messageDataopt, messageOptionsopt)

Source:

Display a result drawn from a RollTable in the Chat Log along. Optionally also display the Roll which produced the result and configure aspects of the displayed messages.

Parameters:
Name Type Attributes Description
results Array.<object>

An Array of one or more table results which were drawn and should be displayed

roll Roll <optional>

An optional Roll instance which produced the drawn results

messageData Object <optional>

Additional data which customizes the created messages

messageOptions Object <optional>

Additional options which customize the created messages