From f0fb5a11fee5d9fb86f9cb15a11ae43dd4366773 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 13 Dec 2022 12:55:39 +0100 Subject: [PATCH] Add a log message --- src/js/Game.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/js/Game.js b/src/js/Game.js index 0f44c5a..3a36f34 100644 --- a/src/js/Game.js +++ b/src/js/Game.js @@ -31,6 +31,13 @@ export class Game */ #board; + /** + * The element containing a log message. + * + * @type {HTMLElement} + */ + #log; + /** * The id of the element to add the board to. * @@ -79,7 +86,14 @@ export class Game class: "board" }); + this.#log = elt( + "div", + { + class: "log" + }); + container.appendChild(this.#board); + container.appendChild(this.#log); this.draw(); } @@ -137,6 +151,18 @@ export class Game 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`; } /**