Enum Class DiceType

java.lang.Object
java.lang.Enum<DiceType>
net.royalur.model.dice.DiceType
All Implemented Interfaces:
Serializable, Comparable<DiceType>, Constable, DiceFactory

public enum DiceType extends Enum<DiceType> implements DiceFactory
The type of dice to be used in a game.
  • Enum Constant Details

    • FOUR_BINARY

      public static final DiceType FOUR_BINARY
      Represents rolling four binary die and counting the number of ones that were rolled.
    • THREE_BINARY_0EQ4

      public static final DiceType 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

      public static final Map<String,DiceFactory> PARSING_MAP
      A store to be used to parse dice.
  • Method Details

    • values

      public static DiceType[] 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

      public static DiceType valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • getID

      public String getID()
      Gets the ID that refers to this dice type.
      Specified by:
      getID in interface DiceFactory
      Returns:
      The ID that refers to this dice type.
    • getName

      public String getName()
      Gets the name of this dice type.
      Specified by:
      getName in interface DiceFactory
      Returns:
      The name of this dice type.
    • getDieCount

      public int getDieCount()
      Gets the number of dice.
      Returns:
      The number of dice.
    • createDice

      public Dice createDice()
      Description copied from interface: DiceFactory
      Create an instance of the dice using a default source of randomness.
      Specified by:
      createDice in interface DiceFactory
      Returns:
      The instance of the dice using a default source of randomness.
    • createDice

      public abstract Dice createDice(RandomGenerator random)
      Creates a set of these dice using random as its source of randomness.
      Parameters:
      random - The source of randomness to use for the dice.
      Returns:
      A new set of these dice.
    • createFactory

      public DiceFactory createFactory(Supplier<RandomGenerator> randomProvider)
      Creates a factory that produces dice using randomProvider 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

      public static DiceType getByID(String id)
      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

      @Nullable public static DiceType getByIDOrNull(@Nullable String id)
      Get the dice type with an ID of , or else null.
      Parameters:
      id - The ID of the dice type to look for.
      Returns:
      The dice type with the given ID, or null.