a dice roller library for Rust, supporting most common modifiers.
- standard notation (e.g.
3d6, etc.) - modifiers (e.g.
3d6kh2,4d10r1, etc.) - explosions! (e.g.
1d6!6,2d10x10, etc.) - command-line tool to roll dice from terminal
- fate/fudge dice
- math
use dice::roll;
fn main() {
let values = roll("3d6");
println!("3d6: {:?} (sum: {})", values, values.iter().sum::<i32>());
}or, with the command line tool,
$ roll 4d6kh3
[4, 4, 1] (3) = 9use dice::Roll;
fn main() {
let roll: Roll = "4d6rr1kh3".try_into().unwrap();
let min = roll.min();
let max = roll.max();
println!("min: {:?}, max: {:?}", min, max);
}$ roll --stats 4d6rr1kh3
min: 6, max: 18$ roll -j 2d10
{
"rolls": [
{
"events": [],
"rolls": [
3,
9
],
"original_rolls": [
3,
9
],
"sum": 12
}
]
}
$ roll -j 1d6x6
{
"rolls": [
{
"events": [
{
"Explode": {
"index": 0,
"new_value": 4
}
}
],
"rolls": [
6,
4
],
"original_rolls": [
6
],
"sum": 10
}
]
}MIT licensed, see license for details.