From e69c80134d15e3b09db93c97fa54ae7bb70febb6 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index b2534d73..7219794a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -710,7 +710,14 @@ 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 === undefined) { + return false; + } + 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) {