StandardDice

StandardDice

Represents a standard numerical die.

Kind: global class

new StandardDice(sides, [qty], [modifiers], [min], [max], [description])

Create a StandardDice instance.

Throws:

  • RequiredArgumentError sides is required
  • TypeError qty must be a positive integer, and modifiers must be valid
ParamTypeDefaultDescription
sidesnumberThe number of sides the die has (.e.g 6)
[qty]number1The number of dice to roll (e.g. 4)
[modifiers]Map.<string, Modifier> | Array.<Modifier> | Object | nullThe modifiers that affect the die
[min]number | null1The minimum possible roll value
[max]number | nullThe maximum possible roll value. Defaults to number of sides
[description]Description | string | nullThe roll description.

standardDice.average ⇒ number

The average value that the die can roll (Excluding modifiers).

Kind: instance property of StandardDice

standardDice.modifiers ⇒ Map.<string, Modifier> | null

The modifiers that affect this die roll.

Kind: instance property of StandardDice

standardDice.modifiers

Set the modifiers that affect this roll.

Kind: instance property of StandardDice
Throws:

  • TypeError Modifiers should be a Map, array of Modifiers, or an Object
ParamType
valueMap.<string, Modifier> | Array.<Modifier> | Object | null

standardDice.max ⇒ number

The maximum value that can be rolled on the die, excluding modifiers.

Kind: instance property of StandardDice

standardDice.min ⇒ number

The minimum value that can be rolled on the die, excluding modifiers.

Kind: instance property of StandardDice

standardDice.name ⇒ string

The name of the die.

Kind: instance property of StandardDice
Returns: string - 'standard'

standardDice.notation ⇒ string

The dice notation. e.g. 4d6!.

Kind: instance property of StandardDice

standardDice.qty ⇒ number

The number of dice that should be rolled.

Kind: instance property of StandardDice

standardDice.sides ⇒ number

The number of sides the die has.

Kind: instance property of StandardDice

standardDice.roll() ⇒ RollResults

Roll the dice for the specified quantity and apply any modifiers.

Kind: instance method of StandardDice
Returns: RollResults - The result of the roll

standardDice.rollOnce() ⇒ RollResult

Roll a single die and return the value.

Kind: instance method of StandardDice
Returns: RollResult - The value rolled

standardDice.toJSON() ⇒ Object

Return an object for JSON serialising.

This is called automatically when JSON encoding the object.

Kind: instance method of StandardDice

standardDice.toString() ⇒ string

Return the String representation of the object.

This is called automatically when casting the object to a string.

Kind: instance method of StandardDice
See: notation