From ac1194ddbb9fc05aef9f96d7908c0ba2edfc7607 Mon Sep 17 00:00:00 2001 From: jcao219 Date: Mon, 8 Aug 2011 15:38:54 -0500 Subject: [PATCH] reset rate-limits for !stats/!votes in certain circumstances. Reduce the rate-limiting for !stats/!votes to 30 sec, and make it impossible for the gunner to kill the wolf at night if he's attacked --- var.py | 6 +++--- wolfgame.py | 23 ++++++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/var.py b/var.py index 1cc77ea..e68317a 100644 --- a/var.py +++ b/var.py @@ -2,8 +2,8 @@ PING_WAIT = 300 # Seconds MINIMUM_WAIT = 60 EXTRA_WAIT = 20 MAXIMUM_WAITED = 2 # limit for amount of !wait's -STATS_RATE_LIMIT = 60 -VOTES_RATE_LIMIT = 60 +STATS_RATE_LIMIT = 30 +VOTES_RATE_LIMIT = 30 ADMINS_RATE_LIMIT = 300 SHOTS_MULTIPLIER = .12 # ceil(shots_multiplier * len_players) = bullets given MAX_PLAYERS = 30 @@ -22,7 +22,7 @@ GUN_CHANCES = ( 5/7 , 1/7 , 1/7 ) DRUNK_GUN_CHANCES = ( 2/7 , 4/7 , 1/7 ) MANSLAUGHTER_CHANCE = 1/5 # ACCIDENTAL HEADSHOT (FATAL) -GUNNER_KILLS_WOLF_AT_NIGHT_CHANCE = 1/2 +GUNNER_KILLS_WOLF_AT_NIGHT_CHANCE = 0 GUARDIAN_ANGEL_DIES_CHANCE = 1/2 DETECTIVE_REVEALED_CHANCE = 2/5 diff --git a/wolfgame.py b/wolfgame.py index 62439e4..7e7ca5a 100644 --- a/wolfgame.py +++ b/wolfgame.py @@ -218,7 +218,7 @@ def pinger(cli, nick, chan, rest): """Pings the channel to get people's attention. Rate-Limited.""" if (var.LAST_PING and var.LAST_PING + timedelta(seconds=var.PING_WAIT) > datetime.now()): - cli.notice(nick, ("This command is ratelimited. " + + cli.notice(nick, ("This command is rate-limited. " + "Please wait a while before using it again.")) return @@ -324,6 +324,8 @@ def join(cli, nick, chan, rest): cli.mode(chan, "+v", nick, nick+"!*@*") var.ROLES["person"].append(nick) cli.msg(chan, '\u0002{0}\u0002 has joined the game.'.format(nick)) + + var.LAST_STATS = None # reset @cmd("fjoin", admin_only=True) @@ -400,8 +402,7 @@ def stats(cli, nick, chan, rest): if (var.LAST_STATS and var.LAST_STATS + timedelta(seconds=var.STATS_RATE_LIMIT) > datetime.now()): - cli.msg(chan, (nick+": This command is ratelimited. " + - "Please wait a while before using it again.")) + cli.msg(chan, nick+": This command is rate-limited.") return var.LAST_STATS = datetime.now() @@ -550,14 +551,14 @@ def show_votes(cli, nick, chan, rest): if (var.LAST_VOTES and var.LAST_VOTES + timedelta(seconds=var.VOTES_RATE_LIMIT) > datetime.now()): - cli.msg(chan, (nick+": This command is ratelimited. " + - "Please wait a while before using it again.")) + cli.msg(chan, nick+": This command is rate-limited.") return var.LAST_VOTES = datetime.now() if not var.VOTES.values(): cli.msg(chan, nick+": No votes yet.") + var.LAST_VOTES = None # reset else: votelist = ["{0}: {1} ({2})".format(votee, len(var.VOTES[votee]), @@ -748,6 +749,10 @@ def del_player(cli, nick, forced_death = False): arg: forced_death = True when lynched or when the seer/wolf both don't act """ t = timetime() # time + + var.LAST_STATS = None # reset + var.LAST_VOTES = None + with var.GRAVEYARD_LOCK: if not var.GAME_ID or var.GAME_ID > t: # either game ended, or a new game has started. @@ -1241,6 +1246,9 @@ def vote(cli, nick, chan, rest): "\u0002{1}\u0002.").format(nick, voted)) var.LOGGER.logMessage("{0} votes for {1}.".format(nick, voted)) var.LOGGER.logBare(voted, "VOTED", nick) + + var.LAST_VOTES = None # reset + chk_decision(cli) elif not rest: cli.notice(nick, "Not enough parameters.") @@ -1273,6 +1281,7 @@ def retract(cli, nick, chan, rest): cli.msg(chan, "\u0002{0}\u0002 retracted his/her vote.".format(nick)) var.LOGGER.logBare(voter, "RETRACT", nick) var.LOGGER.logMessage("{0} retracted his/her vote.".format(nick)) + var.LAST_VOTES = None # reset break else: cli.notice(nick, "You haven't voted yet.") @@ -2140,8 +2149,8 @@ def show_admins(cli, nick, chan, rest): if (var.LAST_ADMINS and var.LAST_ADMINS + timedelta(seconds=var.ADMINS_RATE_LIMIT) > datetime.now()): - cli.notice(chan, (nick+": This command is ratelimited. " + - "Please wait a while before using it again.")) + cli.notice(nick, ("This command is rate-limited. " + + "Please wait a while before using it again.")) return var.LAST_ADMINS = datetime.now()