#! /usr/bin/awk -f
function esc(s) {
gsub(/&/, "&", s);
gsub(/, "<", s);
gsub(/>/, ">", s);
return s;
}
BEGIN {
print "";
print "";
print "
";
print " Dirtbags Tanks";
print " ";
print " ";
print " ";
print " Dirtbags Tanks
";
print " Resources
";
print " ";
print " Rankings
";
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";
}
p = 0;
while (1 == getline < (id "/points")) {
p += $0;
}
scores[p] = p;
points[id] = p;
nscores
}
while (1) {
# Find highest score
maxscore = -1;
for (p in scores) {
if (p > maxscore) {
maxscore = p;
}
}
if (maxscore == -1) {
break;
}
delete scores[maxscore];
for (id in points) {
if (points[id] == maxscore) {
printf("- # %s (%d wins)
\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 "
";
print " ";
print "";
}