|
|
8 years ago | |
|---|---|---|
| dist | 8 years ago | |
| docs | 8 years ago | |
| xdice.egg-info | 8 years ago | |
| .gitignore | 8 years ago | |
| .travis.yml | 8 years ago | |
| LICENSE.txt | 8 years ago | |
| MANIFEST.in | 8 years ago | |
| README.md | 8 years ago | |
| nose2.cfg | 8 years ago | |
| roll.py | 8 years ago | |
| setup.py | 8 years ago | |
| test.py | 8 years ago | |
| xdice.py | 8 years ago |
xdice
xdice is a lightweight python library for managing dice, scores, and dice-notation patterns.
It allows to easily interpret literal expressions as rolls of dice ('1d6', '3d4+3', '12d6+1d4'...etc.), then manipulate the results.
DiceRollParser has been tested with python 3.3+
See the full documentation
import dice
## Roll simple dices with **rolldice()**
score = rolldice(6, amount=2)
# manipulates score as an integer
print( score, score * 2, score == 11 )
>> 11 22 True
# Iterates over the results
for result in score:
print(result)
>> 5
>> 6
# Parse patterns with **roll()**
ps = roll("2d6+18")
print( ps, ps.format() )
>> 28 '[5,6]+18'
Run python roll.py [options] <expr>
Usage:
roll [options] <expr>
Options:
-s Numeric score only
-h --help Displays help message
--version Displays current xdice version
Any opinion / contribution is welcome, please contact us.
pip install xdice
xdice is under GNU License
Olivier Massot, 2017, with Cro-ki Lab
dice roll d20 game random parser dices role board