Browse Source

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

master
jcao219 13 years ago
parent
commit
ac1194ddbb
  1. 6
      var.py
  2. 21
      wolfgame.py

6
var.py

@ -2,8 +2,8 @@ PING_WAIT = 300 # Seconds @@ -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 ) @@ -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

21
wolfgame.py

@ -218,7 +218,7 @@ def pinger(cli, nick, chan, rest): @@ -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
@ -325,6 +325,8 @@ def join(cli, nick, chan, rest): @@ -325,6 +325,8 @@ def join(cli, nick, chan, rest):
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)
def fjoin(cli, nick, chan, rest):
@ -400,8 +402,7 @@ def stats(cli, nick, chan, rest): @@ -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): @@ -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): @@ -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): @@ -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): @@ -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,7 +2149,7 @@ def show_admins(cli, nick, chan, rest): @@ -2140,7 +2149,7 @@ 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. " +
cli.notice(nick, ("This command is rate-limited. " +
"Please wait a while before using it again."))
return

Loading…
Cancel
Save