From: Raphaël Jakse Date: Thu, 8 May 2025 13:04:49 +0000 (+0200) Subject: Fix game in progress check X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=ae05664e79c2aeb153f2b2013cffe993e12cae03;p=trivabble.git Fix game in progress check --- diff --git a/l10n/po/fr/trivabble.po b/l10n/po/fr/trivabble.po index c57ae70..2469e0e 100644 --- a/l10n/po/fr/trivabble.po +++ b/l10n/po/fr/trivabble.po @@ -295,9 +295,6 @@ msgstr "joker" msgid "Leave current game" msgstr "Quitter cette partie" -msgid "You are about to leave this game. Your letters will be put back in the bag. Are you sure?" -msgstr "Vous allez quitter la partie. Vos lettres seront remises dans le sac. Êtes-vous sûr·e ?" - msgid "Enable first word verification" msgstr "Activer la vérification du premier mot" diff --git a/l10n/pot/trivabble.pot b/l10n/pot/trivabble.pot index 705f003..2a3d279 100644 --- a/l10n/pot/trivabble.pot +++ b/l10n/pot/trivabble.pot @@ -300,9 +300,6 @@ msgstr "" msgid "Leave current game" msgstr "" -msgid "You are about to leave this game. Your letters will be put back in the bag. Are you sure?" -msgstr "" - msgid "Enable first word verification" msgstr "" diff --git a/public/trivabble.js b/public/trivabble.js index 3d4afd5..dbb4d43 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -187,6 +187,7 @@ let scoreOf; let bag; let tileCount; + let nbTilesInRacks = 0; let boardLangSelect; let boardLabelSelect; const downloadedDictionaries = {}; @@ -208,7 +209,6 @@ let blockMove = 0; let remainingLetters = 0; let needsRestart = false; - let gameInProgress = true; let currentTilePlayed = {}; let eventSource = null; @@ -804,7 +804,7 @@ } function checkGameInProgress(f) { - if (!gameInProgress) { + if (!isGameInProgress()) { return f(); } @@ -982,7 +982,7 @@ participantPlaceholder = null; } - let nbTilesInRacks = 0; + nbTilesInRacks = 0; for (let i = 0; i < players.length; i++) { const player = players[i]; const playerName = players[i].player; @@ -1127,7 +1127,10 @@ } refreshCurrentPlayer(); - gameInProgress = (nbTilesInRacks + remainingLetters > 0); + } + + function isGameInProgress() { + return nbTilesInRacks > 0 || Boolean(board.querySelector(".tile")); } function handleLastPlayer(data) { @@ -1647,8 +1650,7 @@ } function leaveGame() { - myConfirm( - _("You are about to leave this game. Your letters will be put back in the bag. Are you sure?"), + checkGameInProgress( function () { sendBackTiles(); sendCmds([{cmd: "leaveGame"}]);