Class: Dice

Dice

new Dice()

Dice with basic functionality to roll using good random generator.
Source:

Members

moves :Array

List of moves the player can make. Usually moves are equal to values, but in most rules doubles (eg. 6:6) are played four times, instead of two, in which case moves array will contain four values in stead of only two (eg. [6, 6, 6, 6]).
Type:
  • Array
Source:

movesLeft :Array

After dice is rolled, movesLeft contains the same values as moves. When the player makes a move, the corresponding value is removed from movesLeft array. If the player wants to undo the moves made, movesLeft is replaced with moves.
Type:
  • Array
Source:

movesPlayed :Array

After a piece is moved, the value of the die used is added to movesPlayed array.
Type:
  • Array
Source:

values :Array

Values of the two dice
Type:
  • Array
Source:

Methods

(static) getRemainingMoves(dice) → {Array}

Get remaining moves from dice object - moves that have not been played.
Parameters:
Name Type Description
dice Dice Dice object
Source:
Returns:
- Array containing remaining move values
Type
Array

(static) isDouble(dice) → {boolean}

Check if the dice object has double (equal) values.
Parameters:
Name Type Description
dice Dice New dice with random values
Source:
Returns:
- True if dice object has dobule values, false otherwise
Type
boolean

(static) markAsPlayed(dice, move)

Roll dice and return result as a new Dice object
Parameters:
Name Type Description
dice Dice New dice with random values
move number New dice with random values
Source:

(static) roll() → {Dice}

Roll dice and return result as a new Dice object
Source:
Returns:
- New dice with random values
Type
Dice