Skip to main content

Tabletop RPG Dice roller

Project description

https://github.com/gtmanfred/dicetray/workflows/Tests/badge.svg https://img.shields.io/codecov/c/github/gtmanfred/dicetray https://img.shields.io/pypi/v/dicetray https://img.shields.io/pypi/l/dicetray https://img.shields.io/pypi/dm/dicetray

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 expr
expr MINUS expr
expr TIMES expr
expr DIVIDE expr
exprNUMBER
dice
func
funcdice
dice KEEPHIGH
dice KEEPLOW
dice DROPHIGH
dice DROPLOW
dice KEEPHIGH NUMBER
dice KEEPLOW NUMBER
dice DROPHIGH NUMBER
dice DROPLOW NUMBER
diceNUMBER DIE NUMBER
NUMBER DIE TYPE

PLUS : + 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

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

dicetray-2.1.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

dicetray-2.1.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

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

Hashes for dicetray-2.1.1.tar.gz
Algorithm Hash digest
SHA256 db5cd40ef9e1d046101f651e00309fec44ad8e380060d2673437f7f5ee81ac4d
MD5 8567aca57db156922f17c0ebc58fe075
BLAKE2b-256 afbc070b7ccc3d3283ca0a467c98e5c116d9046796a19eac411f455fbaffe6f3

See more details on using hashes here.

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

Hashes for dicetray-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 152d53b43b66979e7f9add3a331b9a2d8e241135832f70df2cf307134fe98b05
MD5 a6572407aad0a8b71832af91ab159101
BLAKE2b-256 8d46bbc6a7fec7860f4161a381031570f0ea565841b1d97f6fcd229a92650f6e

See more details on using hashes here.

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