3 releases (breaking)
Uses new Rust 2024
| 0.2.0 | Jun 23, 2025 |
|---|---|
| 0.1.0 | Jun 22, 2025 |
| 0.0.0-reserved | Jun 20, 2025 |
#190 in Games
79 downloads per month
63KB
1.5K
SLoC
dnd
D&D 5e types and common mechanics.
This crate provides types and common mechanics used in Dungeons & Dragons 5th Edition (D&D 5e).
Getting Started
To use this crate, add it to your Cargo.toml:
cargo add dnd
You can then import the necessary modules in your Rust code:
use dnd::core::{AbilityScore, AbilityModifier, Level, ProficiencyBonus};
let strength = AbilityScore::new(16);
let modifier = AbilityModifier::from(strength);
let level = Level::new(5);
let proficiency_bonus = ProficiencyBonus::from(level);
assert_eq!(modifier.value(), 3);
assert_eq!(proficiency_bonus.value(), 3);
Features
This crate has optional features and is no_std-compatible:
-
std: Enabled by default; it includes the standard library. If you want to use this crate in ano_stdenvironment, you can disable this feature:dnd = { version = "...", default-features = false } -
serde: Enables serialization and deserialization usingserde. This feature is optional and can be enabled by adding theserdefeature in yourCargo.toml:dnd = { version = "...", features = ["serde"] }
Contributing
This project uses just to run commands the same way as the CI:
cargo just checkto check formatting and lints.cargo just coverageto generate and preview code coverage.cargo just docto generate and preview docs.cargo just testto run tests.
For a full list of commands, see the Justfile.
Dependencies
~205–700KB
~16K SLoC