1
2 """
3 This module provides the Dice class (formula based random numbers)
4 """
5 import sys
6 from random import randint
7
8
10 """
11 This class supports formula based dice rolls.
12 The formulae can be described in a few (fairly standard) formats:
13 - DnD style ... D100, 3D6, 3D6+4
14 - ranges ... 4-12
15 - simple numbers ... 50
16
17 @ivar num_dice: (int) number of dice to be rolled, None if a range
18 @ivar dice_type: (int) number of faces on each die, None if a range
19 @ivar plus: (int) number to be added to the roll
20 @ivar min_value: (int) lowest legal value in range, None if a formula
21 @ivar max_value: (int) highest legal value range, None if a formula
22 """
23
25 """
26 instantiate a roller for a specified formula
27
28 @param formula: (string) description of roll
29 @raise ValueError: illegal formula expression
30 """
31
32
33
34
35
36
37
39 """
40 return string representation of these dice"
41 """
42
44 """
45 roll this set of dice and return result
46 @return: (int) resulting value
47 """
48