Carsten Ruhr

A super simple dice parser

I just published another open-source package. And again something that probably already exists somewhere out there. But I wanted to scratch my itch myself. So I created a tiny library that parses a string in the standard dice notation and returns a random result.

You can find the code and documentation here, if you are interested: https://github.com/cruhr/diceparser

Dice notation

A small explainer what "dice notation" means. If you want to describe how many and what kind of dice to roll, you can rely on a defacto standard notation which describes the number of dice, the number of faces they have and if there is a bonus applied.

Example:

2d10+1

This translates to "2 dice with 10 faces each, plus 1".  
So the number in front of the `d` describes the die count, the number immediately after the `d` the face count and any bonus will be added with a +X.