mirror of https://github.com/dirtbags/tanks.git
Leaderboard working again
This commit is contained in:
parent
37e337a99f
commit
7d495a42a0
1
rank.awk
1
rank.awk
|
@ -75,6 +75,7 @@ END {
|
||||||
printf("<td>" reason[me] "</td>");
|
printf("<td>" reason[me] "</td>");
|
||||||
printf("<td>" lasterr[me] "</td>");
|
printf("<td>" lasterr[me] "</td>");
|
||||||
printf("</tr>\n");
|
printf("</tr>\n");
|
||||||
|
printf("<!-- score " path[me] " " i " -->\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
60
summary.awk
60
summary.awk
|
@ -9,6 +9,7 @@ function esc(s) {
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
ngames = 20;
|
ngames = 20;
|
||||||
|
getline rounds < "next-round";
|
||||||
|
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html>";
|
print "<html>";
|
||||||
|
@ -22,51 +23,39 @@ BEGIN {
|
||||||
print " <p>New here? Read the <a href=\"intro.html\">introduction</a>.</p>";
|
print " <p>New here? Read the <a href=\"intro.html\">introduction</a>.</p>";
|
||||||
print " <p>New round every minute.</p>";
|
print " <p>New round every minute.</p>";
|
||||||
print " <h2>Rankings</h2>";
|
print " <h2>Rankings</h2>";
|
||||||
print " <p>Over the last 20 games only.</p>";
|
print " <p>Over the last " ngames" games only.</p>";
|
||||||
print " <ol>";
|
print " <ol>";
|
||||||
for (i = 1; i < ARGC; i += 1) {
|
for (i = rounds - ngames - 1; i < rounds; i += 1) {
|
||||||
id = ARGV[i];
|
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")) {
|
if (1 == getline < (id "/name")) {
|
||||||
names[id] = esc($0);
|
names[id] = esc($0)
|
||||||
} else {
|
} else {
|
||||||
names[id] = "<i>Unnamed</i>";
|
names[id] = "<i>Unnamed</i>"
|
||||||
}
|
}
|
||||||
|
|
||||||
getline < (id "/color");
|
getline < (id "/color")
|
||||||
if (/^#[0-9A-Fa-f]+$/) {
|
if (/^#[0-9A-Fa-f]+$/) {
|
||||||
color[id] = $0;
|
color[id] = $0
|
||||||
} else {
|
} else {
|
||||||
color[id] = "#c0c0c0";
|
color[id] = "#c0c0c0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (s = topscore; s >= 0; s -= 1) {
|
||||||
for (j = 0; 1 == getline < (id "/points"); j += 1) {
|
for (id in scores) {
|
||||||
pts[id, j % ngames] = int($0);
|
if (scores[id] == s) {
|
||||||
}
|
printf("<li><span class=\"swatch\" style=\"background-color: %s;\">#</span> %s (%d points)</li>\n", color[id], names[id], scores[id]);
|
||||||
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("<li><span class=\"swatch\" style=\"background-color: %s;\">#</span> %s (%d points)</li>\n", color[id], names[id], points[id]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +63,6 @@ BEGIN {
|
||||||
|
|
||||||
print " <h2>Rounds</h2>";
|
print " <h2>Rounds</h2>";
|
||||||
print " <ul>";
|
print " <ul>";
|
||||||
getline rounds < "next-round";
|
|
||||||
for (i = rounds - 1; (i >= rounds - 721) && (i > 0); i -= 1) {
|
for (i = rounds - 1; (i >= rounds - 721) && (i > 0); i -= 1) {
|
||||||
printf("<li><a href=\"round-%04d.html\">%04d</a></li>\n", i, i);
|
printf("<li><a href=\"round-%04d.html\">%04d</a></li>\n", i, i);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue