#! /usr/bin/awk -f
function esc(s) {
gsub(/&/, "&", s);
gsub(/, "<", s);
gsub(/>/, ">", s);
return s;
}
BEGIN {
ngames = 20;
print "";
print "";
print "
";
print " Dirtbags Tanks";
print " ";
print " ";
print " ";
print " Dirtbags Tanks
";
print " New here? Read the introduction.
";
print " New round every minute.
";
print " Rankings
";
print " Over the last 20 games only.
";
print " ";
for (i = 1; i < ARGC; i += 1) {
id = ARGV[i];
if (1 == getline < (id "/name")) {
names[id] = esc($0);
} else {
names[id] = "Unnamed";
}
getline < (id "/color");
if (/^#[0-9A-Fa-f]+$/) {
color[id] = $0;
} else {
color[id] = "#c0c0c0";
}
for (j = 0; 1 == getline < (id "/points"); j += 1) {
pts[id, j % ngames] = int($0);
}
total = 0;
for (j = 0; j < ngames; j += 1) {
total += pts[id, j];
}
scores[total] = total;
points[id] = total;
}
while (1) {
# Find highest score
maxscore = -1;
for (p in scores) {
if (int(p) > maxscore) {
maxscore = int(p);
}
}
if (maxscore == -1) {
break;
}
delete scores[maxscore];
for (id in points) {
if (points[id] == maxscore) {
printf("- # %s (%d points)
\n", color[id], names[id], points[id]);
}
}
}
print "
";
print " Rounds
";
print " ";
getline rounds < "next-round";
for (i = rounds - 1; i >= 0; i -= 1) {
printf("- %04d
\n", i, i);
}
print "
";
while (getline < ENVIRON["NAV_HTML_INC"]) {
print;
}
print " ";
print "";
}