#! /usr/bin/awk -f function esc(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("
  1. # %s (%d points)
  2. \n", color[id], names[id], points[id]); } } } print "
"; print "

Rounds

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