diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-11-25 19:39:21 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2021-11-25 19:41:54 +0100 |
commit | 86848b6cae751439be2946eae563d3fa8caa434c (patch) | |
tree | 24324e1ed177985961479ecd162b34f34f7f3156 /views/stats.pug | |
parent | 4bce77f2c21846baa72161a4a55362c1ed0dd29c (diff) | |
download | server-86848b6cae751439be2946eae563d3fa8caa434c.tar.gz |
Update stat views.
Diffstat (limited to 'views/stats.pug')
-rw-r--r-- | views/stats.pug | 46 |
1 files changed, 17 insertions, 29 deletions
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)) |