diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-06-17 16:35:18 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2021-06-19 11:48:10 +0200 |
commit | 95cfd9241629f50ff36fb0c4700530cf5b697158 (patch) | |
tree | 6b6bbe5c721fad871de9a1131a27341cbe1b79b4 /views | |
parent | fb9fa1b6365c1c13e00c35257e53eebf610f0c6c (diff) | |
download | server-95cfd9241629f50ff36fb0c4700530cf5b697158.tar.gz |
Add list of public games page at /games.
Diffstat (limited to 'views')
-rw-r--r-- | views/games.ejs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/views/games.ejs b/views/games.ejs new file mode 100644 index 0000000..fb58be8 --- /dev/null +++ b/views/games.ejs @@ -0,0 +1,56 @@ +<%- include('header', { title: "All Public Games", refresh: (user ? 300 : 0) }) %> +<style> +td.nowrap a { color: black; text-decoration: none; } +</style> + +<h2>Open</h2> +<table class="wide"> +<tr><th>ID<th>Title<th>Scenario<th>Owner<th>Description<th>Created<th>Players<th> +<% if (open_games.length > 0) { %> +<% open_games.forEach((row) => { %> +<tr> +<td><%= row.game_id %> +<td class="nowrap"><a href="/info/<%= row.title_id %>"><%= row.title_name %></a> +<td><%= row.scenario %> +<td><%= row.owner_name %> +<td><%= row.description %> +<td class="nowrap"><%= row.ctime %> +<td><%= row.players.join(", ") %> +<td><a href="/join/<%= row.game_id %>">Join</a> +<% }); } else { %> +<tr><td colspan="6">No open games. +<% } %> +</table> + +<h2>Active</h2> +<table class="wide"> +<tr><th>ID<th>Title<th>Scenario<th>Description<th>Changed<th>Players<th>Active<th> +<% if (active_games.length > 0) { %> +<% active_games.forEach((row) => { %> +<tr> +<td><%= row.game_id %> +<td class="nowrap"><a href="/info/<%= row.title_id %>"><%= row.title_name %></a> +<td><%= row.scenario %> +<td><%= row.description %> +<td class="nowrap"><%= row.mtime %> +<td><%= row.players.join(", ") %> +<% + if (row.your_turn) { + %><td class="your_turn"><%= row.active %><% + } else { + %><td><%= row.active %><% + } + let me = row.players.reduce((n,p) => n + (p === user.name ? 1 : 0), 0); + if (me == 1) { + %><td><a href="/play/<%= row.game_id %>">Play</a><% + } else if (me > 1) { + %><td><a href="/join/<%= row.game_id %>">Play</a><% + } else { + %><td><a href="/join/<%= row.game_id %>">View</a><% + } +%> +<% }); } else { %> +<tr><td colspan="6">No active games. +<% } %> +</table> + |