Expand description
Core dice primitives and roll orchestration for rdice.
rdice_core owns the domain model used by the command-line and terminal
interfaces: dice, trays, roll expressions, random rolls, and deterministic
roll analysis.
§Quick start
use rdice_core::{DiceEngine, FaceValue, parse_roll_exprs};
let mut engine = DiceEngine::new();
engine.create_die(
"Coin",
vec![FaceValue::Text("heads".into()), FaceValue::Text("tails".into())],
)?;
let parsed = parse_roll_exprs(&["2d6", "Coin", "3"])?;
let analysis = engine.analyze_roll(&parsed.dice, &parsed.modifiers)?;
assert_eq!(analysis.point_range.min, 5);
assert_eq!(analysis.point_range.max, 15);
§Naming
Built-in dice are exposed with uppercase names such as D6 and D20.
Numeric roll expressions are case-insensitive, so d6 and D6 resolve to
the same die. Custom dice are stored with CUSTOM_PREFIX internally, but
API methods that accept die names also accept the unprefixed custom name.
Re-exports§
pub use die::CUSTOM_PREFIX;pub use die::Die;pub use die::DieKind;pub use die::FaceValue;pub use die::builtin_dice;pub use engine::DiceEngine;pub use engine::DieRoll;pub use engine::PointRange;pub use engine::RollAnalysis;pub use engine::RollBatchResult;pub use engine::SlotResult;pub use engine::TrayResult;pub use error::DiceError;pub use error::Result;pub use expr::ParsedRoll;pub use expr::parse_dice_only_exprs;pub use expr::parse_roll_exprs;pub use tray::Tray;pub use tray::TraySlot;
Modules§
- die
- Dice definitions and face values. Dice value objects.
- engine
- Roll execution, roll analysis, and tray operations. Stateful dice engine.
- error
- Error and result types returned by the crate.
Error types returned by
rdice_core. - expr
- Parsing helpers for compact dice roll expressions. Parsers for compact dice roll expressions.
- tray
- Tray data structures used to group persistent dice slots. Persistent dice tray data structures.