Browse Source

fixed a bug for detective; players who are just changing host don't quit the game; better error handling

master
jcao219 14 years ago
parent
commit
4286af119d
  1. 1
      oyoyo/client.py
  2. 12
      wolfgame.py

1
oyoyo/client.py

@ -223,6 +223,7 @@ class IRCClient(object):
if self.socket: if self.socket:
logging.info('closing socket') logging.info('closing socket')
self.socket.close() self.socket.close()
raise SystemExit # lets exit
def msg(self, user, msg): def msg(self, user, msg):
for line in msg.split('\n'): for line in msg.split('\n'):
while not self.tokenbucket.consume(1): while not self.tokenbucket.consume(1):

12
wolfgame.py

@ -729,7 +729,9 @@ def on_nick(cli, prefix, nick):
return return
def leave(cli, what, nick): def leave(cli, what, nick, why=""):
if why == botconfig.CHANGING_HOST_QUIT_MESSAGE:
return
if var.PHASE == "none" and what.startswith(botconfig.CMD_CHAR): if var.PHASE == "none" and what.startswith(botconfig.CMD_CHAR):
cli.notice(nick, "No game is currently running.") cli.notice(nick, "No game is currently running.")
return return
@ -757,11 +759,11 @@ def leave(cli, what, nick):
cli.msg(botconfig.CHANNEL, msg) cli.msg(botconfig.CHANNEL, msg)
del_player(cli, nick) del_player(cli, nick)
cmd("leave")(lambda cli, nick, *rest: leave(cli, "!leave", nick)) cmd("leave")(lambda cli, nick, *rest: leave(cli, botconfig.CMD_CHAR+"leave", nick))
cmd("quit")(lambda cli, nick, *rest: leave(cli, "!quit", nick)) cmd("quit")(lambda cli, nick, *rest: leave(cli, botconfig.CMD_CHAR+"quit", nick))
#Functions decorated with hook do not parse the nick by default #Functions decorated with hook do not parse the nick by default
hook("part")(lambda cli, nick, *rest: leave(cli, "part", parse_nick(nick)[0])) hook("part")(lambda cli, nick, *rest: leave(cli, "part", parse_nick(nick)[0]))
hook("quit")(lambda cli, nick, *rest: leave(cli, "quit", parse_nick(nick)[0])) hook("quit")(lambda cli, nick, *rest: leave(cli, "quit", parse_nick(nick)[0], rest[0]))
hook("kick")(lambda cli, nick, *rest: leave(cli, "kick", parse_nick(rest[1])[0])) hook("kick")(lambda cli, nick, *rest: leave(cli, "kick", parse_nick(rest[1])[0]))
@ -1193,7 +1195,7 @@ def investigate(cli, nick, rest):
if random.random() < var.DETECTIVE_REVEALED_CHANCE: # a 2/5 chance (should be changeable in settings) if random.random() < var.DETECTIVE_REVEALED_CHANCE: # a 2/5 chance (should be changeable in settings)
# Reveal his role! # Reveal his role!
for badguy in var.ROLES["wolf"] + var.ROLES["werecrow"] + var.ROLES["traitor"]: for badguy in var.ROLES["wolf"] + var.ROLES["werecrow"] + var.ROLES["traitor"]:
cli.msg(badguy, ("\0002{0}\0002 accidentally drops a paper. The paper reveals "+ cli.msg(badguy, ("\u0002{0}\u0002 accidentally drops a paper. The paper reveals "+
"that (s)he is the detective!").format(nick)) "that (s)he is the detective!").format(nick))

Loading…
Cancel
Save