Add a log message

This commit is contained in:
Manuel Thalmann 2022-12-13 12:55:39 +01:00
parent 0794aaf8fb
commit f0fb5a11fe
No known key found for this signature in database
GPG key ID: 5FD9AD3CCDDBD27B

View file

@ -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`;
}
/**