Clean up var.illegal_joins during !start, fix related !join bug

This patch fixes a bug in !join that caused new entries to be created in
the var.illegal_joins dictionary for every joining player because of a
missing check to see if the player's cloak is in the dictionary at all.

It also adds logic to !start to remove entries from the
var.illegal_joins dict if they currently have a value of 0, since these
entries are no longer relevant.

These changes together make !eval var.illegal_joins far more useful for
getting a list of *just* stasised players.
This commit is contained in:
Robert Wall 2013-06-28 19:58:30 -07:00
parent b0eb5c9f3d
commit 339a63fe33

View File

@ -383,7 +383,7 @@ def join(cli, nick, chann_, rest):
try:
cloak = var.USERS[nick]['cloak']
if cloak is not None and var.illegal_joins[cloak] > 0:
if cloak is not None and cloak in var.illegal_joins and var.illegal_joins[cloak] > 0:
cli.notice(nick, "Sorry, but you are in stasis for {0} games.".format(var.illegal_joins[cloak]))
return
except KeyError:
@ -2447,9 +2447,11 @@ def start(cli, nick, chann_, rest):
else:
transition_day(cli)
for cloak in var.illegal_joins:
for cloak in list(var.illegal_joins.keys()):
if var.illegal_joins[cloak] != 0:
var.illegal_joins[cloak] -= 1
else:
del var.illegal_joins[cloak]
# DEATH TO IDLERS!
reapertimer = threading.Thread(None, reaper, args=(cli,var.GAME_ID))