#dnd #ttrpg #roll-dice #dice #parser

dice-command-parser

A library for parsing basic dice roll commands like 2d20 + 2a

10 releases (5 breaking)

0.8.0 Jan 5, 2024
0.7.3 Aug 30, 2021
0.7.2 Apr 18, 2021
0.6.0 Aug 21, 2020
0.3.1 Mar 22, 2020

#2 in #ttrpg

Download history 5/week @ 2024-12-27 1/week @ 2025-01-31 12/week @ 2025-02-14 16/week @ 2025-02-21 1/week @ 2025-02-28

110 downloads per month
Used in 2 crates (via dnd_dice_roller)

MIT license

34KB
785 lines

This crate provides functionality for the basic parsing of dice roll commands e.g. d100, d6 + 5, 2d20 - 1. Given some input it will produce a DiceRollWithOp struct which can be used to then calculate a result.


Dice Command Parser

This library parses a simple dice roll command and produces a representation of the dice that should be rolled and its modifier.

Example input: d6, 3d20, d6 + 5, or 2d20 - 4, d20+4d, d100, d100, d100.

Dependencies

~1–1.7MB
~34K SLoC