ExDiceRoller v0.4.0-alpha ExDiceRoller.Sigil
Han dles the sigil ~a
for dice rolling. If no options are specified, the
sigil will return the compiled function based on the provided roll.
The following options are available:
r
: Compiles and invokes the roll. Variables are not supported with this.e
: Allows dice to explode. Can only be used alongside optionr
.
Example
iex> import ExDiceRoller.Sigil
ExDiceRoller.Sigil
iex> fun = ~a/1+1/
iex> fun.([], [])
2
iex> import ExDiceRoller.Sigil
iex> fun = ~a/1d4/
iex> fun.([], [])
1
iex> fun.([], [])
4
iex> import ExDiceRoller.Sigil
iex> ~a/1d6+1/r
4
iex> ~a/1d2/re
7
iex> import ExDiceRoller.Sigil
iex> ~a/1d2/e
{:error, :explode_allowed_only_with_roll}