From 339a63fe332bcd4413a336955fd35166f85281d7 Mon Sep 17 00:00:00 2001 From: Robert Wall Date: Fri, 28 Jun 2013 19:58:30 -0700 Subject: [PATCH] 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. --- modules/wolfgame.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/wolfgame.py b/modules/wolfgame.py index e3ec1d8..3a3f37f 100644 --- a/modules/wolfgame.py +++ b/modules/wolfgame.py @@ -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))