Add a log message
This commit is contained in:
parent
0794aaf8fb
commit
f0fb5a11fe
1 changed files with 26 additions and 0 deletions
|
@ -31,6 +31,13 @@ export class Game
|
||||||
*/
|
*/
|
||||||
#board;
|
#board;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The element containing a log message.
|
||||||
|
*
|
||||||
|
* @type {HTMLElement}
|
||||||
|
*/
|
||||||
|
#log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id of the element to add the board to.
|
* The id of the element to add the board to.
|
||||||
*
|
*
|
||||||
|
@ -79,7 +86,14 @@ export class Game
|
||||||
class: "board"
|
class: "board"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.#log = elt(
|
||||||
|
"div",
|
||||||
|
{
|
||||||
|
class: "log"
|
||||||
|
});
|
||||||
|
|
||||||
container.appendChild(this.#board);
|
container.appendChild(this.#board);
|
||||||
|
container.appendChild(this.#log);
|
||||||
this.draw();
|
this.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,6 +151,18 @@ export class Game
|
||||||
board.appendChild(field);
|
board.appendChild(field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
board.appendChild(
|
||||||
|
elt(
|
||||||
|
"div",
|
||||||
|
{
|
||||||
|
style: "clear: both;"
|
||||||
|
}));
|
||||||
|
|
||||||
|
this.#log.className = "";
|
||||||
|
this.#log.classList.add(this.state.currentPlayer);
|
||||||
|
this.#log.innerHTML = "";
|
||||||
|
this.#log.textContent = `It's player "${Constants.PLAYER_NAMES[this.state.currentPlayer]}"s turn`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue