Browse Source

fixed some minor bugs and added !retract

master
jcao219 14 years ago
parent
commit
604da6fb14
  1. 43
      wolfgame.py

43
wolfgame.py

@ -177,7 +177,7 @@ def stats(cli, nick, chan, rest):
message = [] message = []
for role in ("wolf", "seer", "harlot"): for role in ("wolf", "seer", "harlot"):
count = len(vars.ROLES.get(role,[])) count = len(vars.ROLES.get(role,[]))
if count > 1: if count > 1 or count == 0:
message.append("\u0002(0}\u0002 {1}".format(count, vars.plural(role))) message.append("\u0002(0}\u0002 {1}".format(count, vars.plural(role)))
else: else:
message.append("\u0002{0}\u0002 {1}".format(count, role)) message.append("\u0002{0}\u0002 {1}".format(count, role))
@ -235,12 +235,12 @@ def chk_decision(cli):
@checks @checks
@cmd("!votes") @cmd("!votes")
def show_votes(cli, nick, chan, rest): def show_votes(cli, nick, chan, rest):
if not vars.VOTES.values(): if vars.PHASE != "day":
cli.msg(chan, nick+": No votes yet.")
return
elif vars.PHASE != "day":
cli.notice(nick, "Voting is only during the day.") cli.notice(nick, "Voting is only during the day.")
return return
elif not vars.VOTES.values():
cli.msg(chan, nick+": No votes yet.")
return
if None in [x for voter in vars.VOTES.values() for x in voter]: if None in [x for voter in vars.VOTES.values() for x in voter]:
cli.msg(chan, (nick+": Tiebreaker conditions. Whoever "+ cli.msg(chan, (nick+": Tiebreaker conditions. Whoever "+
"receives the next vote will be lynched.")) "receives the next vote will be lynched."))
@ -448,6 +448,7 @@ def vote(cli, nick, chan, rest):
vars.VOTES[voters].remove(nick) vars.VOTES[voters].remove(nick)
if not vars.VOTES[voters] and voters != voted: if not vars.VOTES[voters] and voters != voted:
del vars.VOTES[voters] del vars.VOTES[voters]
break
if voted not in vars.VOTES.keys(): if voted not in vars.VOTES.keys():
vars.VOTES[voted] = [nick] vars.VOTES[voted] = [nick]
else: else:
@ -461,6 +462,26 @@ def vote(cli, nick, chan, rest):
cli.notice(nick, "\u0002{0}\u0002 is currently not playing.".format(rest)) cli.notice(nick, "\u0002{0}\u0002 is currently not playing.".format(rest))
@checks
@cmd("!retract")
def retract(cli, nick, chan, rest):
if vars.PHASE != "day":
cli.notice(nick, ("Lynching is only allowed during the day. "+
"Please wait patiently for morning."))
return
candidates = vars.VOTES.keys()
for voters in list(candidates):
if nick in vars.VOTES[voters]:
vars.VOTES[voters].remove(nick)
if not vars.VOTES[voters]:
del vars.VOTES[voters]
cli.msg(chan, "\u0002{0}\u0002 retracted his/her vote.".format(nick))
break
else:
cli.notice(nick, "You haven't voted yet.")
@checks @checks
@pmcmd("!kill", "kill") @pmcmd("!kill", "kill")
@ -548,6 +569,7 @@ def transition_night(cli):
vars.NIGHT_START_TIME = datetime.now() vars.NIGHT_START_TIME = datetime.now()
daydur_msg = "" daydur_msg = ""
if vars.NIGHT_TIMEDELTA: # transition from day if vars.NIGHT_TIMEDELTA: # transition from day
td = vars.NIGHT_START_TIME - vars.DAY_START_TIME td = vars.NIGHT_START_TIME - vars.DAY_START_TIME
vars.DAY_START_TIME = None vars.DAY_START_TIME = None
@ -556,10 +578,6 @@ def transition_night(cli):
daydur_msg = "Day lasted \u0002{0:0>2}:{1:0>2}. ".format(min,sec) daydur_msg = "Day lasted \u0002{0:0>2}:{1:0>2}. ".format(min,sec)
chan = botconfig.CHANNEL chan = botconfig.CHANNEL
cli.msg(chan, (daydur_msg + "It is now nighttime. All players "+
"check for PMs from me for instructions. "+
"If you did not receive one, simply sit back, "+
"relax, and wait patiently for morning."))
if vars.NIGHT_TIME_LIMIT > 0: if vars.NIGHT_TIME_LIMIT > 0:
t = threading.Timer(vars.NIGHT_TIME_LIMIT, transition_day, [cli]) t = threading.Timer(vars.NIGHT_TIME_LIMIT, transition_day, [cli])
@ -593,6 +611,13 @@ def transition_night(cli):
for d in vars.ROLES["village drunk"]: for d in vars.ROLES["village drunk"]:
cli.msg(d, 'You have been drinking too much! You are the \u0002village drunk\u0002.') cli.msg(d, 'You have been drinking too much! You are the \u0002village drunk\u0002.')
cli.msg(chan, (daydur_msg + "It is now nighttime. All players "+
"check for PMs from me for instructions. "+
"If you did not receive one, simply sit back, "+
"relax, and wait patiently for morning."))
@cmd("!start") @cmd("!start")
def start(cli, nick, chan, rest): def start(cli, nick, chan, rest):
villagers = vars.list_players() villagers = vars.list_players()

Loading…
Cancel
Save