Create a dedicated draw
method
This commit is contained in:
parent
6faeae8b66
commit
63bfb5375e
1 changed files with 9 additions and 1 deletions
|
@ -53,6 +53,14 @@ export class Game
|
||||||
* Initializes the game.
|
* Initializes the game.
|
||||||
*/
|
*/
|
||||||
initialize()
|
initialize()
|
||||||
|
{
|
||||||
|
this.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the content of the board with the current state.
|
||||||
|
*/
|
||||||
|
draw()
|
||||||
{
|
{
|
||||||
let board = document.getElementById(this.id);
|
let board = document.getElementById(this.id);
|
||||||
board.innerHTML = "";
|
board.innerHTML = "";
|
||||||
|
@ -86,7 +94,7 @@ export class Game
|
||||||
{
|
{
|
||||||
this.board[i][j] = this.state.currentPlayer;
|
this.board[i][j] = this.state.currentPlayer;
|
||||||
this.state.turnCount++;
|
this.state.turnCount++;
|
||||||
this.initialize();
|
this.draw();
|
||||||
};
|
};
|
||||||
|
|
||||||
board.appendChild(field);
|
board.appendChild(field);
|
||||||
|
|
Loading…
Reference in a new issue