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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

Supported by

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