Package net.royalur.model.dice
Class BinaryDice
java.lang.Object
net.royalur.model.dice.Dice
net.royalur.model.dice.BinaryDice
- Direct Known Subclasses:
BinaryDice0AsMax
Rolls a number of binary die and counts the result.
-
Constructor Summary
ConstructorDescriptionBinaryDice
(String id, RandomGenerator random, int numDie) Instantiates this binary dice withrandom
as the source of randomness to generate rolls. -
Method Summary
Modifier and TypeMethodDescriptiongenerateRoll
(int value) Generates a roll with valuevalue
using this dice.int
Gets the maximum value that could be rolled by this dice.float[]
Gets the probability of rolling each value of the dice, where the index into the returned array represents the value of the roll.int
Generates a random roll using this dice, and returns just the value.Methods inherited from class net.royalur.model.dice.Dice
copyFrom, getDiceType, getID, getName, hasDiceType, hasState, recordRoll, roll, roll
-
Constructor Details
-
BinaryDice
Instantiates this binary dice withrandom
as the source of randomness to generate rolls.- Parameters:
id
- The ID of this dice.random
- The source of randomness used to generate dice rolls.numDie
- The number of binary dice to roll.
-
-
Method Details
-
getMaxRollValue
public int getMaxRollValue()Description copied from class:Dice
Gets the maximum value that could be rolled by this dice.- Specified by:
getMaxRollValue
in classDice
- Returns:
- The maximum value that this dice could possibly roll.
-
getRollProbabilities
public float[] getRollProbabilities()Description copied from class:Dice
Gets the probability of rolling each value of the dice, where the index into the returned array represents the value of the roll.- Specified by:
getRollProbabilities
in classDice
- Returns:
- The probability of rolling each value of the dice.
-
rollValue
public int rollValue()Description copied from class:Dice
Generates a random roll using this dice, and returns just the value. If this dice has state, this should callDice.recordRoll(int)
. -
generateRoll
Description copied from class:Dice
Generates a roll with valuevalue
using this dice. This does not update the state of the dice.- Specified by:
generateRoll
in classDice
- Parameters:
value
- The value of the dice to be rolled.- Returns:
- A roll with value
value
of this dice.
-