#! /usr/bin/awk -f function esc(s) { gsub(/&/, "&", s); gsub(//, ">", s); return s; } BEGIN { ngames = 20; getline rounds < "next-round"; 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 " ngames" games only.

"; print "
    "; for (i = rounds - ngames - 1; i > 0 && 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] } } } } for (id in scores) { 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 (s = topscore; s >= 0; s -= 1) { for (id in scores) { if (scores[id] == s) { printf("
  1. # %s (%d points)
  2. \n", color[id], names[id], scores[id]); } } } print "
"; print "

Rounds

"; print " "; while (getline < ENVIRON["NAV_HTML_INC"]) { print; } print " "; print ""; }