OGS Java API Spec

ogs.core
Class Die

java.lang.Object
  |
  +--ogs.core.Die

public class Die
extends Object

A die generates random numbers by simulating rolls of polyhedral die. Each Die object is homogeneous: 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.


Field Summary
static int d10
          A ten-sided die.
static int d100
          A hundred-sided die.
static int d12
          A twelve-sided die.
static int d2
          A two-sided die.
static int d20
          A twenty-sided die.
static int d3
          A three-sided die.
static int d4
          A four-sided die.
static int d5
          A five-sided die.
static int d6
          A six-sided die.
static int d8
          An eight-sided die.
 
Constructor Summary
Die()
          Create a d20 die rolled once with no modifier.
Die(int sides)
          Create a specific die rolled once with no modifier.
Die(int sides, int count)
          Create a specific die rolled one or more times with no modifier.
Die(int sides, int count, int modifier)
          Create a specific die rolled one or more times with a modifier.
 
Method Summary
 int getCount()
          Determine the number of times the die is rolled.
 int getMaximumValue()
          Retrieve the highest possible value of the die.
 int getMinimumValue()
          Retrieve the lowest possible value of the die.
 int getModifier()
          Determine the modifier added to the sum of die rolls.
 int getSides()
          Determine the number of sides on this die.
 int getValue()
          Retrieve the value of the die.
static int roll()
          Roll a d20 one time.
static int roll(int sides)
          Roll a die one time.
static int roll(int sides, int count)
          Roll a die one or more times.
static int roll(int sides, int count, int modifier)
          Roll a die one or more times and add a modifier.
 int rollValue()
          Change and retrieve the value of the die.
 void setCount(int count)
          Change the number of times the die is rolled.
 void setModifier(int modifier)
          Change the modifier added to the sum of die rolls.
 void setSides(int sides)
          Change the sides on this die.
 void setValue()
          Change the value of the die.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

d4

public static final int d4
A four-sided die.

See Also:
Constant Field Values

d6

public static final int d6
A six-sided die.

See Also:
Constant Field Values

d8

public static final int d8
An eight-sided die.

See Also:
Constant Field Values

d10

public static final int d10
A ten-sided die.

See Also:
Constant Field Values

d12

public static final int d12
A twelve-sided die.

See Also:
Constant Field Values

d20

public static final int d20
A twenty-sided die.

See Also:
Constant Field Values

d2

public static final int d2
A two-sided die. 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.

See Also:
Constant Field Values

d3

public static final int d3
A three-sided die. 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.

See Also:
Constant Field Values

d5

public static final int d5
A five-sided die. A five-sided die is simulated by rolling a d10, Results are treated similarly to d3.

See Also:
Constant Field Values

d100

public static final int d100
A hundred-sided die. A hundred-sided die is simulated by rolling two d10. One die is tens and the other is ones.

See Also:
Constant Field Values
Constructor Detail

Die

public Die()
Create a d20 die rolled once with no modifier.


Die

public Die(int sides)
Create a specific die rolled once with no modifier.

Parameters:
sides - Number of sides on the die.

Die

public Die(int sides,
           int count)
Create a specific die rolled one or more times with no modifier.

Parameters:
sides - Number of sides on the die.
count - Number of times the die is rolled.

Die

public Die(int sides,
           int count,
           int modifier)
Create a specific die rolled one or more times with a modifier.

Parameters:
sides - Number of sides on the die.
count - Number of times the die is rolled.
modifier - Value added to the sum of die rolls.
Method Detail

roll

public static int roll()
Roll a d20 one time. Same as roll (d20, 1, 0).

Returns:
Result of die roll.

roll

public static int roll(int sides)
Roll a die one time. Same as roll (sides, 1, 0).

Parameters:
sides - Number of sides on die.
Returns:
Result of die roll.

roll

public static int roll(int sides,
                       int count)
Roll a die one or more times. Same as roll (sides, cound, 0).

Parameters:
sides - Number of sides on die.
count - Number of times to roll die.
Returns:
Sum of die rolls.

roll

public static int roll(int sides,
                       int count,
                       int modifier)
Roll a die one or more times and add a modifier.

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 - Value added to sum of die rolls.
Returns:
Sum of die rolls and modifier.

getSides

public int getSides()
Determine the number of sides on this die.


setSides

public void setSides(int sides)
Change the sides on this die.

Parameters:
sides - Number of sides on die.

getCount

public int getCount()
Determine the number of times the die is rolled.

Returns:
Number of sides on die.

setCount

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

Parameters:
count - Number of times die is rolled.

getModifier

public int getModifier()
Determine the modifier added to the sum of die rolls.

Returns:
Number of times die is rolled.

setModifier

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

Parameters:
modifier - Arbitrary value added to sum of rolls.

getValue

public int getValue()
Retrieve the value of the die. This method returns the value of the last die roll.

Returns:
Current value of the die.

setValue

public void setValue()
Change the value of the die. This method rerolls the die.


rollValue

public int rollValue()
Change and retrieve the value of the die. This method rerolls the die and returns the value of the new roll.

Returns:
New value of the die.

getMinimumValue

public int getMinimumValue()
Retrieve the lowest possible value of the die.

Returns:
Lowest possible value of the die.

getMaximumValue

public int getMaximumValue()
Retrieve the highest possible value of the die.

Returns:
Highest possible value of the die.

OGS Java API Spec