From 652852e3104ce4020de53231ee7691a4970439d6 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 1 May 2021 00:48:35 +0200 Subject: Add server and lobby code. --- views/about.ejs | 83 +++++++++++++++++++++++++++++++++++++++++++++ views/banned.ejs | 3 ++ views/change_password.ejs | 15 +++++++++ views/create.ejs | 22 ++++++++++++ views/error.ejs | 1 + views/header.ejs | 32 ++++++++++++++++++ views/index.ejs | 19 +++++++++++ views/info.ejs | 83 +++++++++++++++++++++++++++++++++++++++++++++ views/join.ejs | 85 +++++++++++++++++++++++++++++++++++++++++++++++ views/login.ejs | 15 +++++++++ views/profile.ejs | 84 ++++++++++++++++++++++++++++++++++++++++++++++ views/signup.ejs | 18 ++++++++++ views/users.ejs | 16 +++++++++ 13 files changed, 476 insertions(+) create mode 100644 views/about.ejs create mode 100644 views/banned.ejs create mode 100644 views/change_password.ejs create mode 100644 views/create.ejs create mode 100644 views/error.ejs create mode 100644 views/header.ejs create mode 100644 views/index.ejs create mode 100644 views/info.ejs create mode 100644 views/join.ejs create mode 100644 views/login.ejs create mode 100644 views/profile.ejs create mode 100644 views/signup.ejs create mode 100644 views/users.ejs (limited to 'views') diff --git a/views/about.ejs b/views/about.ejs new file mode 100644 index 0000000..ed1b54d --- /dev/null +++ b/views/about.ejs @@ -0,0 +1,83 @@ +<%- include('header', { title: "Rally the Troops!" }) %> + + +

+Rally the Troops! is created and maintained by Tor Andersson. +It is an open source project, and you can find the code on GitHub. + +

+Tips & Tricks +

+ + + +

+Licensing +

+ +

+All games are used with consent from their respective rights holders. + +

+Icons are sourced from game-icons.net +by Delapouite, Lorc, and others under the +CC BY 3.0 license. + + diff --git a/views/banned.ejs b/views/banned.ejs new file mode 100644 index 0000000..4c08bc2 --- /dev/null +++ b/views/banned.ejs @@ -0,0 +1,3 @@ +<%- include('header', { title: "Banned" }) %> +

+Sorry, but this IP or account has been banned. diff --git a/views/change_password.ejs b/views/change_password.ejs new file mode 100644 index 0000000..ab15a4a --- /dev/null +++ b/views/change_password.ejs @@ -0,0 +1,15 @@ +<%- include('header', { title: "Change password" }) %> +

+

+Name: <%= user.name %> +

+Mail: <%= user.mail %> +

+
+ +

+
+ +

+ +

diff --git a/views/create.ejs b/views/create.ejs new file mode 100644 index 0000000..a23fab5 --- /dev/null +++ b/views/create.ejs @@ -0,0 +1,22 @@ +<%- include('header', { title: title.title_name }) %> + + +
+

+Scenario:
+ +

+Description:
+ +

+ +

+ +

diff --git a/views/error.ejs b/views/error.ejs new file mode 100644 index 0000000..b7d9632 --- /dev/null +++ b/views/error.ejs @@ -0,0 +1 @@ +<%- include('header', { title: "Error" }) %> diff --git a/views/header.ejs b/views/header.ejs new file mode 100644 index 0000000..9e101dd --- /dev/null +++ b/views/header.ejs @@ -0,0 +1,32 @@ + + + + +<% if (typeof refresh != 'undefined' && refresh > 0) { %><% } %> + + + +<%= title %> + + +
+
+
+About +<% + if (user) { + %>Profile (<%= user.name %>)<% + } else { + %>Signup<% + %>Login<% + } +%> +
+
+
+

<%= title %>

+<% + if (typeof message != 'undefined' && message.length > 0) { + %>

<%= Array.isArray(message) ? message.join("\n") : message %>

<% + } +%> diff --git a/views/index.ejs b/views/index.ejs new file mode 100644 index 0000000..a9abeff --- /dev/null +++ b/views/index.ejs @@ -0,0 +1,19 @@ +<%- include('header', { title: "Rally the Troops!" }) %> + + +

+Rally the Troops! is a website where you can play historic games with other +players. + +

+Registration and use is free, and there are no ads. + +

+
+ +

+Join the Discord server to find players or report bugs. diff --git a/views/info.ejs b/views/info.ejs new file mode 100644 index 0000000..27cb543 --- /dev/null +++ b/views/info.ejs @@ -0,0 +1,83 @@ +<%- include('header', { title: title.title_name, refresh: (user ? 300 : 0) }) %> + +<%- include('../public/' + title.title_id + '/about.html') %> +
+

