summaryrefslogtreecommitdiff
path: root/views/games.ejs
diff options
context:
space:
mode:
Diffstat (limited to 'views/games.ejs')
-rw-r--r--views/games.ejs56
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>
+