Package net.royalur.model.dice
Enum Class DiceType
- All Implemented Interfaces:
Serializable
,Comparable<DiceType>
,Constable
,DiceFactory
The type of dice to be used in a game.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionRepresents rolling four binary die and counting the number of ones that were rolled.Represents rolling three binary die and counting the number of ones that were rolled. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Map<String,
DiceFactory> A store to be used to parse dice. -
Method Summary
Modifier and TypeMethodDescriptionCreate an instance of the dice using a default source of randomness.abstract Dice
createDice
(RandomGenerator random) Creates a set of these dice usingrandom
as its source of randomness.createFactory
(Supplier<RandomGenerator> randomProvider) Creates a factory that produces dice usingrandomProvider
to generate the source of randomness for each dice that is produced.static DiceType
Get the dice type with an ID of .static DiceType
getByIDOrNull
(String id) Get the dice type with an ID of , or elsenull
.int
Gets the number of dice.getID()
Gets the ID that refers to this dice type.getName()
Gets the name of this dice type.static DiceType
Returns the enum constant of this class with the specified name.static DiceType[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
Methods inherited from interface net.royalur.model.dice.DiceFactory
createRoll, getDiceType, hasDiceType
-
Enum Constant Details
-
FOUR_BINARY
Represents rolling four binary die and counting the number of ones that were rolled. -
THREE_BINARY_0EQ4
Represents rolling three binary die and counting the number of ones that were rolled. If no ones are rolled, then a value of four is given.
-
-
Field Details
-
PARSING_MAP
A store to be used to parse dice.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
getID
Gets the ID that refers to this dice type.- Specified by:
getID
in interfaceDiceFactory
- Returns:
- The ID that refers to this dice type.
-
getName
Gets the name of this dice type.- Specified by:
getName
in interfaceDiceFactory
- Returns:
- The name of this dice type.
-
getDieCount
public int getDieCount()Gets the number of dice.- Returns:
- The number of dice.
-
createDice
Description copied from interface:DiceFactory
Create an instance of the dice using a default source of randomness.- Specified by:
createDice
in interfaceDiceFactory
- Returns:
- The instance of the dice using a default source of randomness.
-
createDice
Creates a set of these dice usingrandom
as its source of randomness.- Parameters:
random
- The source of randomness to use for the dice.- Returns:
- A new set of these dice.
-
createFactory
Creates a factory that produces dice usingrandomProvider
to generate the source of randomness for each dice that is produced.- Parameters:
randomProvider
- The provider of the source of randomness for each dice.- Returns:
- A factory for these dice.
-
getByID
Get the dice type with an ID of .- Parameters:
id
- The ID of the dice type.- Returns:
- The dice type with the given ID.
-
getByIDOrNull
Get the dice type with an ID of , or elsenull
.- Parameters:
id
- The ID of the dice type to look for.- Returns:
- The dice type with the given ID, or null.
-