From e837970fb71eda5e786e12f69a46e9140b709f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siim=20P=C3=B5der?= Date: Sun, 12 May 2024 14:42:03 +0000 Subject: [PATCH] fix concurrent player check The `player_pool` property does not exist on main site (yet?). --- src/main.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index b2534d73..d821f22a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -710,7 +710,16 @@ class Main { config; if (config.max_games_per_player) { const game_count = Object.keys(this.connected_games).filter((game_id) => { - return !!this.connected_games[game_id].state?.player_pool[player_id]; + const state = this.connected_games[game_id]?.state; + if (state == null) { + trace.log("No game state for: ", game_id); + return false; + } + // The `player_pool` property isn't set on real games? + if (state.player_pool !== undefined) { + return !!state.player_pool[player_id]; + } + return state.white_player_id === player_id || state.black_player_id === player_id; }).length; trace.log("Game count: ", game_count, " for ", player_id); if (game_count >= config.max_games_per_player) {