mirror of https://github.com/dirtbags/moth.git
Make tanks not award points with 0 players
This commit is contained in:
parent
43295d62cf
commit
2fd441b06f
|
@ -11,7 +11,7 @@ while true; do
|
||||||
|
|
||||||
# If enabled, run tanks
|
# If enabled, run tanks
|
||||||
if ! [ -f var/disabled/tanks ]; then
|
if ! [ -f var/disabled/tanks ]; then
|
||||||
sbin/run-tanks -1 var/tanks
|
sbin/run-tanks --no-barren-points --once var/tanks
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect any new points
|
# Collect any new points
|
||||||
|
@ -21,6 +21,7 @@ while true; do
|
||||||
rm $fn
|
rm $fn
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Update the scoreboard
|
||||||
if [ -f $POINTS ]; then
|
if [ -f $POINTS ]; then
|
||||||
sbin/scoreboard -t www/scoreboard.html -j www/myplot.js < $POINTS
|
sbin/scoreboard -t www/scoreboard.html -j www/myplot.js < $POINTS
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -8,28 +8,27 @@ import time
|
||||||
from ctf import pointscli, teams, paths
|
from ctf import pointscli, teams, paths
|
||||||
from tanks import Pflanzarr
|
from tanks import Pflanzarr
|
||||||
|
|
||||||
MAX_HIST = 30
|
|
||||||
HIST_STEP = 100
|
|
||||||
|
|
||||||
running = True
|
running = True
|
||||||
|
|
||||||
def run_tanks(basedir, turns):
|
def run_tanks(basedir, turns, barren_points=True):
|
||||||
try:
|
try:
|
||||||
p = Pflanzarr.Pflanzarr(basedir)
|
p = Pflanzarr.Pflanzarr(basedir)
|
||||||
p.run(turns)
|
p.run(turns)
|
||||||
winner = p.winner
|
winner = p.winner or teams.house
|
||||||
except Pflanzarr.NotEnoughPlayers:
|
except Pflanzarr.NotEnoughPlayers:
|
||||||
|
if not barren_points:
|
||||||
|
return
|
||||||
winner = teams.house
|
winner = teams.house
|
||||||
pointscli.award('tanks', winner, 1)
|
pointscli.award('tanks', winner, 1)
|
||||||
|
|
||||||
winnerFile = open(os.path.join(basedir, 'winner'),'w')
|
winnerFile = open(os.path.join(basedir, 'winner'),'w')
|
||||||
winnerFile.write(winner or teams.house)
|
winnerFile.write(winner)
|
||||||
winnerFile.close()
|
winnerFile.close()
|
||||||
|
|
||||||
# Fake being a flag, so the most recent winner shows up on the
|
# Fake being a flag, so the most recent winner shows up on the
|
||||||
# scoreboard.
|
# scoreboard.
|
||||||
try:
|
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:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -39,6 +38,9 @@ def main():
|
||||||
parser.add_option('-1', '--once',
|
parser.add_option('-1', '--once',
|
||||||
action='store_true', dest='once',
|
action='store_true', dest='once',
|
||||||
help='Run only 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',
|
parser.add_option('-t', '--max-turns',
|
||||||
type='int', dest='turns', default=500,
|
type='int', dest='turns', default=500,
|
||||||
help='Maximum number of turns per round')
|
help='Maximum number of turns per round')
|
||||||
|
@ -50,7 +52,7 @@ def main():
|
||||||
parser.error('Wrong number of arguments')
|
parser.error('Wrong number of arguments')
|
||||||
|
|
||||||
while running:
|
while running:
|
||||||
run_tanks(args[0], opts.turns)
|
run_tanks(args[0], opts.turns, opts.barren)
|
||||||
if opts.once:
|
if opts.once:
|
||||||
break
|
break
|
||||||
time.sleep(opts.sleep)
|
time.sleep(opts.sleep)
|
||||||
|
|
Loading…
Reference in New Issue