Allow dynamic creation of game states
This commit is contained in:
parent
87f078da13
commit
be4956f360
2 changed files with 11 additions and 5 deletions
|
@ -40,7 +40,7 @@ export class Game
|
|||
constructor(id)
|
||||
{
|
||||
this.id = id;
|
||||
this.#state = new State();
|
||||
this.#state = new State(Game.#width, Game.#height);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,7 +72,7 @@ export class Game
|
|||
*/
|
||||
reset()
|
||||
{
|
||||
this.#state = new State();
|
||||
this.#state = new State(Game.#width, Game.#height);
|
||||
this.draw();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,14 +17,20 @@ export class State
|
|||
|
||||
/**
|
||||
* Initializes a new instance of the {@link State `State`} class.
|
||||
*
|
||||
* @param {number} width
|
||||
* The width of the board.
|
||||
*
|
||||
* @param {number} height
|
||||
* The height of the board.
|
||||
*/
|
||||
constructor()
|
||||
constructor(width, height)
|
||||
{
|
||||
this.#board = /** @type {Board} */ (
|
||||
Array(6).fill("").map(
|
||||
Array(height).fill("").map(
|
||||
() =>
|
||||
{
|
||||
return Array(7).fill(
|
||||
return Array(width).fill(
|
||||
/** @type {CellOwner} */ (""));
|
||||
}));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue