Skip to content

Commit

Permalink
fix concurrent player check
Browse files Browse the repository at this point in the history
The `player_pool` property does not exist on main site (yet?).
  • Loading branch information
windo committed May 12, 2024
1 parent 9478fd1 commit e837970
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e837970

Please sign in to comment.