fixed some minor bugs and added !retract
This commit is contained in:
parent
25369f43be
commit
e3a009b65f
43
wolfgame.py
43
wolfgame.py
@ -177,7 +177,7 @@ def stats(cli, nick, chan, rest):
|
||||
message = []
|
||||
for role in ("wolf", "seer", "harlot"):
|
||||
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)))
|
||||
else:
|
||||
message.append("\u0002{0}\u0002 {1}".format(count, role))
|
||||
@ -235,12 +235,12 @@ def chk_decision(cli):
|
||||
@checks
|
||||
@cmd("!votes")
|
||||
def show_votes(cli, nick, chan, rest):
|
||||
if not vars.VOTES.values():
|
||||
cli.msg(chan, nick+": No votes yet.")
|
||||
return
|
||||
elif vars.PHASE != "day":
|
||||
if vars.PHASE != "day":
|
||||
cli.notice(nick, "Voting is only during the day.")
|
||||
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]:
|
||||
cli.msg(chan, (nick+": Tiebreaker conditions. Whoever "+
|
||||
"receives the next vote will be lynched."))
|
||||
@ -448,6 +448,7 @@ def vote(cli, nick, chan, rest):
|
||||
vars.VOTES[voters].remove(nick)
|
||||
if not vars.VOTES[voters] and voters != voted:
|
||||
del vars.VOTES[voters]
|
||||
break
|
||||
if voted not in vars.VOTES.keys():
|
||||
vars.VOTES[voted] = [nick]
|
||||
else:
|
||||
@ -461,6 +462,26 @@ def vote(cli, nick, chan, 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
|
||||
@pmcmd("!kill", "kill")
|
||||
@ -548,6 +569,7 @@ def transition_night(cli):
|
||||
vars.NIGHT_START_TIME = datetime.now()
|
||||
|
||||
daydur_msg = ""
|
||||
|
||||
if vars.NIGHT_TIMEDELTA: # transition from day
|
||||
td = vars.NIGHT_START_TIME - vars.DAY_START_TIME
|
||||
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)
|
||||
|
||||
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:
|
||||
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"]:
|
||||
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")
|
||||
def start(cli, nick, chan, rest):
|
||||
villagers = vars.list_players()
|
||||
|
Loading…
Reference in New Issue
Block a user