View Source ExTTRPGDev.Dice (ExTTRPGDev v0.2.1)

This module deals with the rolling of any and all dice

Link to this section Summary

Functions

Roll dice defined by the input string

Rolls the a number of multisided dice

Rolls a die with the number of sides given in the input

Validates that a given string conforms to the expexted dice specifying format

Link to this section Functions

Roll dice defined by the input string

Returns: List of die roll results

examples

Examples

# Although not necessary, let's seed the random algorithm
iex> :rand.seed(:exsplus, 1337)
iex> ExTTRPGDev.Dice.roll("3d4")
[4, 4, 1]
Link to this function

roll(number_of_dice, dice_sides)

View Source

Rolls the a number of multisided dice

Returns: List of die roll results

examples

Examples

# Although not necessary, let's seed the random algorithm
iex> :rand.seed(:exsplus, 1337)
iex> ExTTRPGDev.Dice.roll(3, 8)
[4, 8, 5]

Rolls a die with the number of sides given in the input

Returns: the rolled number

examples

Examples

# Although not necessary, let's seed the random algorithm
iex> :rand.seed(:exsplus, 1337)
iex> ExTTRPGDev.Dice.roll_d(6)
6
iex> ExTTRPGDev.Dice.roll_d(6)
2

Validates that a given string conforms to the expexted dice specifying format

Returns: the input string

examples

Examples

iex> ExTTRPGDev.Dice.validate_dice_str("3d4")
"3d4"

iex> ExTTRPGDev.Dice.validate_dice_str("3")
** (RuntimeError) Improper dice format. Dice must be given in xdy where x and y are both integers