Roll dice on the command line because why not?
Project description
Rolly
Rolling dice the boring way.
Introduction
A roll is expressed as a single string of text that contains a sequence of instructions. Whitespace between instructions is entirely ignored. There are different ways to express the same roll, some being shorter than others. Below, we roll 3 D20s with advantage in three different ways.
d20 d20 d20+
d20 x3+
d20 d20x2 +
Instructions
The available instructions are listed below.
- A die to be rolled:
dN,Nis the number of sides - Roll multiple dice:
xM,Mis the number of the previous die to roll - Advantage on the roll:
+anywhere in the string - Disadvantage on the roll:
-anywhere in the string
Examples
So a number prefixed with d implies x1 and a space between a number
and a count is ignored. Advantage is indicated by a + anywhere in the
string, disadvantage is a -.
d20x2 +
a d20 d20
d20x2-
CLI
The CLI is straightforward. Once the package is installed, it can be run as a module:
$ python -m rolly
This will show the help text. The primary command is roll, which takes
a string of instructions and displays the result.
$ python -m rolly roll d20x3
▄▄▄▄ ▄▄▄ ▄▄▄▄▄▄▄▄ ▄▄▄▄▄
██▀▀▀█ █▀██ ▀▀▀▀▀███ █▀▀▀▀██▄
██ ▄▄▄ ██ ▄██ ▄██
███▀▀██▄ ██ ██ █████
██ ██ ██ ██ ▀██
▀██▄▄██▀ ▄▄▄██▄▄▄ ██ █▄▄▄▄██▀
▀▀▀▀ ▀▀▀▀▀▀▀▀ ▀▀ ▀▀▀▀▀
The default uses ASCII art, but passing the --plain (-p) flag will
cause it to use plain text.
$ python -m rolly roll d20x3
6 17 3
It is also possible to sum the dice automatically using the --add (-a)
flag:
$ python -m rolly roll -ap d20x3
16 12 7
= 35
The ASCII art theme can be changed with the --theme (-t) option and
the available themes can be listed with the themes command.
Install
Probably easiest from PyPI: https://pypi.org/project/rolly/
I've become kind of a uv fanboy recently, and you can use that to run Rolly directly, which is slick.
uvx --from rolly rolly roll d20x3
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rolly-1.0.1.tar.gz.
File metadata
- Download URL: rolly-1.0.1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4eb2e194d6b13fd3bae842aa56f012d63ea800cd34c02c442a3e33d364f50cc3
|
|
| MD5 |
5c17c18a62175630549d620e2fe647b5
|
|
| BLAKE2b-256 |
ec7347f94bc0748391bfb627832af6342465ee38a0b24a476f9b48325088609a
|
File details
Details for the file rolly-1.0.1-py3-none-any.whl.
File metadata
- Download URL: rolly-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8152279feb71b39bc8c6075269938007bd083e86ca06692af0f5f577a829280
|
|
| MD5 |
6406b7f48624d01a4be4366f7abd7ac2
|
|
| BLAKE2b-256 |
f592c45784e06496912b473b0f1bec97a6008dacbe443af36a8e67c6679cc379
|