Members
hasStarted :boolean
Flag that shows if game has started
Type:
- boolean
id :number
Unique ID of game
Type:
- number
isOver :boolean
Flag that shows if game is over/has finished
Type:
- boolean
moveSequence
Sequence number that is incremented each time a piece is moved during the game
previousState
Previous game state, used for undoing moves
previousTurnDice
Previous dice state, used for undoing moves
state :State
Board state
Type:
turnConfirmed :boolean
Flag that shows if the moves made in current turn have been confirmed by the player.
Type:
- boolean
turnDice :Dice
Dice for current turn. Should be null if dice haven't been rolled yet.
Type:
turnNumber :number
Number (index) of turn
Type:
- number
turnPlayer :Player
Show which player's turn it is
Type:
Methods
(static) createNew(rule) → {Game}
Create new game object with unique ID and initialize it.
Game object is not saved in database.
Parameters:
Name | Type | Description |
---|---|---|
rule |
Rule | Rule object to use |
Returns:
- A new game object with unique ID
- Type
- Game
(static) diceWasRolled(game) → {boolean}
Check if dice has been rolled
Parameters:
Name | Type | Description |
---|---|---|
game |
Game | Game |
Returns:
- True if dice has been rolled (turnDice is not null)
- Type
- boolean
(static) hasMoreMoves(game) → {boolean}
Check if there are more moves to make
Parameters:
Name | Type | Description |
---|---|---|
game |
Game | Game |
Returns:
- True if there are any moves left to make
- Type
- boolean
(static) hasMove(game, value) → {boolean}
Check if a specific move value is available in movesLeft
Parameters:
Name | Type | Description |
---|---|---|
game |
Game | Game |
value |
number | Move value to check for |
Returns:
- True if specified move value is available
- Type
- boolean
(static) init(game, rule)
Initialize game object
Parameters:
Name | Type | Description |
---|---|---|
game |
Game | Game to initialize |
rule |
Rule | Rule to use |
(static) isPlayerTurn(game, player) → {boolean}
Check if it is specified player's turn
Parameters:
Name | Type | Description |
---|---|---|
game |
Game | Game |
player |
Player | Specified player |
Returns:
- True if it is specified player's turn
- Type
- boolean
(static) isTypeTurn(game, type) → {boolean}
Check if it is specified player's turn, but check by their piece type, and not player object
Parameters:
Name | Type | Description |
---|---|---|
game |
Game | Game |
type |
PieceType | Player's piece type |
Returns:
- True if it is specified player's turn
- Type
- boolean
(static) restoreState(game)
Restore game state from last snapshot - if player requested to undoing of moves
Parameters:
Name | Type | Description |
---|---|---|
game |
Game | Game |
(static) snapshotState(game)
Store current game state - in case the player wants to undo moves later
Parameters:
Name | Type | Description |
---|---|---|
game |
Game | Game |