2010-10-26 12:25:27 -06:00
|
|
|
#! /usr/bin/awk -f
|
|
|
|
|
|
|
|
function esc(s) {
|
2014-07-28 14:32:24 -06:00
|
|
|
gsub(/&/, "&", s);
|
|
|
|
gsub(/</, "<", s);
|
|
|
|
gsub(/>/, ">", s);
|
|
|
|
return s;
|
2010-10-26 12:25:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
ngames = 20;
|
2014-07-28 18:45:53 -06:00
|
|
|
getline rounds < "next-round";
|
2010-10-26 12:25:27 -06:00
|
|
|
|
2014-07-28 14:32:24 -06:00
|
|
|
print "<!DOCTYPE html>";
|
|
|
|
print "<html>";
|
|
|
|
print " <head>";
|
|
|
|
print " <title>Dirtbags Tanks</title>";
|
|
|
|
print " <link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">";
|
|
|
|
print " </head>";
|
|
|
|
print " <body>";
|
|
|
|
print " <h1>Dirtbags Tanks</h1>";
|
2010-10-26 12:25:27 -06:00
|
|
|
|
|
|
|
print " <p>New here? Read the <a href=\"intro.html\">introduction</a>.</p>";
|
|
|
|
print " <p>New round every minute.</p>";
|
|
|
|
print " <h2>Rankings</h2>";
|
2014-07-28 18:45:53 -06:00
|
|
|
print " <p>Over the last " ngames" games only.</p>";
|
2010-10-26 12:25:27 -06:00
|
|
|
print " <ol>";
|
2014-07-28 18:45:53 -06:00
|
|
|
for (i = rounds - ngames - 1; i < rounds; i += 1) {
|
|
|
|
fn = sprintf("round-%04d.html", i)
|
|
|
|
while (getline < fn) {
|
|
|
|
if ($2 == "score") {
|
|
|
|
scores[$3] += $4
|
|
|
|
if (scores[$3] > topscore) {
|
|
|
|
topscore = scores[$3]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-10-26 12:25:27 -06:00
|
|
|
|
2014-07-28 18:45:53 -06:00
|
|
|
for (id in scores) {
|
2010-10-26 12:25:27 -06:00
|
|
|
if (1 == getline < (id "/name")) {
|
2014-07-28 18:45:53 -06:00
|
|
|
names[id] = esc($0)
|
2010-10-26 12:25:27 -06:00
|
|
|
} else {
|
2014-07-28 18:45:53 -06:00
|
|
|
names[id] = "<i>Unnamed</i>"
|
2010-10-26 12:25:27 -06:00
|
|
|
}
|
|
|
|
|
2014-07-28 18:45:53 -06:00
|
|
|
getline < (id "/color")
|
2010-10-26 12:25:27 -06:00
|
|
|
if (/^#[0-9A-Fa-f]+$/) {
|
2014-07-28 18:45:53 -06:00
|
|
|
color[id] = $0
|
2010-10-26 12:25:27 -06:00
|
|
|
} else {
|
2014-07-28 18:45:53 -06:00
|
|
|
color[id] = "#c0c0c0"
|
2010-10-26 12:25:27 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-28 18:45:53 -06:00
|
|
|
for (s = topscore; s >= 0; s -= 1) {
|
|
|
|
for (id in scores) {
|
|
|
|
if (scores[id] == s) {
|
|
|
|
printf("<li><span class=\"swatch\" style=\"background-color: %s;\">#</span> %s (%d points)</li>\n", color[id], names[id], scores[id]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-10-26 12:25:27 -06:00
|
|
|
print " </ol>";
|
|
|
|
|
|
|
|
print " <h2>Rounds</h2>";
|
|
|
|
print " <ul>";
|
2014-07-28 14:42:49 -06:00
|
|
|
for (i = rounds - 1; (i >= rounds - 721) && (i > 0); i -= 1) {
|
2010-10-26 12:25:27 -06:00
|
|
|
printf("<li><a href=\"round-%04d.html\">%04d</a></li>\n", i, i);
|
|
|
|
}
|
|
|
|
print " </ul>";
|
|
|
|
|
2014-07-28 14:32:24 -06:00
|
|
|
while (getline < ENVIRON["NAV_HTML_INC"]) {
|
|
|
|
print;
|
|
|
|
}
|
2010-10-26 12:25:27 -06:00
|
|
|
|
2014-07-28 14:32:24 -06:00
|
|
|
print " </body>";
|
|
|
|
print "</html>";
|
2010-10-26 12:25:27 -06:00
|
|
|
}
|