Skip to main content

Roll dice on the command line because why not?

Project description

Rolly Mascot

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, N is the number of sides
  • Roll multiple dice: xM, M is 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.

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

rolly-1.0.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rolly-1.0.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file rolly-1.0.0.tar.gz.

File metadata

  • Download URL: rolly-1.0.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for rolly-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e787aac1f92b3e7bc6279f5ca2e7a3bd02ec0ac067e556dfc9f51efaedf59e42
MD5 72571fa09e863adba05e5e8b19de3a1d
BLAKE2b-256 54c08d4f5515703ced29500d0199d02e398dc32127855b43b0782b6ebb38d137

See more details on using hashes here.

File details

Details for the file rolly-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: rolly-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for rolly-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff359be3f64a54bf30ce864b2e3b4b4d6b38d0586b70bf76bdf3a59c3f976d29
MD5 1cefde4637646201e019a87f80fef703
BLAKE2b-256 ea27ace46bed29cb1525b9420b767b114a6347288c105189621c3dfe3c890b54

See more details on using hashes here.

Supported by

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