Reference Source
public class | source

Round

A round in the WOJ game. The standard game is played with two rounds.

Constructor Summary

Public Constructor
public

constructor(id: number, wheel: Wheel, players: Player[], maxTime: number)

Member Summary

Public Members
public
public get
public get

Current player's player object.

public
public get

Stats for the current round, including spins used, clues answered, and attributes for the player who has the current turn, e.g.

Private Members
private get

Current player's score object.

private
private

Method Summary

Public Methods
public

End the current players turn, should be called after a spin and validation (if applicable) is complete.

public

When Spin resulted in a clue or pickCategory was used to set a clue, call this method if the player answered incorrectly, to adjust their score.

public

When spin is Player's Choice or Opponent's Choice, use pickCategory, to get the next clue from the specificed category.

public

reset()

Resets the current round by reseting the wheel, board, and player scores.

public

spin(): Spin

Spins the wheel and returns the result in a Spin object.

public

start()

Start the WOJ round.

public

Use a free turn token for the current player.

public

When Spin resulted in a clue or pickCategory was used to set a clue, call this method if the player answered correctly, to adjust their score.

Private Methods
private

Private method to reset the turn: currentSpin and currentClue are set to undefined.

Public Constructors

public constructor(id: number, wheel: Wheel, players: Player[], maxTime: number) source

Params:

NameTypeAttributeDescription
id number

A unique numeric ID for the round.

wheel Wheel

a wheel for the round.

players Player[]

an array of players in the game.

maxTime number
  • optional
  • default: 20

maximum time to answer a question in seconds.

Public Members

public board: Board source

public get complete: boolean source

public get currentPlayer: Player: * source

Current player's player object.

Return:

Player

current player's player object.

public currentPlayerID: number source

public get stats: RoundStats: * source

Stats for the current round, including spins used, clues answered, and attributes for the player who has the current turn, e.g. score, tokens.

Return:

RoundStats

current stats for the round.

Private Members

private get currentPlayerScore_: Score: * source

Current player's score object.

Return:

Score

current players score object.

private roundReady_: boolean source

private turnComplete_: boolean source

Public Methods

public endTurn() source

End the current players turn, should be called after a spin and validation (if applicable) is complete. This method will switch to the next player and reset the currentSpin and currentClue.

public invalidAnswer() source

When Spin resulted in a clue or pickCategory was used to set a clue, call this method if the player answered incorrectly, to adjust their score.

Throw:

Error

throws error if no clue is set to validate.

public pickCategory(column: number): Clue source

When spin is Player's Choice or Opponent's Choice, use pickCategory, to get the next clue from the specificed category. This will set the currentClue.

Params:

NameTypeAttributeDescription
column number

column index of the category.

Return:

Clue

next unanswered clue in the category.

Throw:

Error

throws error if current spin sector does not permit picking a category, i.e. it is not Player's Choice or Opponents Choice.

public reset() source

Resets the current round by reseting the wheel, board, and player scores.

public spin(): Spin source

Spins the wheel and returns the result in a Spin object. If Free Turn, Bankrupt, or Double Score are landed, the players tokens or score is adjusted. If Player's Choice or Opponent's Choice are landed, use pickCategory to get the next clue.

Return:

Spin

result of the spin.

public start() source

Start the WOJ round.

public useToken(): boolean source

Use a free turn token for the current player. A token may be used if the player loses his turn or answers a question incorrectly. A token cannot be used if the player spins free turn.

Return:

boolean

true if succesfully used token, false otherwise.

Throw:

Error

throws error if player does not have any tokens.

Error

throws error if the current spin is Free Turn.

public validAnswer() source

When Spin resulted in a clue or pickCategory was used to set a clue, call this method if the player answered correctly, to adjust their score.

Throw:

Error

throws error if no clue is set to validate.

Private Methods

private resetTurn_() source

Private method to reset the turn: currentSpin and currentClue are set to undefined.