gurgle

Crates.iogurgle
lib.rsgurgle
version0.5.0
sourcesrc
created_at2021-07-11 17:37:36.308262
updated_at2021-07-30 12:54:37.023725
descriptionYet another dice rolling crate
homepagehttps://github.com/7sDream/gurgle
repositoryhttps://github.com/7sDream/gurgle
max_upload_size
id421514
size47,691
7sDream (7sDream)

documentation

https://docs.rs/gurgle

README

Gurgle

Badge with github icon Badge with document icon

Gurgle is yet another dice rolling crate using TRPG-like syntax.

Have a Taste

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.

License

BSD 3-Clause Clear License, See LICENSE.

Commit count: 24

cargo fmt