Fix game in progress check
authorRaphaël Jakse <raphael.trivabble@jakse.fr>
Thu, 8 May 2025 13:04:49 +0000 (15:04 +0200)
committerRaphaël Jakse <raphael.trivabble@jakse.fr>
Thu, 8 May 2025 13:44:02 +0000 (15:44 +0200)
l10n/po/fr/trivabble.po
l10n/pot/trivabble.pot
public/trivabble.js

index c57ae706ed76339d0ee90ad0bccab74335a1a07c..2469e0eb97c52fa44937a215041d2a6a308152aa 100644 (file)
@@ -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"
 
index 705f003d62947e7b10c4bbb2a0fd0dd61c0cb337..2a3d279cdae25387dfe473da234b5f03480e14aa 100644 (file)
@@ -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 ""
 
index 3d4afd52537cb1b00191fe995a51af7b487a29cd..dbb4d43a3668642f4d93412a52aa9a238c67d75b 100644 (file)
     let scoreOf;
     let bag;
     let tileCount;
+    let nbTilesInRacks = 0;
     let boardLangSelect;
     let boardLabelSelect;
     const downloadedDictionaries = {};
     let blockMove = 0;
     let remainingLetters = 0;
     let needsRestart = false;
-    let gameInProgress = true;
     let currentTilePlayed = {};
 
     let eventSource = null;
     }
 
     function checkGameInProgress(f) {
-        if (!gameInProgress) {
+        if (!isGameInProgress()) {
             return f();
         }
 
             participantPlaceholder = null;
         }
 
-        let nbTilesInRacks = 0;
+        nbTilesInRacks = 0;
         for (let i = 0; i < players.length; i++) {
             const player = players[i];
             const playerName = players[i].player;
         }
 
         refreshCurrentPlayer();
-        gameInProgress = (nbTilesInRacks + remainingLetters > 0);
+    }
+
+    function isGameInProgress() {
+        return nbTilesInRacks > 0 || Boolean(board.querySelector(".tile"));
     }
 
     function handleLastPlayer(data) {
     }
 
     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"}]);