#dnd #dice #roller

dnd_dice_roller

A simple dice rolling library for dnd dice strings

7 releases (4 breaking)

0.5.1 Apr 18, 2021
0.5.0 Apr 10, 2021
0.4.0 Aug 21, 2020
0.3.0 May 10, 2020
0.1.0 Mar 30, 2020
Download history 17/week @ 2023-02-05 27/week @ 2023-02-12 22/week @ 2023-02-19 1/week @ 2023-02-26 21/week @ 2023-03-05 7/week @ 2023-03-12 10/week @ 2023-03-19 21/week @ 2023-03-26 14/week @ 2023-04-02 23/week @ 2023-04-09 6/week @ 2023-04-16 6/week @ 2023-04-23 23/week @ 2023-04-30 22/week @ 2023-05-07 7/week @ 2023-05-14 5/week @ 2023-05-21

57 downloads per month
Used in holding

MIT license

29KB
544 lines

dnd_dice_roller

A simple Rust library for taking a DnD like dice string as an input and calculating a result.

Supports advantage and disadvantage.

Usage

use dice_roller::dice::{Dice, RollType};
use std::str::FromStr;

let dice = Dice::from_str("2d20 + 1")?;
// Roll dice uses thread RNG
let result = dice.roll_dice();

A single d20 with a plus five modifier and advantage
let second_dice = Dice::new(1, 20, Some(5), RollType::Advantage);
let results = second_dice.roll_dice();

Example inputs

d6
2d6
2d6 + 3
d20 advantage
d20 adv
d20 a
2d20 + 4 advantage
2d20 - 2 adv
1d6 - 1 disadvantage
1d6 dadv
d6 d

Dependencies

~1.6–2.1MB
~45K SLoC