From 09c3f5f808581821729cd1de879e22b754a72934 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 24 Jul 2022 12:28:05 +0200 Subject: Sort player names by role. --- public/style.css | 2 +- server.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/public/style.css b/public/style.css index 1f6fdf6..330e8f4 100644 --- a/public/style.css +++ b/public/style.css @@ -169,7 +169,7 @@ article hr + p { font-style: italic; } .game_main img { display: block; height: 72px; - margin: 4px 0; + margin: 4px 0 4px 4px; border: 1px solid black; } diff --git a/server.js b/server.js index feb06ca..4145b43 100644 --- a/server.js +++ b/server.js @@ -1015,12 +1015,17 @@ function format_options(options) { function annotate_game(game, user_id) { let players = SQL_SELECT_PLAYERS_JOIN.all(game.game_id) let options = JSON.parse(game.options) + let roles = get_game_roles(game.title_id, game.scenario, options) if (game.options === '{}') game.human_options = "None" else game.human_options = format_options(options) + for (let i = 0; i < players.length; ++i) + players[i].index = roles.indexOf(players[i].role) + players.sort((a, b) => a.index - b.index) + game.is_ready = is_game_ready(game.title_id, game.scenario, options, players) let your_count = 0 -- cgit v1.2.3