Board
A WOJ board with column * row clues arranged in a grid. The top left corner is indexed at 0. Each column is a Category and each row in a category is a Clue. All categories must have the same number of clues. Each clue in the first row has Board#basePoints. Each clue in the next row equals the sum of the clue value in the prior row plus basePoints.
Constructor Summary
Public Constructor | ||
public |
constructor(columns: number, rows: number, basePoints: number) |
Member Summary
Public Members | ||
public get |
|
|
public get |
|
|
public get |
|
Method Summary
Public Methods | ||
public |
editCategory(column: number, name: string) Edit the name of a category at column index. |
|
public |
Edit the question and answer of a clue at column and row index. |
|
public |
Export board content to JSON board string. |
|
public |
getCategory(column: number): Category Returns a category at the specified column. |
|
public |
Returns a clue at the specified column and row. |
|
public |
Import JSON board, initializing board and setting categories and clues. |
|
public |
Retrieve next unanswered clue in the category at column and increment cluesAnswered for that category. |
|
public |
reset() Resets each category in the board and their cluesAnswered count to 0. |
Private Methods | ||
private |
Initializes an empty board of size columns * rows with Clue's. |
Public Members
Public Methods
public editCategory(column: number, name: string) source
Edit the name of a category at column index.
public editClue(column: number, row: number, question: string, answer: string) source
Edit the question and answer of a clue at column and row index.
public export(): string source
Export board content to JSON board string. See Board.import for details on JSON board structure.
public getCategory(column: number): Category source
Returns a category at the specified column.
Params:
Name | Type | Attribute | Description |
column | number | column index of the category. |
public getClue(column: number, row: number): Clue source
Returns a clue at the specified column and row.
public import(data: string) source
Import JSON board, initializing board and setting categories and clues. Data should be a string. Use JSON.stringify if data is an object literal.
Params:
Name | Type | Attribute | Description |
data | string | board JSON. |
|
data.columns | number | number of columns. |
|
data.rows | numnber | number of rows. |
|
data.categories | string[] | array of category names. |
|
data.clues | Object[] | array of clues, zero indexed from top left of board |
|
data.clues.column | number | column index of the clue. |
|
data.clues.row | number | row index of the clue. |
|
data.clues.question | string | new question text. |
|
data.clues.answer | string | new answer text. |
See:
public nextClue(column: number): Clue source
Retrieve next unanswered clue in the category at column and increment cluesAnswered for that category. If all clues are answered, this will return undefined.
Params:
Name | Type | Attribute | Description |
column | number | column index of the category. |
Throw:
throw error when board is complete. |