summaryrefslogtreecommitdiff
path: root/views/games.ejs
blob: fb58be8e4eb38038bea676a42915b82aab7552ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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>