From 603f955a0019366acfcc9cac422cf9300cd96c0d Mon Sep 17 00:00:00 2001 From: zamabe Date: Mon, 20 Feb 2012 14:49:27 -0600 Subject: [PATCH 1/2] Allow players to join the game after being pinged. Check for and enforce a minimum wait time when ping command is used to avoid leaving players behind after pinging them. --- modules/wolfgame.py | 4 ++++ settings/wolfgame.py | 1 + 2 files changed, 5 insertions(+) diff --git a/modules/wolfgame.py b/modules/wolfgame.py index ea9624a..d89c5b2 100644 --- a/modules/wolfgame.py +++ b/modules/wolfgame.py @@ -272,6 +272,10 @@ def pinger(cli, nick, chan, rest): cli.msg(chan, "PING! "+" ".join(TO_PING)) var.PINGING = False + + minimum = datetime.now() + timedelta(seconds=var.PING_MIN_WAIT) + if var.CAN_START_TIME < minimum: + var.CAN_START_TIME = minimum decorators.unhook(HOOKS, 800) diff --git a/settings/wolfgame.py b/settings/wolfgame.py index ae82349..fcd87f7 100644 --- a/settings/wolfgame.py +++ b/settings/wolfgame.py @@ -1,4 +1,5 @@ PING_WAIT = 300 # Seconds +PING_MIN_WAIT = 30 MINIMUM_WAIT = 60 EXTRA_WAIT = 20 MAXIMUM_WAITED = 2 # limit for amount of !wait's From 6de1e1a2a4e143714631680071e6cc596ebea508 Mon Sep 17 00:00:00 2001 From: zamabe Date: Mon, 20 Feb 2012 14:58:58 -0600 Subject: [PATCH 2/2] Changed behavior of stats command and added a players command. The stats command's behavior has been to ping every person already playing. The solution placed into practice here is to split the more annoying (and frankly, mostly unnecessary) half of the command into a different command for use when actually wanted/needed. --- modules/wolfgame.py | 35 +++++++++++++++++++++++++++++++---- settings/wolfgame.py | 1 + 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/modules/wolfgame.py b/modules/wolfgame.py index d89c5b2..78dac6c 100644 --- a/modules/wolfgame.py +++ b/modules/wolfgame.py @@ -77,6 +77,7 @@ def connect_callback(cli): var.LAST_STATS = None var.LAST_VOTES = None var.LAST_ADMINS = None + var.LAST_PLAYERS = None var.USERS = {} @@ -353,6 +354,7 @@ def join(cli, nick, chan, rest): cli.msg(chan, '\u0002{0}\u0002 has joined the game.'.format(nick)) var.LAST_STATS = None # reset + var.LAST_PLAYERS = None # re/set @cmd("fjoin", admin_only=True) @@ -428,7 +430,7 @@ def on_account(cli, nick, acc): @cmd("stats") def stats(cli, nick, chan, rest): - """Display the player statistics""" + """Display the game statistics""" if var.PHASE == "none": cli.notice(nick, "No game is currently running.") return @@ -446,10 +448,12 @@ def stats(cli, nick, chan, rest): pl.sort(key=lambda x: x.lower()) if len(pl) > 1: - msg = '{0}: \u0002{1}\u0002 players: {2}'.format(nick, - len(pl), ", ".join(pl)) + msg = '{0}: \u0002{1}\u0002 players'.format(nick, len(pl)) else: - msg = '{0}: \u00021\u0002 player: {1}'.format(nick, pl[0]) + msg = '{0}: \u00021\u0002 player'.format(nick) + + if var.PHASE == "join": + msg = msg + ". The game has not started yet." if nick in pl or var.PHASE == "join": cli.msg(chan, msg) @@ -502,6 +506,29 @@ def stats(cli, nick, chan, rest): cli.notice(nick, stats_mssg) +@cmd("players") +def players(cli, nick, chan, rest): + """Display the player statistics""" + if var.PHASE == "none": + cli.notice(nick, "No players have joined.") + return + + if (var.LAST_PLAYERS and + var.LAST_PLAYERS + timedelta(seconds=var.PLAYERS_RATE_LIMIT) > datetime.now()): + cli.msg(chan, nick+": This command is rate-limited.") + return + + var.LAST_PLAYERS = datetime.now() + + pl = var.list_players() + pl.sort(key=lambda x: x.lower()) + if len(pl) > 1: + cli.msg(chan, '{0}: \u0002{1}\u0002 players: {2}'.format(nick, + len(pl), ", ".join(pl))) + else: + cli.msg(chan, '{0}: \u00021\u0002 player: {1}'.format(nick, pl[0])) + + def hurry_up(cli, gameid, change): if var.PHASE != "day": return diff --git a/settings/wolfgame.py b/settings/wolfgame.py index fcd87f7..ead0160 100644 --- a/settings/wolfgame.py +++ b/settings/wolfgame.py @@ -5,6 +5,7 @@ EXTRA_WAIT = 20 MAXIMUM_WAITED = 2 # limit for amount of !wait's STATS_RATE_LIMIT = 15 VOTES_RATE_LIMIT = 15 +PLAYERS_RATE_LIMIT = 45 ADMINS_RATE_LIMIT = 300 SHOTS_MULTIPLIER = .12 # ceil(shots_multiplier * len_players) = bullets given MAX_PLAYERS = 30