From 92cd0f5f348430b5ec68d9b48e2c501eff046403 Mon Sep 17 00:00:00 2001 From: xnrand Date: Sat, 1 Feb 2014 19:28:01 +0100 Subject: [PATCH] implement extra wait time for !join i.e. it makes sure that there are at least X seconds of wait time left after a !join. Feb01[18:03:40] +Zazie_Lavender | I think there should be an enforced 10 to 20 second wait after last !join --- modules/wolfgame.py | 13 ++++++++++++- settings/wolfgame.py | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/wolfgame.py b/modules/wolfgame.py index f45c58b..e117ed8 100644 --- a/modules/wolfgame.py +++ b/modules/wolfgame.py @@ -73,6 +73,8 @@ var.illegal_joins = defaultdict(int) var.LOGGER = WolfgameLogger(var.LOG_FILENAME, var.BARE_LOG_FILENAME) +var.JOINED_THIS_GAME = [] # keeps track of who already joined this game at least once (cloaks) + if botconfig.DEBUG_MODE: var.NIGHT_TIME_LIMIT = 0 # 90 var.NIGHT_TIME_WARN = 0 @@ -178,6 +180,8 @@ def reset(cli): var.ROLES = {"person" : []} + var.JOINED_THIS_GAME = [] + reset_settings() dict.clear(var.LAST_SAID_TIME) @@ -414,7 +418,14 @@ def join(cli, nick, chann_, rest): cli.mode(chan, "+v", nick) var.ROLES["person"].append(nick) cli.msg(chan, '\u0002{0}\u0002 has joined the game and raised the number of players to \u0002{1}\u0002.'.format(nick, len(pl) + 1)) - + if not cloak in var.JOINED_THIS_GAME: + # make sure this only happens one + var.JOINED_THIS_GAME.append(cloak) + now = datetime.now() + # make sure there's at least var.WAIT_AFTER_JOIN seconds of wait time left, if not add them + if now + timedelta(seconds=var.WAIT_AFTER_JOIN) > var.CAN_START_TIME: + var.CAN_START_TIME = now + timedelta(seconds=var.WAIT_AFTER_JOIN) + var.LAST_STATS = None # reset diff --git a/settings/wolfgame.py b/settings/wolfgame.py index 830aa3c..52666b6 100644 --- a/settings/wolfgame.py +++ b/settings/wolfgame.py @@ -2,6 +2,7 @@ PING_WAIT = 300 # Seconds PING_MIN_WAIT = 30 # How long !start has to wait after a !ping MINIMUM_WAIT = 60 EXTRA_WAIT = 20 +WAIT_AFTER_JOIN = 10 # Wait at least this many seconds after the last join MAXIMUM_WAITED = 3 # limit for amount of !wait's STATS_RATE_LIMIT = 60 VOTES_RATE_LIMIT = 60