summaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-03-01 21:17:43 +0100
committerTor Andersson <tor@ccxvii.net>2023-03-01 21:17:48 +0100
commitfab1401922290364fcd260d7390701b46aa3eb75 (patch)
tree364e101760671e44246729a660e48df5ffb5532f /server.js
parentba9f82e2344bbbda2d5aa5d81b41a9b52624a4c3 (diff)
downloadserver-fab1401922290364fcd260d7390701b46aa3eb75.tar.gz
Separate ready and full status for display in game lists.
Diffstat (limited to 'server.js')
-rw-r--r--server.js7
1 files changed, 6 insertions, 1 deletions
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)