From 6407378d92eb8880e35e8ee33e1801136a1a44a7 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 10 Sep 2023 21:05:59 +0200 Subject: Set player_count in database for faster and easier logic. Track ready to start and unjoined games in "active" header. --- views/head.pug | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'views/head.pug') diff --git a/views/head.pug b/views/head.pug index 2322250..fa2b042 100644 --- a/views/head.pug +++ b/views/head.pug @@ -45,10 +45,11 @@ 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_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" + if (item.status === 0 && item.join_count === 0) className += " open replacement" + else if (item.status === 0 && item.join_count !== item.player_count) className += " open" + else if (item.status === 0 && item.join_count === item.player_count) className += " ready" + else if (item.status === 1 && item.join_count !== item.player_count) className += " replacement" + else if (item.status === 1 && item.join_count === item.player_count) className += " active" else if (item.status === 2) className += " finished" else if (item.status === 3) className += " archived" @@ -63,12 +64,14 @@ mixin gamelist(list,hide_title=0) case item.status when 0 - if item.is_ready && item.your_turn + if item.join_count === item.player_count a(class="command" href=`/join/${item.game_id}`) Start else a(class="command" href=`/join/${item.game_id}`) Join when 1 - if item.is_yours + if item.join_count !== item.player_count + a(class="command" href="/join/"+item.game_id) Join + else if item.is_yours if item.your_role a(class="command" href=`/${item.title_id}/play.html?game=${item.game_id}&role=${encodeURIComponent(item.your_role)}`) Play else -- cgit v1.2.3