Crates.io | gurgle |
lib.rs | gurgle |
version | 0.5.0 |
source | src |
created_at | 2021-07-11 17:37:36.308262 |
updated_at | 2021-07-30 12:54:37.023725 |
description | Yet another dice rolling crate |
homepage | https://github.com/7sDream/gurgle |
repository | https://github.com/7sDream/gurgle |
max_upload_size | |
id | 421514 |
size | 47,691 |
Gurgle is yet another dice rolling crate using TRPG-like syntax.
let attack = "3d6+2d4+1";
println!("roll your attack({}), result: {}", attack, gurgle::roll(attack).unwrap());
// output: roll your attack(3d6+2d4+1), result: 16
use gurgle::Gurgle;
let attack = "3d6+2d4+1>15";
let dice = Gurgle::compile(attack).unwrap();
let result = dice.roll();
println!("roll your attack({}), result: {}", attack, result);
// output: roll your attack(3d6+2d4+1>15), result: (4+3+1) + (1+3) + 1 = 15, target is >15, failed
Notice: Display
trait for rolling result is implemented only if feature detail
(which is enabled by default) is enabled.
But you can always use result.value()
to get rolling result value(i64), and result.success()
to get if it's a success.
Gurgle also support multiply and parentheses, see docs for full syntax and example.
BSD 3-Clause Clear License, See LICENSE.