A formal grammar-based dice parser and roller for D&D and other dice systems.
Project description
d20
A fast, powerful, and extensible dice engine for D&D, d20 systems, and other applications.
Key Features
- Quick to start - just use
d20.roll()
! - Optimized for speed and memory efficiency
- Highly extensible API for custom behaviour and dice stringification
- Built-in execution limits against malicious dice expressions
- Tree-based dice representation for easy traversal
Installing
Requires Python 3.6+.
d20 is built on top of the amazing Lark parser, and has it as its only dependency!
python3 -m pip install -U d20
Quickstart
>>> import d20
>>> result = d20.roll("1d20+5")
>>> str(result)
'1d20 (10) + 5 = `15`'
>>> result.total
15
>>> result.crit
<CritType.NORMAL: 0>
>>> str(result.ast)
'1d20 + 5'
Documentation
TODO
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
d20-0.1.0.tar.gz
(9.0 kB
view details)
Built Distribution
d20-0.1.0-py3-none-any.whl
(18.5 kB
view details)
File details
Details for the file d20-0.1.0.tar.gz
.
File metadata
- Download URL: d20-0.1.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd9fc8ce91650e9a100535cffb9c8ab29f81350735bda45744acb28a8aca4038 |
|
MD5 | bf13b9956947d0a6fdc9fcd0fb2b3785 |
|
BLAKE2b-256 | 92201a0b32587727a5108723f200275c8052986e49432f8ac1c4de7358d1db3e |
File details
Details for the file d20-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: d20-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e576c7f60f65fa05ada35d3ac3ec3132e90680215007d7648cfe28b02369078b |
|
MD5 | 8f94ff39544b66d013124e0d0c8a6b97 |
|
BLAKE2b-256 | 2e6edc0f16f2bcabb8faf0bde4f7158a3e242c1c913c409ac85af299ee789e93 |