Metadata-Version: 2.1
Name: DiceLib
Version: 0.2.0
Summary: A dice-rolling library for RPGs.
Home-page: https://github.com/rolecraft/DiceLib
Author: CMSteffen
Author-email: cmsteffen@protonmail.com
License: MIT
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Description-Content-Type: text/markdown

# DiceLib
A dice-rolling library for RPGs.

## Requirements
* Python 3.5 or newer.

## Installation
`pip install DiceLib`

## Usage
```python
>>> from DiceLib import Die
>>> # You can create custom dice by specifying the number of faces:
... d6 = Die(6)
>>> # Rolling dice is simple:
... d6.roll()
[6]
>>> d6.roll(2)
[3, 5]
>>> d6.roll(7)
[2, 2, 6, 4, 4, 3, 1]
>>> # The value returned might look like a list, and in many way acts like one,
... # but it's actually a special class called Rolls:
... roll = _
>>> type(roll)
<class 'DiceLib.rolls.Rolls'>
>>> # Rolls act like lists in many ways:
... roll
[2, 2, 6, 4, 4, 3, 1]
>>> roll[1:3]
[2, 6]
>>> roll[1:3] = [5, 5]
>>> roll
[2, 5, 5, 4, 4, 3, 1]
>>> roll[0] = 6
>>> roll
[6, 5, 5, 4, 4, 3, 1]
>>> # But in other ways, Rolls are different:
... roll.total
28
>>> roll.count
7
>>> roll.highest
6
>>> roll.lowest
1
>>> roll[2:5].highest
5
>>> roll[2:5].total
13
>>> roll < 20
False
>>> roll > 20
True
>>> roll == 28
True
>>> int(roll)
28
>>> # You can easily add or subtract from a roll:
... roll + 2
30
... roll - 8
20
>>> # You can even drop the lowest or highest rolls:
... roll.drop_lowest()
[6, 5, 5, 4, 4, 3]
>>> roll.drop_lowest(3)
[6, 5, 5, 4]
>>> roll.drop_highest()
[5, 5, 4, 4, 3, 1]
>>> roll.drop_highest(3)
[4, 4, 3, 1]
>>> # Which makes it easy, for example, to roll stats:
... stats = dict()
>>> for stat in ["str", "dex", "con", "int", "wis", "cha"]:
...     stat_roll = int(d6.roll(4).drop_lowest())
...     stats[stat] = stat_roll
...
>>> stats
{'str': 12, 'dex': 15, 'con': 14, 'int': 12, 'wis': 15, 'cha': 11}
```


