dice_roller_rs
A Rust library for simulating dice rolls in RPG-style games.
Features
- Roll multiple dice with modifiers (e.g., 2d6+3)
- Simple single die rolls
- Roll with advantage (D&D 5e style - roll twice, take higher)
- Roll with disadvantage (roll twice, take lower)
- Detailed roll results with individual die values
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Usage
use ;
API
roll(num_dice: u32, sides: u32, modifier: i32) -> DiceRoll
Roll multiple dice with a modifier. Returns a DiceRoll struct containing:
num_dice: Number of dice rolledsides: Number of sides on each diemodifier: Modifier added to the totalrolls: Vector of individual roll resultstotal: Sum of rolls plus modifier
roll_simple(sides: u32) -> u32
Roll a single die and return the result.
roll_advantage(sides: u32) -> u32
Roll twice and return the higher result.
roll_disadvantage(sides: u32) -> u32
Roll twice and return the lower result.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.