A library to emulate rolling dice
Project description
Roll dice in your python programs
Why?
I wanted a better API to rolling dice using Python, and the usual random.randint is very good,
but doesn't really represent rolling dice quite the way I imagine it.
This was a good learning experiment, but I'm not expecting anyone to use it.
Who is this for?
People building RPGs, or games that would involve dice and who care about how their code looks like.
I may be biased, but I really believe that this library provides a much better interface than
pure random.randint.
How to install
$ pip install dragn
How to use
>> from dragn.dice import D4, D6, D8
>>> D6()
1
>>> f"You roll the die and the result is {D8()}"
'You roll the die and the result is 4'
>>> f"You roll 3 dice and you get {[D8() for _ in range(3)]}"
>>> 'You roll 3 dice and you get [3, 1, 8]'
>>> four_dice = D4 * 4
>>> f"You roll 4 dice and the results are {four_dice()}"
'You roll 4 dice and the results are (4, 3, 1, 2)'
>>> f"You roll two dice and the results are {two_dice()}"
'You roll two dice and the results are (3, 4)'
>>> dice_tower = (D6 * 2) + D4
>>> f"You roll two D6 and a D4 and check the results {dice_tower()}"
'You roll two D6 and a D4 and check the results (2, 2, 6)'
For more examples, check the tests
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 dragn-0.4.0.tar.gz.
File metadata
- Download URL: dragn-0.4.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d970ceb7e5363934a1cb7c963e518858527e38d2e1267f11269a5ff305a72d6b
|
|
| MD5 |
05517906e81be08116393145294cfe6f
|
|
| BLAKE2b-256 |
3e0d31ea6812695c6c81e7813da5c012f7a86b560aed990b16ba92169d1649db
|
File details
Details for the file dragn-0.4.0-py3-none-any.whl.
File metadata
- Download URL: dragn-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcd2e0178179ded491fd2259b6e6692ca4b70ee492091cd674668806d4f65fce
|
|
| MD5 |
22f58c8286d93bbd78264d5992007ecf
|
|
| BLAKE2b-256 |
344517d0a3d2ff336de6ccc4b0a3f687bd0af7f9ca79942a163358d5bc808585
|