gametools
gametools is a lightweight Rust library for simulating game components like dice rolls, card decks, dominos, and spinners. It's designed to be modular, testable, and usable in both game engines and CLI tools. The goal is to provide reusable game apparatus โ not game logic โ so you can build your rules on top of well-tested building blocks.
Features
- ๐ฒ Numeric dice up to 255 sides, plus dice pools with chainable operations
- ๐ Standard playing cards: decks, hands, piles, shuffling, drawing
- ๐ซ Dominos with support for longest-path train solving
- ๐ Spinners with support for weighted wedges and optional blocking
- ๐ฅ Human-readable game errors for common failure conditions
- ๐งช Well-documented and tested with 90%+ code coverage
Example: Dice
use ;
let d6 = new;
let total = d6.roll_into_pool
.take_highest
.nerf
.sum;
Example: Spinners
use ;
let wedges = wedges_from_values;
let spinner = new;
if let Some = spinner.spin
Philosophy
This crate avoids hardcoding game rules. Instead, it provides flexible, composable abstractions to make building games easier โ whether you're making a tabletop simulator, card game engine, or randomizer tool.
Documentation
Full API docs with usage examples are available via docs.rs.
More Examples
See additional usage examples in the module docs:
- Cards module: shuffling, drawing, hands
- Dominos module: longest-train solver
License
Licensed under MIT. Contributions welcome!