Module to roll multiple dice.
Project description
Dice rolling
This module aims to implement the throw of many types of dice.
Installation
Simply run:
pip install dice-rolling
CLI usage
Once installed, a throw of a simple die of 6 sides can be performed with:
$ roll 1d6
Rolled 1d6 and got 4. [4]
Or, for instance, to throw three 20-sided dice can be as simple as:
$ roll 3d20
Rolled 3d20 and got 36. [14, 9, 13]
Module usage
To use this module you should use the class RollBuilder to implement the throws:
from dice_rolling import RollBuilder
builder = RollBuilder()
builder.set_amount_of_dice(3)
builder.set_number_of_sides(20)
builder.build()
print(builder.get_result())
Throws
The request must start with x
dy
, where x
is the number of dice and y
the number of faces of each die.
For example, to roll 4 6-sided dice:
$ roll 4d6
Rolled 4d6 and got 16. [5, 2, 3, 6]
After that, the following modifiers have been implemented (using the previous result as reference):
-
+a
: Add the value ofa
to each die. For example, to roll 4 6-sided dice and add 3 to each roll:$ roll 4d6+3 Rolled 4d6+3 and got 28. [8, 5, 6, 9]
-
khb
:K
eep theH
ighestb
. For example, to roll 4 6-sided dice and keep the highest 2:$ roll 4d6kh2 Rolled 4d6kh2 and got 11. Kept [5, 6] and discarded [3, 2].
-
klc
:K
eep theL
owestc
. For example, to roll 4 6-sided dice and keep the lowest 2:$ roll 4d6kl2 Rolled 4d6kl2 and got 5. Kept [2, 3] and discarded [5, 6].
Of course you can use together an addition with any of the keep actions:
$ roll 4d6+5kh2
Rolled 4d6+5kh2 and got 21. Kept [11, 10] and discarded [8, 7].
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
File details
Details for the file dice_rolling-1.1.0.tar.gz
.
File metadata
- Download URL: dice_rolling-1.1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d72282fc42577c5a63c0ec51be7a2a7096320f59298c6c2a07ca7c6ca01922e |
|
MD5 | 42bc1a80a9053d020dceb6bdb24c720b |
|
BLAKE2b-256 | 7bf56e9b9f2140c362723ebc28673c45b24e477ca4c4367502c7df6b52a9a023 |