diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-01-15 23:00:42 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-01-15 23:00:48 +0100 |
commit | 4cfbe0019331c8fb2d381606806e6bea253ca14a (patch) | |
tree | 2401a00273b7b19bdbefe70a60515a7b00833734 /server.js | |
parent | c3d34c80112b291f13375b477e4fb6d70b59ed0a (diff) | |
download | server-4cfbe0019331c8fb2d381606806e6bea253ca14a.tar.gz |
Separate open and ready to start game lists.
Diffstat (limited to 'server.js')
-rw-r--r-- | server.js | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -1015,8 +1015,16 @@ function annotate_game(game, user_id) { } function annotate_games(games, user_id) { - for (let i = 0; i < games.length; ++i) - annotate_game(games[i], user_id); + for (let i = 0; i < games.length; ++i) { + let game = games[i]; + if (game.status === 0) { + let players = SQL_SELECT_PLAYERS_JOIN.all(game.game_id); + game.is_ready = RULES[game.title_id].ready(game.scenario, JSON.parse(game.options), players); + } else { + game.is_ready = false; + } + annotate_game(game, user_id); + } } app.get('/games', function (req, res) { @@ -1032,7 +1040,8 @@ app.get('/games', function (req, res) { } res.render('games.pug', { user: req.user, - open_games: open_games, + open_games: open_games.filter(g => !g.is_ready), + ready_games: open_games.filter(g => g.is_ready), active_games: active_games, }); }); @@ -1048,7 +1057,8 @@ app.get('/profile', must_be_logged_in, function (req, res) { res.render('profile.pug', { user: req.user, avatar: avatar, - open_games: open_games, + open_games: open_games.filter(g => !g.is_ready), + ready_games: open_games.filter(g => g.is_ready), active_games: active_games, finished_games: finished_games, }); @@ -1073,7 +1083,8 @@ function get_title_page(req, res, title_id) { user: req.user, title: title, about_html: HTML_ABOUT[title_id], - open_games: open_games, + open_games: open_games.filter(g => !g.is_ready), + ready_games: open_games.filter(g => g.is_ready), active_games: active_games, finished_games: finished_games, }); |