diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-05-01 00:48:35 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2021-05-01 00:48:35 +0200 |
commit | 652852e3104ce4020de53231ee7691a4970439d6 (patch) | |
tree | 57a053cb2104520e240cd44a4dfb9f92fd5ede07 /views/join.ejs | |
parent | 156f7f8546890c6406001061dae199f8320ca83b (diff) | |
download | server-652852e3104ce4020de53231ee7691a4970439d6.tar.gz |
Add server and lobby code.
Diffstat (limited to 'views/join.ejs')
-rw-r--r-- | views/join.ejs | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/views/join.ejs b/views/join.ejs new file mode 100644 index 0000000..810e0f4 --- /dev/null +++ b/views/join.ejs @@ -0,0 +1,85 @@ +<%- include('header', { title: game.title_name, refresh: game.status == 0 ? 15 : 0 }) %> +<script> +function confirm_delete(status) { + let warning = "Are you sure you want to DELETE this game?"; + if (window.confirm(warning)) + window.open("/delete/<%= game.game_id %>"); +} +</script> + +<a href="/info/<%= game.title_id %>"><img class="logo" src="/<%= game.title_id %>/cover.jpg"></a> + +<p> +Owner: <%= game.owner_name %> +<p> +Scenario: <%= game.scenario %> +<p> +Description: <%= game.description || "No description." %> + +<br clear=left> + +<p> +<table> +<tr> +<% + roles.forEach((role) => { + %><th><%= role.role %><% + }); +%> +<tr> +<% + roles.forEach((role) => { + if (game.active == role.role || game.active == "Both" || game.active == "All") { + %><td style="min-width:9em" class="your_turn"><% + } else { + %><td style="min-width:9em"><% + } + let p = players.find(p => p.role == role.role); + if (game.status == 0) { + if (p) { + if ((p.user_id == user.user_id) || (game.owner_id == user.user_id)) { + %><a style="color:red;text-decoration:none" href="/part/<%= game.game_id %>/<%= p.user_id %>/<%= p.role %>">❌</a> <% + %><%= p.name %><% + } else { + %><%= p.name %><% + } + } else { + %><a href="/join/<%= game.game_id %>/<%= role.role %>">Join</a><% + } + } else { + if (p) { + if (p.user_id == user.user_id) { + %><a href="/play/<%= game.game_id %>/<%= p.role %>">Play</a><% + } else { + %><%= p.name %><% + } + } else { + %><i>Empty</i><% + } + } + }); + if (game.status > 0 && !players.some(p => p.user_id == user.user_id)) { + %> + <tr><td colspan="<%= roles.length %>"><a href="/play/<%= game.game_id %>/Observer">View</a> + <% + } +%> +</table> + +<p> +<% + if (game.status == 0) { + if (players.length == roles.length) { + if (game.owner_id == user.user_id) { + %><form action="/start/<%= game.game_id %>"><button type="submit">Start!</button></form><% + } else { + %>Waiting for <%= game.owner_name %> to start the game.<% + } + } else { + %>Waiting for players to join the game.<% + } + } + if (game.owner_id == user.user_id && (game.status == 0 || solo)) { + %><p><br><button onclick="confirm_delete()">Delete</button><% + } +%> |