From b1b753e317daa10e03a6a3b210d185539fac176b Mon Sep 17 00:00:00 2001
From: Tor Andersson <tor@ccxvii.net>
Date: Tue, 12 Sep 2023 23:56:45 +0200
Subject: Calculate Elo ratings.

Primarily for use with future matchmaking system to provide better games for
everyone.

Show top 5 players of each game on the game pages.
---
 views/game_stats.pug | 25 +++++++++++++++++++++++++
 views/user_stats.pug | 34 ++++++++++++++++++++++++----------
 2 files changed, 49 insertions(+), 10 deletions(-)
 create mode 100644 views/game_stats.pug

(limited to 'views')

diff --git a/views/game_stats.pug b/views/game_stats.pug
new file mode 100644
index 0000000..a60d7cb
--- /dev/null
+++ b/views/game_stats.pug
@@ -0,0 +1,25 @@
+//- vim:ts=4:sw=4:
+doctype html
+html
+	head
+		include head
+		title #{title_name} - Ranking
+	body
+		include header
+		article
+			h1 #{title_name} - Ranking
+
+			table(style="min-width:auto")
+				thead
+					tr
+						th Player
+						th.r Rating
+						th.r Plays
+						th.r Last played
+				tbody
+					each row in ratings
+						tr
+							td= row.name
+							td.r= row.rating
+							td.r= row.count
+							td.r= row.last
diff --git a/views/user_stats.pug b/views/user_stats.pug
index a947b64..dee2883 100644
--- a/views/user_stats.pug
+++ b/views/user_stats.pug
@@ -5,12 +5,11 @@ doctype html
 html
 	head
 		include head
-		title Stats for #{who.name}
-		style td:nth-child(n+4){text-align:right}
+		title Statistics for #{who.name}
 	body
 		include header
 		article
-			h1 Stats for #{who.name}
+			h1 Statistics for #{who.name}
 
 			table(style="min-width:auto")
 				thead
@@ -18,8 +17,8 @@ html
 						th Title
 						th Scenario
 						th Role
-						th Played
-						th Won
+						th.r Played
+						th.r Won
 				tbody
 					each row in stats
 						tr
@@ -28,12 +27,27 @@ html
 							td= row.title_name
 							td= row.scenario
 							td= row.role
-							td= row.total
-							td= Math.round(row.won*100/row.total) + "%"
+							td.r= row.total
+							td.r= Math.round(row.won*100/row.total) + "%"
 				tfoot
 					tr
+						td Overall
 						td
 						td
-						td
-						td= all_total
-						td= Math.round(all_won*100/all_total) + "%"
+						td.r= all_total
+						td.r= Math.round(all_won*100/all_total) + "%"
+
+			table(style="min-width:auto")
+				thead
+					tr
+						th Title
+						th.r Rating
+						th.r Plays
+						th.r Last played
+				tbody
+					each row in ratings
+						tr
+							td= row.title_name
+							td.r= row.rating
+							td.r= row.count
+							td.r= row.last
-- 
cgit v1.2.3