Skip to main content

A formal grammar-based dice parser and roller for D&D and other dice systems.

Project description

d20

PyPI version shields.io PyPI license PyPI pyversions

A fast, powerful, and extensible dice engine for D&D, d20 systems, and any other system that needs dice!

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


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.2.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

d20-0.2.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file d20-0.2.0.tar.gz.

File metadata

  • Download URL: d20-0.2.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for d20-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4a75e691c0a3175a29b0322d9b32bc60a03c1b01fe908672edf92677d77ebe82
MD5 406eff19a542a4a1616b98ff6b843d4c
BLAKE2b-256 c205e3320f8dd0c4df03ce71d4bac17387b9087640ec36ef4ce71990eb83d749

See more details on using hashes here.

File details

Details for the file d20-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: d20-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for d20-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f76c61ff1dd828eac9eb7817cc8c00c69dc8038ed66e13eaeddd8af7641f5ff
MD5 b355d3caaf7a7dac772f82fa781a73ba
BLAKE2b-256 4ace727ab34cc925547f49508bb44850347af293dc0da371a9149ec2368d0554

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page