tanks/round.sh

60 lines
1.0 KiB
Bash
Raw Normal View History

2010-07-14 16:39:06 -06:00
#! /bin/sh
2010-07-20 20:35:24 -06:00
if [ "$#" -gt 0 ]; then
tanks="$@"
else
echo "Usage: $0 tank1 tank2 [...]"
exit 1
fi
2010-07-14 16:39:06 -06:00
if [ -f next-round ]; then
next=$(cat next-round)
else
next=0
fi
expr $next + 1 > next-round
fn=$(printf "round-%04d.html" $next)
2010-07-20 12:06:33 -06:00
rfn=results$$.txt
2010-07-14 16:39:06 -06:00
echo -n "Running round $next... "
2010-07-20 12:06:33 -06:00
cat <<EOF >$fn
2010-07-14 16:39:06 -06:00
<!DOCTYPE html>
<html>
<head>
<title>Tanks Round $next</title>
<script type="application/javascript" src="tanks.js"></script>
2010-07-20 20:35:24 -06:00
<link rel="stylesheet" href="dirtbags.css" type="text/css">
2010-07-14 16:39:06 -06:00
<script type="application/javascript">
function go() {
2010-07-20 15:39:10 -06:00
start("battlefield",
2010-07-14 16:39:06 -06:00
// Start JSON data
EOF
2010-07-20 20:35:24 -06:00
./run-tanks $tanks >>$fn 3>$rfn
2010-07-20 12:06:33 -06:00
cat <<EOF >>$fn
2010-07-14 16:39:06 -06:00
// end JSON data
);
}
window.onload = go;
</script>
</head>
<body>
2010-07-22 18:08:55 -06:00
<h1>Tanks Round $next</h1>
2010-07-14 16:39:06 -06:00
<div id="game_box"><canvas id="battlefield"></canvas></div>
<p><span id="fps">0</span> fps</p>
2010-07-20 12:06:33 -06:00
EOF
./rank.awk $rfn >>$fn
rm -f $rfn
2010-07-22 18:08:55 -06:00
cat nav.html.inc >>$fn
2010-07-20 12:06:33 -06:00
cat <<EOF >>$fn
2010-07-14 16:39:06 -06:00
</body>
</html>
EOF
2010-07-20 12:06:33 -06:00
2010-07-20 20:35:24 -06:00
./summary.awk $tanks > summary.html
2010-07-20 12:06:33 -06:00
2010-07-14 16:39:06 -06:00
echo "done."