#dice #parser #dnd #ttrpg

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

#4 in #dnd


Used in 2 crates (via dnd_dice_roller)

MIT license

34KB
785 lines

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.


lib.rs:

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.

Dependencies

~1–1.8MB
~36K SLoC