Summary
Functions
Adds weight to ALL dice in the Dice struct.
Take a list of Dice structs, and combine them without rerolling
Directly create a Dice struct.
Takes a Dice struct and rerolls it.
Convenience sigil for creating dice
Types
Functions
Adds weight to ALL dice in the Dice struct.
Examples
iex> :rand.seed(:exsss, {205, 301, 402})
iex> d = ~d{10, 20}
iex> Enum.map(d.dice, &(&1.result))
[17, 1, 17, 11, 12, 13, 17, 13, 14, 3]
iex> d.total
118
iex> d = Dice.add_weight(d, [%{target: 2, weight: 50}])
iex> d = Dice.roll(d)
iex> Enum.map(d.dice, &(&1.result))
[10, 2, 2, 2, 2, 2, 2, 2, 2, 2]
iex> d.total
28
Take a list of Dice structs, and combine them without rerolling
Directly create a Dice struct.
Takes a Dice struct and rerolls it.
Examples
iex> :rand.seed(:exsss, {200, 301, 402})
iex> dice = ~d{2, 12}
iex> dice.total
12
iex> Dice.roll(dice).total
20
Convenience sigil for creating dice
Examples
iex> :rand.seed(:exsss, {100, 101, 102})
iex> d = ~d{4, 6, 1} # Equal to 4d6+1 in standard dice notation
iex> [die1 | _] = d.dice
iex> die1.sides
6
iex> die1.result
2
iex> d.subtotal
9
iex> d.total
10