gametools

Crates.iogametools
lib.rsgametools
version
sourcesrc
created_at2025-04-06 06:51:06.911555+00
updated_at2025-04-14 01:57:54.844252+00
descriptionGame-related tools: spinners, dice, dominos, and cards.
homepage
repositoryhttps://github.com/pygmy-twylyte/gametools
max_upload_size
id1622677
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(pygmy-twylyte)

documentation

README

Crates.io Docs.rs Build Status License: MIT

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 gametools::{Die, DicePool};

let d6 = Die::new(6);
let total = d6.roll_into_pool(5)
    .take_highest(4)
    .nerf(1)
    .sum();

Example: Spinners

use gametools::spinners::{Spinner, wedges_from_values};

let wedges = wedges_from_values(vec!["Rock", "Paper", "Scissors"]);
let spinner = Spinner::new(wedges);

if let Some(result) = spinner.spin() {
    println!("You chose: {result}");
}

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:

License

Licensed under MIT. Contributions welcome!

Commit count: 0

cargo fmt