Tabletop RPG Dice rolling manager for handling Standard Dice Notation
Grammer
Below is the grammer that is used by the parser generator to intepret inputs.
- statementexpr
expr PLUS exprexpr MINUS exprexpr TIMES exprexpr DIVIDE expr- exprNUMBER
dicefunc- funcdice
dice KEEPHIGHdice KEEPLOWdice DROPHIGHdice DROPLOWdice KEEPHIGH NUMBERdice KEEPLOW NUMBERdice DROPHIGH NUMBERdice DROPLOW NUMBER- diceNUMBER DIE NUMBER
NUMBER DIE TYPEPLUS : + MINUS : - TIMES : * DIVIDE : /
NUMBER: [0-9]+ TYPE: [fF%] DIE : d KEEPHIGH: kh KEEPLOW: kl DROPHIGH: dh DROPLOW: dl
Example
>>> from dicetray import Dicetray
>>> Dicetray('1d20 + 3').roll()
15
>>> Dicetray('4d6dl').roll()
10
>>> Dicetray('4d6kh3').roll()
12
>>> d = Dicetray('2d20kh + 1d4 + 3')
>>> d.result
>>> d.dice
set()
>>> d.roll()
18
>>> d.dice
{<Dice (d20): 14>, <Dice (d20): 14>, <Dice (d4): 1>}
>>> d.result
18
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dicetray-2.1.1.tar.gz
(5.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dicetray-2.1.1.tar.gz.
File metadata
- Download URL: dicetray-2.1.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db5cd40ef9e1d046101f651e00309fec44ad8e380060d2673437f7f5ee81ac4d
|
|
| MD5 |
8567aca57db156922f17c0ebc58fe075
|
|
| BLAKE2b-256 |
afbc070b7ccc3d3283ca0a467c98e5c116d9046796a19eac411f455fbaffe6f3
|
File details
Details for the file dicetray-2.1.1-py3-none-any.whl.
File metadata
- Download URL: dicetray-2.1.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
152d53b43b66979e7f9add3a331b9a2d8e241135832f70df2cf307134fe98b05
|
|
| MD5 |
a6572407aad0a8b71832af91ab159101
|
|
| BLAKE2b-256 |
8d46bbc6a7fec7860f4161a381031570f0ea565841b1d97f6fcd229a92650f6e
|