From fab1401922290364fcd260d7390701b46aa3eb75 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 1 Mar 2023 21:17:43 +0100 Subject: Separate ready and full status for display in game lists. --- server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'server.js') diff --git a/server.js b/server.js index f0a4d8c..ecc03eb 100644 --- a/server.js +++ b/server.js @@ -1054,11 +1054,15 @@ function get_game_roles(title_id, scenario, options) { return roles } +function is_game_full(title_id, scenario, options, players) { + return get_game_roles(title_id, scenario, options).length === players.length +} + function is_game_ready(title_id, scenario, options, players) { for (let p of players) if (p.is_invite) return false - return get_game_roles(title_id, scenario, options).length === players.length + return is_game_full(title_id, scenario, options, players) } load_rules() @@ -1209,6 +1213,7 @@ function annotate_game(game, user_id, unread) { players[i].index = roles.indexOf(players[i].role) players.sort((a, b) => a.index - b.index) + game.is_full = is_game_full(game.title_id, game.scenario, options, players) game.is_ready = is_game_ready(game.title_id, game.scenario, options, players) game.is_unread = set_has(unread, game.game_id) -- cgit v1.2.3