This is a small library intended for use with my Dicer applications.
It's not being 'maintained' in the usual sense, but feel free to fork and use it as a basis for your own work.
Input should be a string written in dice notation or arithmetic. Supports exploding dice - 2d6!
.
Returns summed output based on dice roll/expression.
Supports addition, subtration, multiplication, and division. Expressions can use parentheses.
Returns a vector of numbers based on dice roll/expression.
-
base
represents the type of dice to use when not specified.- E.g.
pool("2+2", 10)
is equivalent to4d10
.
- E.g.
-
threshold
determines the minimum required for a successful dice roll.- If less than 1, minimum equals
threshold * die_faces + 1
(rounded down) - If greater than 1,
minimum = threshold
- If less than 1, minimum equals
Only supports addition and subtraction. Subtraction truncates the pool by number of dice specificed - type is irrelevant. If more dice are subtracted than exists in the pool, returns [(0, false)]
(automatic failure).
NOTE: Pools combining dice and integers cannot begin with an integer. 2+1d10
is invalid, but 1d10+2
is allowed.
MIT