From 2fd441b06fe08d5f4a6f41f64fe191197debe698 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Wed, 3 Mar 2010 22:48:45 -0700 Subject: [PATCH] Make tanks not award points with 0 players --- bin/run-ctf | 3 ++- bin/run-tanks | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/bin/run-ctf b/bin/run-ctf index 54be56e..f4a5b14 100755 --- a/bin/run-ctf +++ b/bin/run-ctf @@ -11,7 +11,7 @@ while true; do # If enabled, run tanks if ! [ -f var/disabled/tanks ]; then - sbin/run-tanks -1 var/tanks + sbin/run-tanks --no-barren-points --once var/tanks fi # Collect any new points @@ -21,6 +21,7 @@ while true; do rm $fn done + # Update the scoreboard if [ -f $POINTS ]; then sbin/scoreboard -t www/scoreboard.html -j www/myplot.js < $POINTS fi diff --git a/bin/run-tanks b/bin/run-tanks index e07a49c..2aa64fc 100755 --- a/bin/run-tanks +++ b/bin/run-tanks @@ -8,28 +8,27 @@ import time from ctf import pointscli, teams, paths from tanks import Pflanzarr -MAX_HIST = 30 -HIST_STEP = 100 - running = True -def run_tanks(basedir, turns): +def run_tanks(basedir, turns, barren_points=True): try: p = Pflanzarr.Pflanzarr(basedir) p.run(turns) - winner = p.winner + winner = p.winner or teams.house except Pflanzarr.NotEnoughPlayers: + if not barren_points: + return winner = teams.house pointscli.award('tanks', winner, 1) winnerFile = open(os.path.join(basedir, 'winner'),'w') - winnerFile.write(winner or teams.house) + winnerFile.write(winner) winnerFile.close() # Fake being a flag, so the most recent winner shows up on the # scoreboard. try: - open(os.path.join(paths.VAR, 'flags', 'tanks'), 'w').write(winner or teams.house) + open(os.path.join(paths.VAR, 'flags', 'tanks'), 'w').write(winner) except IOError: pass @@ -39,6 +38,9 @@ def main(): parser.add_option('-1', '--once', action='store_true', dest='once', help='Run only once') + parser.add_option('-b', '--no-barren-points', + action='store_false', dest='barren', default=True, + help="Don't award points if there aren't enough players") parser.add_option('-t', '--max-turns', type='int', dest='turns', default=500, help='Maximum number of turns per round') @@ -50,7 +52,7 @@ def main(): parser.error('Wrong number of arguments') while running: - run_tanks(args[0], opts.turns) + run_tanks(args[0], opts.turns, opts.barren) if opts.once: break time.sleep(opts.sleep)