diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-03-01 21:17:43 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-03-01 21:17:48 +0100 |
commit | fab1401922290364fcd260d7390701b46aa3eb75 (patch) | |
tree | 364e101760671e44246729a660e48df5ffb5532f | |
parent | ba9f82e2344bbbda2d5aa5d81b41a9b52624a4c3 (diff) | |
download | server-fab1401922290364fcd260d7390701b46aa3eb75.tar.gz |
Separate ready and full status for display in game lists.
-rw-r--r-- | server.js | 7 | ||||
-rw-r--r-- | views/games_public.pug | 10 | ||||
-rw-r--r-- | views/head.pug | 8 | ||||
-rw-r--r-- | views/info.pug | 10 |
4 files changed, 20 insertions, 15 deletions
@@ -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) diff --git a/views/games_public.pug b/views/games_public.pug index b91dd61..eb188be 100644 --- a/views/games_public.pug +++ b/views/games_public.pug @@ -1,8 +1,8 @@ //- vim:ts=4:sw=4: -- let open_games = games0.filter(game => game.status === 0 && !game.is_ready) -- let ready_games = games0.filter(game => game.status === 0 && game.is_ready) -- let replacement_games = games0.filter(game => game.status === 1 && !game.is_ready) -- let active_games = games1.filter(game => game.status === 1 && game.is_ready) +- let open_games = games0.filter(game => game.status === 0 && !game.is_full) +- let ready_games = games0.filter(game => game.status === 0 && game.is_full) +- let replacement_games = games0.filter(game => game.status === 1 && !game.is_full) +- let active_games = games1.filter(game => game.status === 1 && game.is_full) doctype html html head @@ -29,7 +29,7 @@ html +gamelist(replacement_games) if ready_games.length > 0 - h2 Ready to start + h2 Ready +gamelist(ready_games) if active_games.length > 0 diff --git a/views/head.pug b/views/head.pug index 78fe0ba..3d2285a 100644 --- a/views/head.pug +++ b/views/head.pug @@ -45,10 +45,10 @@ mixin gamelist(list,hide_title=0) let className = "game_item" if (item.your_turn) className += " your_turn" if (item.is_unread) className += " unread" - if (item.status === 0 && !item.is_ready) className += " open" - else if (item.status === 0 && item.is_ready) className += " ready" - else if (item.status === 1 && !item.is_ready) className += " replacement" - else if (item.status === 1 && item.is_ready) className += " active" + if (item.status === 0 && !item.is_full) className += " open" + else if (item.status === 0 && item.is_full) className += " ready" + else if (item.status === 1 && !item.is_full) className += " replacement" + else if (item.status === 1 && item.is_full) className += " active" else if (item.status === 2) className += " finished" div(class=className) diff --git a/views/info.pug b/views/info.pug index 8eb1d40..60eac7b 100644 --- a/views/info.pug +++ b/views/info.pug @@ -1,8 +1,8 @@ //- vim:ts=4:sw=4: -- let open_games = games0.filter(game => game.status === 0 && !game.is_ready) -- let ready_games = games0.filter(game => game.status === 0 && game.is_ready) -- let replacement_games = games1.filter(game => game.status === 1 && !game.is_ready) -- let active_games = games1.filter(game => game.status === 1 && game.is_ready) +- let open_games = games0.filter(game => game.status === 0 && !game.is_full) +- let ready_games = games0.filter(game => game.status === 0 && game.is_full) +- let replacement_games = games1.filter(game => game.status === 1 && !game.is_full) +- let active_games = games1.filter(game => game.status === 1 && game.is_full) - let finished_games = games2 doctype html html @@ -38,7 +38,7 @@ html a(href="/create/"+title.title_id) Create a new game if ready_games.length > 0 - h2 Ready to start + h2 Ready +gamelist(ready_games, true) if active_games.length > 0 |