Skip to content

Commit 3a3843c

Browse files
committed
Documentation and initial release
1 parent fe87b1c commit 3a3843c

File tree

3 files changed

+38
-21
lines changed

3 files changed

+38
-21
lines changed

README.rst

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,47 @@
22
dice
33
====
44

5-
A library for parsing and evaluating dice notation.
5+
A library and command line tool for parsing and evaluating dice notation.
66

7-
Todo
8-
====
7+
Usage
8+
=====
99

10-
* Unary and binary operators
11-
* Console and module API functions
10+
From the command line::
1211

13-
Notes
14-
=====
12+
roll 3d6
13+
14+
From python::
15+
16+
import dice
17+
dice.roll('3d6')
18+
19+
Notation
20+
========
21+
22+
The expression works like a simple equation parser with some extra operators.
23+
24+
*The following operators are listed in order of precedence.*
25+
26+
The dice ('d') operator takes an amount (A) and a number of sides (S), and
27+
returns a list of A random numbers between 1 and S. For example: ``4d6`` may
28+
return ``[6, 3, 2, 4]``.
29+
30+
If A is not specified, it is assumed you want to roll a single die.
31+
``d6`` is equivalent to ``1d6``.
32+
33+
Basic integer operations are available: ``16 / 8 * 4 + 2 - 1 -> 9``.
1534

16-
Some rough notes on how I want the API to look:
35+
A set of rolls can be turned into an integer with the total (``t``) operator.
36+
``6d1t`` will return ``6`` instead of ``[1, 1, 1, 1, 1, 1]``. Applying
37+
integer operations to a list of rolls will total them automatically.
1738

18-
::
39+
A set of dice rolls can be sorted with the sort (``s``) operator. ``4d6s``
40+
will not change the return value, but the dice will be sorted from lowest to
41+
highest.
1942

20-
>>> d = Dice('2d6')
21-
Dice("Two six-sided dice")
22-
>>> d.roll()
23-
Roll(5, 5, sides=6)
24-
>>> b = Bag('two six-sided dice', 'six-sided die', '4d2', (3,3), Dice('d1'))
25-
>>> repr(b)
26-
Bag((3,6), (4,2), (3,3))
27-
>>> str(b)
28-
"3d6, 4d2, 1d1"
43+
The lowest or highest rolls can be selected with ``^`` and ``v``. ``6d6^3``
44+
will keep the highest 3 rolls, whereas ``6d6v3`` will select the lowest 3
45+
rolls.
2946

3047
Licence
3148
=======

dice/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
__all__ = ['roll', 'ParseException']
1212
__author__ = "Sam Clements <[email protected]>"
13-
__version__ = '0.4.2'
13+
__version__ = '1.0.0'
1414

1515

1616
def roll(string, single=True, verbose=False):

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name = 'dice',
8-
version = '0.4.0',
8+
version = '1.0.0',
99

1010
author = "Sam Clements",
1111
author_email = "[email protected]",
@@ -28,7 +28,7 @@
2828
},
2929

3030
classifiers = [
31-
'Development Status :: 3 - Alpha',
31+
'Development Status :: 4 - Beta',
3232
'Environment :: Console',
3333
'Operating System :: OS Independent',
3434
'Programming Language :: Python',

0 commit comments

Comments
 (0)