Package dev.davwheat
Class Dice
- java.lang.Object
-
- dev.davwheat.Dice
-
public class Dice extends java.lang.Object
Handles the rolling of dice to decide player movement.
-
-
Constructor Summary
Constructors Constructor Description Dice()
-
Method Summary
Modifier and Type Method Description int
getOneRoll(int diceNumber)
Gets the value of one specific dice roll.int
getTotalRoll()
Get the total value of both dice rolls.boolean
isDouble()
Is the roll a double?Dice
rollAllDice()
Rolls two dice and updates the instance of this class accordingly.static int
rollDice()
Gets a random number between 1 and 6.
-
-
-
Method Detail
-
rollDice
public static int rollDice()
Gets a random number between 1 and 6.- Returns:
- int (1-6)
-
rollAllDice
public Dice rollAllDice()
Rolls two dice and updates the instance of this class accordingly.To get the total roll, call: rollAllDice().getTotalRoll()
- Returns:
- the current dice object
-
isDouble
public boolean isDouble()
Is the roll a double?- Returns:
- true for double
-
getTotalRoll
public int getTotalRoll()
Get the total value of both dice rolls.- Returns:
- total roll value
-
getOneRoll
public int getOneRoll(int diceNumber)
Gets the value of one specific dice roll.- Parameters:
diceNumber
- Number dice to fetch value from (1 or 2)- Returns:
- The roll value
-
-