From 86848b6cae751439be2946eae563d3fa8caa434c Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 25 Nov 2021 19:39:21 +0100 Subject: Update stat views. --- views/stats.pug | 46 +++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) (limited to 'views/stats.pug') diff --git a/views/stats.pug b/views/stats.pug index 7634048..b6c8673 100644 --- a/views/stats.pug +++ b/views/stats.pug @@ -6,40 +6,28 @@ html title Game Statistics style. table { table-layout: fixed; min-width: auto; } + td:not(:nth-child(1)) { text-align: right; } td:nth-child(1) { width: 240px; } td { width: 100px; } - tr.blank { height: 2rem; border: none; } + tr+tr.blank { height: 2rem; border: none; } body include header article h1 Game Statistics table - - - function total(t,s) { - return stats - .filter(entry => entry.title_id === t && entry.scenario === s) - .reduce((acc, entry) => acc + entry.count, 0); - } - function result(t,s,r) { - let info = stats.find(entry => entry.title_id === t && entry.scenario === s && entry.result === r); - return info ? info.count : 0; - } - each title_name, title_id in title_name_map - unless title_name_map[title_id].hidden - - let scenarios = title_rule_map[title_id].scenarios; - - let roles = title_role_map[title_id].concat(["Draw"]); - tr - th= title_name_map[title_id].title_name - each role in roles - th= role - each scenario in scenarios - - let t = total(title_id, scenario); - tr - td #{scenario} (#{t}) - each role in roles - if t > 0 - -let r = result(title_id, scenario, role); - td= Math.round(r * 100 / t) + "%" - else - td - + - function p(t,r) { return r > 0 ? Math.round(r*100/t) + "%" : "" } + - function drawn(x) { return x.total-(x.r1+x.r2+x.r3+x.r4+x.r5+x.r6+x.r7) } + each row in stats + unless row.scenario tr.blank + tr + th= row.title_name + th= row.r1 + th= row.r2 + th Draw + else + tr + td #{row.scenario} (#{row.total}) + td= p(row.total, row.r1) + td= p(row.total, row.r2) + td= p(row.total, drawn(row)) -- cgit v1.2.3