Module dice :: Class Dice
[hide private]
[frames] | no frames]

Class Dice

source code


This class supports formula based dice rolls. The formulae can be described in a few (fairly standard) formats:

Instance Methods [hide private]
 
__init__(self, formula)
instantiate a roller for a specified formula
source code
 
str(self)
return string representation of these dice"
source code
 
roll(self)
roll this set of dice and return result
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
  dice_type
(int) number of faces on each die, None if a range
  max_value
(int) highest legal value range, None if a formula
  min_value
(int) lowest legal value in range, None if a formula
  num_dice
(int) number of dice to be rolled, None if a range
  plus
(int) number to be added to the roll
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, formula)
(Constructor)

source code 

instantiate a roller for a specified formula

Parameters:
  • formula - (string) description of roll
Raises:
  • ValueError - illegal formula expression
Overrides: object.__init__

roll(self)

source code 

roll this set of dice and return result

Returns:
(int) resulting value