console.log("Closing connections and saving the game state...");
let listeningPlayerCount = 0;
+ let gamesCount = 0;
for (const gameID of Object.keys(games)) {
const game = games[gameID];
for (const listeningPlayer of game.listeningPlayers) {
writeResponse(listeningPlayer, '{"stopping": 2000}', true);
}
- listeningPlayerCount += game.listeningPlayers.length;
+
+ if (game.listeningPlayers.length) {
+ listeningPlayerCount += game.listeningPlayers.length;
+ gamesCount++;
+ }
}
- console.log("Stopped", games.length, "games and ", listeningPlayerCount, " player connections.");
+ console.log("Stopped", gamesCount, "games and", listeningPlayerCount, "player connections.");
saveGames(true);
}