+Read more about the game on +boardgamegeek.com. + +<% if (user) { %> + +

Open Games

+ + +
IDScenarioOwnerDescriptionCreated +<% if (open_games.length > 0) { %> +<% open_games.forEach((row) => { %> +
<%= row.game_id %> +<%= row.scenario %> +<%= row.owner_name %> +<%= row.description %> +<%= row.ctime %> +Join +<% }); } else { %> +
No open games. +<% } %> +
+ +

+Create a new game. + +<% if (active_games.length > 0) { %> +

Active Games

+ + +
IDScenarioPlayersDescriptionChangedTurn +<% active_games.forEach((row) => { %> +
<%= row.game_id %> +<%= row.scenario %> +<%= row.players.join(", ") %> +<%= row.description %> +<%= row.mtime %> +<% + if (row.your_turn) { + %><%= row.active %><% + } else { + %><%= row.active %><% + } + let me = row.players.reduce((n,p) => n + (p === user.name ? 1 : 0), 0); + if (me == 1) { + %>Play<% + } else if (me > 1) { + %>Play<% + } else { + %>View<% + } +%> +<% }); %> +
+<% } %> + +<% if (finished_games.length > 0) { %> +

Finished Games

+ + +
IDScenarioPlayersDescriptionFinishedResult +<% finished_games.forEach((row) => { %> +
<%= row.game_id %> +<%= row.scenario %> +<%= row.players.join(", ") %> +<%= row.description %> +<%= row.mtime %> +<%= row.result %> +View +<% }); %> +
+<% } %> + +<% } else { %> + +

+Login to create or join a game. + +<% } %> 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 }) %> + + + + +

+Owner: <%= game.owner_name %> +

+Scenario: <%= game.scenario %> +

+Description: <%= game.description || "No description." %> + +
+ +

+ + +<% + roles.forEach((role) => { + %> +<% + roles.forEach((role) => { + if (game.active == role.role || game.active == "Both" || game.active == "All") { + %>
<%= role.role %><% + }); +%> +
<% + } else { + %><% + } + 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)) { + %> <% + %><%= p.name %><% + } else { + %><%= p.name %><% + } + } else { + %>Join<% + } + } else { + if (p) { + if (p.user_id == user.user_id) { + %>Play<% + } else { + %><%= p.name %><% + } + } else { + %>Empty<% + } + } + }); + if (game.status > 0 && !players.some(p => p.user_id == user.user_id)) { + %> +
View + <% + } +%> +
+ +

+<% + if (game.status == 0) { + if (players.length == roles.length) { + if (game.owner_id == user.user_id) { + %>

<% + } 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)) { + %>


<% + } +%> diff --git a/views/login.ejs b/views/login.ejs new file mode 100644 index 0000000..a5e2546 --- /dev/null +++ b/views/login.ejs @@ -0,0 +1,15 @@ +<%- include('header', { title: "Login" }) %> +<% if (user) { %> +

You're already logged in! +<% } else { %> +

+

+
+ +

+
+ +

+ +

+<% } %> diff --git a/views/profile.ejs b/views/profile.ejs new file mode 100644 index 0000000..60f1ff9 --- /dev/null +++ b/views/profile.ejs @@ -0,0 +1,84 @@ +<%- include('header', { title: "Rally the Troops!", refresh: (active_games.length > 0 ? 300 : 0) }) %> + + + +

+Welcome, <%= user.name %>! +

+Your mail address is <%= user.mail %>. + +
+ +

+Change password + +

+Logout + +<% if (open_games.length > 0) { %> +

Open Games

+ + +
IDGameScenarioPlayersDescriptionCreated +<% open_games.forEach((row) => { %> +
<%= row.game_id %> +<%= row.title_name %> +<%= row.scenario %> +<%= row.players.join(", ") %> +<%= row.description %> +<%= row.ctime %> +Join +<% }); %> +
+<% } %> + +<% if (active_games.length > 0) { %> +

Active Games

+ + +
IDGameScenarioPlayersDescriptionChangedTurn +<% active_games.forEach((row) => { %> +
<%= row.game_id %> +<%= row.title_name %> +<%= row.scenario %> +<%= row.players.join(", ") %> +<%= row.description %> +<%= row.mtime %> +<% + if (row.your_turn) { + %><%= row.active %><% + } else { + %><%= row.active %><% + } + if (row.players.reduce((n,p) => n + (p === user.name ? 1 : 0), 0) == 1) { + %>Play<% + } else { + %>Play<% + } +%> +<% }); %> +
+<% } %> + +<% if (finished_games.length > 0) { %> +

Finished Games

+ + +
IDGameScenarioPlayersDescriptionFinishedResult +<% finished_games.forEach((row) => { %> +
<%= row.game_id %> +<%= row.title_name %> +<%= row.scenario %> +<%= row.players.join(", ") %> +<%= row.description %> +<%= row.mtime %> +<%= row.result %> +View +<% }); %> +
+<% } %> + +<% if (open_games.length == 0 && active_games.length == 0 && finished_games.length == 0) { %> +

+You don't have any current or finished games. +<% } %> diff --git a/views/signup.ejs b/views/signup.ejs new file mode 100644 index 0000000..819da3f --- /dev/null +++ b/views/signup.ejs @@ -0,0 +1,18 @@ +<%- include('header', { title: "Signup" }) %> +<% if (user) { %> +

You're already logged in! +<% } else { %> +

+

+
+ +

+
+ +

+
+ +

+ +

+<% } %> diff --git a/views/users.ejs b/views/users.ejs new file mode 100644 index 0000000..a8f5c7d --- /dev/null +++ b/views/users.ejs @@ -0,0 +1,16 @@ +<%- include('header', { title: "User list" }) %> + + + + +
AvatarNameMember sinceLast seen + +<% userList.forEach((row) => { %> +
+<%= row.name %> +<%= row.ctime %> +<%= row.atime %> +<% }); %> -- cgit v1.2.3