Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

ogs::core::Die Class Reference

A die generates random numbers by simulating rolls of polyhedral die. More...

#include <Die.h>

Inheritance diagram for ogs::core::Die:

Inheritance graph
[legend]
Collaboration diagram for ogs::core::Die:

Collaboration graph
[legend]
List of all members.

Public Types

typedef unsigned short Sides
 The type of a die.

typedef unsigned short Count
 Number of times a die is rolled.

typedef short Modifier
 Arbitrary value added to sum of die rolls.

typedef short Value
 Sum of die rolls plus modifier.


Public Member Functions

 Die (Sides sides=d20, Count count=1, Modifier modifier=0)
 Create a new die.

Sides getSides () const
 Determine the number of sides on this die.

void setSides (Sides sides)
 Change the sides on this die.

Count getCount () const
 Determine the number of times this die is rolled.

void setCount (Count count)
 Change the number of times the die is rolled.

Modifier getModifier () const
 Determine the arbitrary value added to the sum of die rolls.

void setModifier (Modifier modifier)
 Change the modifier added to the sum of die rolls.

Value getValue () const
 Determine the value of the last die roll.

void setValue () const
 Change the value of the die.

Value rollValue () const
 Reroll this die.

Value getMaximumValue () const
 Retrieve the highest possible value of this die.

Value getMinimumValue () const
 Retrieve the lowest possible value of this die.


Static Public Member Functions

Value roll (Sides sides=d20, Count count=1, Modifier modifier=0)
 Roll a die one or more times and add a modifier.


Static Public Attributes

const Sides d4 = 4
 A four-sided die.

const Sides d6 = 6
 A six-sided die.

const Sides d8 = 8
 An eight-sided die.

const Sides d10 = 10
 A ten-sided die.

const Sides d12 = 12
 A twelve-sided die.

const Sides d20 = 20
 A twenty-sided die.

const Sides d2 = 2
 A two-sided die.

const Sides d3 = 3
 A three-sided die.

const Sides d5 = 5
 A five-sided die.

const Sides d100 = 100
 A hundred-sided die.


Detailed Description

Each Die object is homogenous: only one type of die is represented by a single object. Type refers to the number of sides on a die. A single die, however, can be rolled more than once. The sum of these rolls can be added to a die modifier to produce an overall range of random numbers.


Member Typedef Documentation

typedef unsigned short ogs::core::Die::Count
 

Die counts must always be one (1) or more.

typedef short ogs::core::Die::Modifier
 

Die modifiers can be zero (0), positive, or negative.

typedef unsigned short ogs::core::Die::Sides
 

The type of a die is denoted by the number of sides that it has. Some types of die are real: they are geometrical solids. Other types are virtual: they are simulated using real die. Die sides must always be two (2) or more.

typedef short ogs::core::Die::Value
 

A die value is usually called "a die roll" but "Value" is used to distinguish "a die roll" from "roll a die".


Constructor & Destructor Documentation

Die::Die Sides  sides = d20,
Count  count = 1,
Modifier  modifier = 0
 

Parameters:
sides Number of sides on die.
count Number of times to roll die.
modifier Arbitrary value added to sum of die rolls.


Member Function Documentation

Die::Count ogs::core::Die::getCount  )  const [inline]
 

Returns:
Number of times this die is rolled.

Die::Value ogs::core::Die::getMaximumValue  )  const [inline]
 

Returns:
Highest possible value of this die.

Die::Value ogs::core::Die::getMinimumValue  )  const [inline]
 

Returns:
Lowest possible value of this die.

Die::Modifier ogs::core::Die::getModifier  )  const [inline]
 

Returns:
Arbitrary value added to the sum of die rolls.

Die::Sides ogs::core::Die::getSides  )  const [inline]
 

Returns:
Number of sides on this die.

Die::Value ogs::core::Die::getValue  )  const [inline]
 

Returns:
Value of the last die roll.

Die::Value Die::roll Sides  sides = d20,
Count  count = 1,
Modifier  modifier = 0
[static]
 

Parameters:
sides Number of sides on die. Must be greater than 0.
count Number of times to roll die. Must be greater than 0.
modifier Arbitrary value added to sum of die rolls.
Returns:
Sum of die rolls and modifier.
Exceptions:
invalid_argument If sides or count is zero (0).

Die::Value ogs::core::Die::rollValue  )  const [inline]
 

This method combines the setValue and getValue methods.

Returns:
New value of the die.

void Die::setCount Count  count  ) 
 

Parameters:
count Number of times die is rolled.

void Die::setModifier Modifier  modifier  ) 
 

Parameters:
modifier Arbitrary value added to sum of rolls.

void Die::setSides Sides  sides  ) 
 

Parameters:
sides Number of sides on die.

void Die::setValue  )  const
 

This method rerolls the die.


Member Data Documentation

const Sides ogs::core::Die::d100 = 100 [static]
 

A hundred-sided die is simulated by rolling two d10. One die is tens and the other is ones.

const Sides ogs::core::Die::d2 = 2 [static]
 

A two-sided die is simulated by rolling a d4, d6, d8, d10, d12, or d20. An even number is a 1 and an odd number is a 2.

const Sides ogs::core::Die::d3 = 3 [static]
 

A three-sided die is simulated by rolling a d6, 1 or 2 counts as 1, 3 or 4 is a 2, 5 or 6 is a 3.

const Sides ogs::core::Die::d5 = 5 [static]
 

A five-sided die is simulated by rolling a d10, Results are treated similarly to d3.


The documentation for this class was generated from the following files:
Generated on Sun Apr 20 03:38:06 2003 for Open Gaming System (OGS) by doxygen1.3