From 072766b71f9441fdd2796b8dd1137b90acd5a561 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 12 Jun 2022 16:42:33 +0200 Subject: List playing and recently finished games on user pages. --- views/games_active.pug | 11 +++++------ views/games_finished.pug | 7 +++++-- views/games_public.pug | 8 ++++---- views/head.pug | 15 ++++++++++++--- views/info.pug | 10 +++++----- views/user.pug | 10 ++++++++++ 6 files changed, 41 insertions(+), 20 deletions(-) (limited to 'views') diff --git a/views/games_active.pug b/views/games_active.pug index 16d8ceb..a72a203 100644 --- a/views/games_active.pug +++ b/views/games_active.pug @@ -13,24 +13,23 @@ html if ready_games.length > 0 h2 Ready to start - +gamelist(ready_games, "ready") + +gamelist(ready_games) if open_games.length > 0 h2 Open - +gamelist(open_games, "open") + +gamelist(open_games) if replacement_games.length > 0 h2 Need replacement - +gamelist(replacement_games, "replacement") + +gamelist(replacement_games) if active_games.length > 0 h2 Active - +gamelist(active_games, "active") - + +gamelist(active_games) if finished_games.length > 0 h2 Recently finished - +gamelist(finished_games, "finished") + +gamelist(finished_games) p All your finished games diff --git a/views/games_finished.pug b/views/games_finished.pug index c6fa66d..df7f038 100644 --- a/views/games_finished.pug +++ b/views/games_finished.pug @@ -7,9 +7,12 @@ html body include header article - h1 Your finished games + if user && user.user_id === who.user_id + h1 Your finished games + else + h1 #{who.name}’s finished games if finished_games.length > 0 - +gamelist(finished_games, "finished") + +gamelist(finished_games) else p Nothing here. diff --git a/views/games_public.pug b/views/games_public.pug index a681419..9c56402 100644 --- a/views/games_public.pug +++ b/views/games_public.pug @@ -13,20 +13,20 @@ html h2 Open if open_games.length > 0 - +gamelist(open_games, "open") + +gamelist(open_games) else p No open games. if replacement_games.length > 0 h2 Need replacement - +gamelist(replacement_games, "replacement") + +gamelist(replacement_games) if ready_games.length > 0 h2 Ready to start - +gamelist(ready_games, "ready") + +gamelist(ready_games) h2 Active if active_games.length > 0 - +gamelist(active_games, "active") + +gamelist(active_games) else p No open games. diff --git a/views/head.pug b/views/head.pug index 911def4..748d417 100644 --- a/views/head.pug +++ b/views/head.pug @@ -34,11 +34,20 @@ mixin forumpost(row,show_buttons) | | #[a(href="/forum/reply/"+row.post_id) Reply] -mixin gamelist(list,status,hide_title=0) - div.game_list(class=status) +mixin gamelist(list,hide_title=0) + div.game_list each item in list div - div.game_item(class=item.your_turn ? "your_turn" : "") + - + let className = "game_item" + if (item.your_turn) className += " your_turn" + 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" + else if (item.status === 2) className += " finished" + + div(class=className) div.game_head if item.scenario.length <= 2 div diff --git a/views/info.pug b/views/info.pug index c7083ef..24425e5 100644 --- a/views/info.pug +++ b/views/info.pug @@ -21,25 +21,25 @@ html h2 Open if open_games.length > 0 - +gamelist(open_games, "open", true) + +gamelist(open_games, true) else p No open games. if replacement_games.length > 0 h2 Need replacement - +gamelist(replacement_games, "replacement", true) + +gamelist(replacement_games, true) p a(href="/create/"+title.title_id) Create a new game if ready_games.length > 0 h2 Ready to start - +gamelist(ready_games, "ready", true) + +gamelist(ready_games, true) if active_games.length > 0 h2 Active - +gamelist(active_games, "active", true) + +gamelist(active_games, true) if finished_games.length > 0 h2 Recently finished - +gamelist(finished_games, "finished", true) + +gamelist(finished_games, true) diff --git a/views/user.pug b/views/user.pug index 99420cc..73c2e2d 100644 --- a/views/user.pug +++ b/views/user.pug @@ -21,3 +21,13 @@ html if user p a(href="/message/send/"+who.name) Send message + + if active_games.length > 0 + h2 Playing + +gamelist(active_games) + + if finished_games.length > 0 + h2 Recently finished + +gamelist(finished_games) + + p All #{who.name}'s finished games -- cgit v1.2.3