reroll

Crates.ioreroll
lib.rsreroll
version1.0.0
created_at2025-07-17 14:44:09.889345+00
updated_at2025-07-17 14:44:09.889345+00
descriptioncli app to roll dice!
homepagehttps://github.com/DVDTSB/reroll
repositoryhttps://github.com/DVDTSB/reroll
max_upload_size
id1757607
size31,223
Tache David Stefan (DVDTSB)

documentation

README

๐ŸŽฒ reroll

A powerful and flexible command-line dice roller for tabletop games and probability testing.

Supports:

  • Standard dice expressions like d8,3d6, 4d6kh3, and 2d10dl1
  • Arithmetic operations: +, -, *, /
  • Repetition syntax: 3(1d6+2) rolls 1d6+2 three times
  • Modifiers: explode (!), keep/drop high/low (k/kh, kl, d/dh, dl)

๐Ÿงพ Usage

reroll "4d6kh3 + 2"
reroll "3(2d8+1)"
reroll "1d20 + 5" 

Use quotes around expressions to avoid shell interference.

๐Ÿ” Options

  • -v or --verbose: Show all final rolls.
  • -h or --help: Print help and usage info.

โœจ Features

  • Full support for nested expressions with correct order of operations
  • Exploding dice (e.g., 1d6!) with custom thresholds (e.g., 1d6!5)
  • Deterministic expression parsing using pest

๐Ÿงช Example Output

$ reroll "4d6kh3"
14

$ reroll -v "4d6kh3"
[6, 4, 4]

๐Ÿ”ง Build

cargo build --release

โœ… Tests

cargo test

๐Ÿ“ File Structure

  • src/parser.rs: Expression parsing (via Pest)
  • src/eval.rs: Expression evaluation and dice logic
  • src/main.rs: CLI frontend

๐Ÿ“œ Syntax Reference

Example Meaning
3d6 Roll 3 six-sided dice
4d6kh3 Roll 4d6, keep the highest 3
2d8dl1 Roll 2d8, drop the lowest 1
1d6! Exploding dice on max roll
3(1d6+2) Roll 1d6+2 three times
(2d6+1)*2 Roll and apply arithmetic

Made with ๐Ÿ€ for dice goblins and probability nerds.

Commit count: 0

cargo fmt