tanks/winner.awk

32 lines
471 B
Awk
Raw Permalink Normal View History

#! /usr/bin/awk -f
BEGIN {
FS = "\t";
}
{
2010-10-26 14:57:17 -06:00
tanks[$1] = $2;
if ($4 == "(nil)") {
p = $1;
} else {
p = $4;
}
score[p] += 1;
2011-02-12 20:31:54 -07:00
if (score[p] == topscore) {
winners += 1;
} else if (score[p] > topscore) {
winners = 1;
topscore = score[p];
}
}
END {
2011-02-12 20:31:54 -07:00
if (winners > 1) {
exit;
}
for (id in tanks) {
if (score[id] == topscore) {
2010-10-26 14:57:17 -06:00
print tanks[id];
}
}
}