[][src]Crate one_d_six

Provides utilities for rolling dice.

Examples

Simple Usage

use one_d_six::quickroll;

if quickroll("1d2") == 1 {
    println!("Heads!");
} else {
    println!("Tails!");
}

Adding Sets of Dice Together

use one_d_six::Dice;

// 3d6
let set_1 = Dice::new(3, 6);
// 2d4
let set_2: Dice = "2d4".parse().unwrap();

// 3d6 + 2d4
let dice = set_1 + set_2;

// Each set of dice starts pre-rolled
let roll = dice.total();

println!("Result of 3d6 + 2d4 roll: {}", roll);

Getting Dice as String

Simple String

use one_d_six::Dice;


println!("3d6: {}", Dice::new(3, 6));

Complex String

use one_d_six::Dice;


// Will look like "1 2 3"
println!("3d6: {:?}", Dice::new(3, 6));

Structs

Dice

A Handful of dice.

Die

Represents a single die. Has an initial random value.

Functions

quickroll

Rolls dice based on a 1d6 style string.

try_quickroll

Attempts to roll dice based on a 1d6 style string.