summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-06-22 01:20:28 +0200
committerTor Andersson <tor@ccxvii.net>2022-06-27 14:31:50 +0200
commit6120eeefa55d55ff46b508dbfa8214fc1f21b338 (patch)
tree32e28a041d9c558b6466aa5c6650fb8c48149619
parentce767b57fcb916838be65f317e38c1a54f4f2258 (diff)
downloadserver-6120eeefa55d55ff46b508dbfa8214fc1f21b338.tar.gz
Sort active games with your turn first.
-rw-r--r--server.js3
-rw-r--r--views/head.pug2
2 files changed, 3 insertions, 2 deletions
diff --git a/server.js b/server.js
index 342e9a1..710879f 100644
--- a/server.js
+++ b/server.js
@@ -1036,7 +1036,7 @@ function annotate_game(game, user_id) {
if (p.user_id === user_id) {
your_role = p.role
your_count++
- if (p_is_active || (p_is_owner && game.is_ready))
+ if ((p_is_active || p_is_owner) && game.is_ready)
game.your_turn = true
}
@@ -1093,6 +1093,7 @@ function sort_your_turn(a, b) {
app.get('/games/active', must_be_logged_in, function (req, res) {
let games = QUERY_LIST_ACTIVE_GAMES_OF_USER.all({ user_id: req.user.user_id })
annotate_games(games, req.user.user_id)
+ games.sort(sort_your_turn)
res.render('games_active.pug', { user: req.user, who: req.user, games: games })
})
diff --git a/views/head.pug b/views/head.pug
index 005a4b2..08f2660 100644
--- a/views/head.pug
+++ b/views/head.pug
@@ -61,7 +61,7 @@ mixin gamelist(list,hide_title=0)
case item.status
when 0
- if item.is_yours && item.is_ready
+ if item.is_ready && item.your_turn
a(class="command" href=`/join/${item.game_id}`) Start
else
a(class="command" href=`/join/${item.game_id}`) Join