Game
The WOJ game. Supports creation of board, wheel, and players which are used to track game play. This class should be used to create games and add rounds to ensure proper functionality.
Example:
let game = new Game();
// create default boards
let data = [data1, data2];
for(let i=0; i<data.length; i++){
let round = game.addRound();
round.board.import(JSON.stringify(data[i]));
round.wheel.assignSectors();
round.wheel.randomizeSectors();
}
// edit board content if needed
round = game.getRound(0);
let clue = round.board.getCategory(1).clues[2];
clue.question = "What is the oldest soft drink in America?";
clue.answer = "Dr. Pepper.";
// start game
game.addPlayer("John");
game.addPlayer("Jane");
// start first round
round = game.getRound(0);
round.start();
// player spins
console.log(round.currentPlayer);
let spin = round.wheel.spin();
console.log(spin);
console.log(round.complete);
Member Summary
Public Members | ||
public |
|
|
public |
|
|
public |
rounds: Rounds[] |
|
public get |
Stats for the game. |
Method Summary
Public Methods | ||
public |
Add a player to the game. |
|
public |
Add and initialize a game round with an empty wheel and board. |
|
public |
editPlayer(id: number, name: string) Retrieve and edit a player. |
|
public |
getLeaderBoard(): Player[] Retrieve array of players ordered by top score. |
|
public |
Retrieve a player. |
|
public |
Retrieve a game round by id. |
Public Members
public rounds: Rounds[] source
Public Methods
public addPlayer(name: string): number source
Add a player to the game. Players are assigned an ID starting with 0 and incrementing by 1.
Params:
Name | Type | Attribute | Description |
name | string | the players name. |
public addRound(columns: number, rows: number, basePoints: number): id source
Add and initialize a game round with an empty wheel and board. Rounds are assigned an ID starting with 0 and incrementing by 1.
Return:
id | auto assigned round ID. |