add a warning when leaving a game in progess during a join
authorLaurent Mazet <mazet@softndesign.org>
Mon, 3 Feb 2025 22:44:02 +0000 (23:44 +0100)
committerRaphaël Jakse <raph@jakse.fr>
Fri, 14 Feb 2025 07:13:19 +0000 (08:13 +0100)
public/trivabble.js

index 1ba9d615674d501ca38ff11f156aa9eef257db76..487fc1fef111adda0e796b301e45754918dfb68a 100644 (file)
     let blockMove = 0;
     let remainingLetters = 0;
     let needsRestart = false;
-    const gameInProgress = false;
+    let gameInProgress = true;
     let currentTilePlayed = {};
 
     let eventSource = null;
 
         myConfirm(
             _("Your game is not over. Are you sure you want to leave now?"),
-            function () {
-                myAlert(
-                    format(
-                        _("You are about to leave the current game. To recover it, please note its number: {0}"),
-                        getSetting("GameNumber")
-                    ),
-                    f
-                );
-            }
+            f
         );
     }
 
             participantPlaceholder = null;
         }
 
+        let nbTilesInRacks = 0;
         for (let i = 0; i < players.length; i++) {
             const player = players[i];
             const playerName = players[i].player;
                 const countCell = tablePlayers[playerName].childNodes[1];
                 countCell.textContent = player.rackCount;
                 blink(countCell);
+                nbTilesInRacks += player.rackCount;
             }
         }
 
         refreshCurrentPlayer();
+        gameInProgress = (nbTilesInRacks + remainingLetters > 0);
     }
 
     function handleLastPlayer(data) {