(tic-tac-toe): Erratum, it's the join/leave queue button

This commit is contained in:
apetitco 2026-01-07 22:40:48 +01:00 committed by Maix0
parent ca9b2a7320
commit 92eb73c508
5 changed files with 17 additions and 16 deletions

View file

@ -45,20 +45,20 @@ async function handleTTT(): Promise<RouteHandlerReturn> {
if (user === null)
return;
const newGameBtn = document.querySelector<HTMLButtonElement>("#NewGameBtn");
const joinQueueBtn = document.querySelector<HTMLButtonElement>("#JoinQueueBtn");
if (!newGameBtn) {
if (!joinQueueBtn) {
return showError('fatal error');
}
// TODO
// TODO: Join queue button
// When clicking on this button, two scenarios:
// not in a game -> Join queue
// In a game -> user clicking on the button loses the game and joins the queue, board is cleaned
// Should I differentiate the scenarios here or inside the requestNewGame function ?
newGameBtn.addEventListener("click", () => {
console.log('===== NEW GAME REQUESTED =====');
socket.emit("requestNewGame");
joinQueueBtn.addEventListener("click", () => {
console.log('===== JOIN QUEUE BUTTON PRESSED =====');
socket.emit("joinQueueButton");
});
let curGame: CurrentGameInfo | null = null;