summaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-09-10 21:05:59 +0200
committerTor Andersson <tor@ccxvii.net>2023-09-13 20:06:36 +0200
commit6407378d92eb8880e35e8ee33e1801136a1a44a7 (patch)
tree9bac140875ba3ba3a29c8fee864b0eca8d922399 /views
parent2da7e775f26043e0d475faf89d1fce03c798b1e3 (diff)
downloadserver-6407378d92eb8880e35e8ee33e1801136a1a44a7.tar.gz
Set player_count in database for faster and easier logic.
Track ready to start and unjoined games in "active" header.
Diffstat (limited to 'views')
-rw-r--r--views/games_public.pug22
-rw-r--r--views/head.pug15
-rw-r--r--views/header.pug4
-rw-r--r--views/info.pug15
-rw-r--r--views/join.pug12
5 files changed, 33 insertions, 35 deletions
diff --git a/views/games_public.pug b/views/games_public.pug
index d49fc9e..9afc45c 100644
--- a/views/games_public.pug
+++ b/views/games_public.pug
@@ -1,8 +1,4 @@
//- vim:ts=4:sw=4:
-- let open_games = games0.filter(game => game.status === 0 && !game.is_full)
-- let ready_games = games0.filter(game => game.status === 0 && game.is_full)
-- let replacement_games = games1.filter(game => game.status === 1 && !game.is_full)
-- let active_games = games1.filter(game => game.status === 1 && game.is_full)
doctype html
html
head
@@ -13,7 +9,7 @@ html
body
include header
article
- h1 All Public Games
+ h1 Public Games
h2 Open
if open_games.length > 0
@@ -21,17 +17,21 @@ html
else
p No open games.
- p
- a(href="/create") Create a new game
-
if replacement_games.length > 0
- h2 Need replacement
+ h2 Open (missing players)
+gamelist(replacement_games)
+ p
+ a(href="/create") Create a new game
+
if ready_games.length > 0
- h2 Ready
+ h2 Open (waiting to start)
+gamelist(ready_games)
if active_games.length > 0
- h2 Active
+ h2 Recently active
+gamelist(active_games)
+
+ if finished_games.length > 0
+ h2 Recently finished
+ +gamelist(finished_games)
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
diff --git a/views/header.pug b/views/header.pug
index c417665..454c35a 100644
--- a/views/header.pug
+++ b/views/header.pug
@@ -7,8 +7,8 @@ header
if ENABLE_FORUM
a(href="/forum") Forum
a(href="/games/public") Public
- if user.active > 0
- a(href="/games/active") Games (#{user.active})
+ if user.waiting > 0
+ a(href="/games/active") Games (#{user.waiting})
else
a(href="/games/active") Games
a(href="/contacts") Friends
diff --git a/views/info.pug b/views/info.pug
index 60eac7b..51fc81d 100644
--- a/views/info.pug
+++ b/views/info.pug
@@ -1,9 +1,4 @@
//- vim:ts=4:sw=4:
-- let open_games = games0.filter(game => game.status === 0 && !game.is_full)
-- let ready_games = games0.filter(game => game.status === 0 && game.is_full)
-- let replacement_games = games1.filter(game => game.status === 1 && !game.is_full)
-- let active_games = games1.filter(game => game.status === 1 && game.is_full)
-- let finished_games = games2
doctype html
html
head
@@ -24,25 +19,23 @@ html
p Read more about the game on #[a(href="https://boardgamegeek.com/boardgame/"+title.bgg) boardgamegeek.com].
- h2 Open
if open_games.length > 0
+ h2 Open
+gamelist(open_games, true)
- else
- p No open games.
if replacement_games.length > 0
- h2 Need replacement
+ h2 Open (missing players)
+gamelist(replacement_games, true)
p
a(href="/create/"+title.title_id) Create a new game
if ready_games.length > 0
- h2 Ready
+ h2 Open (waiting to start)
+gamelist(ready_games, true)
if active_games.length > 0
- h2 Active
+ h2 Recently active
+gamelist(active_games, true)
if finished_games.length > 0
diff --git a/views/join.pug b/views/join.pug
index 0f9daef..2e6bf08 100644
--- a/views/join.pug
+++ b/views/join.pug
@@ -43,11 +43,13 @@ html
unless game.human_options === "None"
div Options: #{game.human_options}
- div
- if game.is_private
- | Owner: <a href="/user/#{game.owner_name}">#{game.owner_name}</a> (private)
- else
- | Owner: <a href="/user/#{game.owner_name}">#{game.owner_name}</a>
+
+ if game.owner_id
+ div
+ if game.is_private
+ | Owner: <a href="/user/#{game.owner_name}">#{game.owner_name}</a> (private)
+ else
+ | Owner: <a href="/user/#{game.owner_name}">#{game.owner_name}</a>
div Created: #{game.ctime}
unless game.mtime === "never"