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

Uploaded Source

Built Distribution

dicetray-2.1.1-py3-none-any.whl (5.0 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