Browse Source

fixed the leguin bug, allowed more customization of chances

master
jcao219 14 years ago
parent
commit
a1f3adb00f
  1. 16
      oyoyo/client.py
  2. 3
      var.py
  3. 6
      wolfbot.py
  4. 6
      wolfgame.py

16
oyoyo/client.py

@ -194,16 +194,22 @@ class IRCClient(object):
for el in data: for el in data:
prefix, command, args = parse_raw_irc_command(el) prefix, command, args = parse_raw_irc_command(el)
try:
enc = "utf8"
fargs = [arg.decode(enc) for arg in args if isinstance(arg,bytes)]
except UnicodeDecodeError:
enc = "latin1"
fargs = fargs = [arg.decode(enc) for arg in args if isinstance(arg,bytes)]
logging.debug("processCommand ({2}){0}({1})".format(command, logging.debug("processCommand ({2}){0}({1})".format(command,
[arg.decode('utf_8') fargs, prefix))
for arg in args
if isinstance(arg, bytes)], prefix))
try: try:
largs = list(args) largs = list(args)
if prefix is not None: if prefix is not None:
prefix = prefix.decode("utf-8") prefix = prefix.decode(enc)
for i,arg in enumerate(largs): for i,arg in enumerate(largs):
if arg is not None: largs[i] = arg.decode('utf_8') if arg is not None: largs[i] = arg.decode(enc)
if command in self.command_handler: if command in self.command_handler:
self.command_handler[command](self, prefix,*largs) self.command_handler[command](self, prefix,*largs)
elif "" in self.command_handler: elif "" in self.command_handler:

3
var.py

@ -16,8 +16,9 @@ GAME_COMMAND_ADMIN_ONLY = True
GUN_CHANCES = ( 5/7 , 1/7 , 1/7 ) GUN_CHANCES = ( 5/7 , 1/7 , 1/7 )
DRUNK_GUN_CHANCES = ( 4/7 , 2/7 , 1/7 ) DRUNK_GUN_CHANCES = ( 4/7 , 2/7 , 1/7 )
MANSLAUGHTER_CHANCE = 1/5 MANSLAUGHTER_CHANCE = 1/5
GUN_KILLS_WOLF_CHANCE = 1/2 GUNNER_KILLS_WOLF_AT_NIGHT_CHANCE = 1/2
GUARDIAN_ANGEL_DIES_CHANCE = 1/2 GUARDIAN_ANGEL_DIES_CHANCE = 1/2
DETECTIVE_REVEALED_CHANCE = 2/5
GAME_MODES = {} GAME_MODES = {}

6
wolfbot.py

@ -39,11 +39,7 @@ def main():
nickname=botconfig.NICK, nickname=botconfig.NICK,
connect_cb=wolfgame.connect_callback connect_cb=wolfgame.connect_callback
) )
try: cli.mainLoop()
cli.mainLoop()
except Exception as e:
cli.msg(botconfig.CHANNEL, "An error has occured: "+str(e))
raise e
if __name__ == "__main__": if __name__ == "__main__":

6
wolfgame.py

@ -854,7 +854,7 @@ def transition_day(cli, gameid=0):
message.append("The wolves' selected victim was a harlot, "+ message.append("The wolves' selected victim was a harlot, "+
"but she wasn't home.") "but she wasn't home.")
if var.VICTIM in var.GUNNERS.keys() and var.GUNNERS[var.VICTIM]: # victim had bullets! if var.VICTIM in var.GUNNERS.keys() and var.GUNNERS[var.VICTIM]: # victim had bullets!
if random.random() < 0.5: if random.random() < var.GUNNER_KILLS_WOLF_AT_NIGHT_CHANCE:
wc = var.ROLES["werecrow"] wc = var.ROLES["werecrow"]
for crow in wc: for crow in wc:
if crow in var.OBSERVED.keys(): if crow in var.OBSERVED.keys():
@ -888,7 +888,7 @@ def transition_day(cli, gameid=0):
for gangel in var.ROLES["guardian angel"]: for gangel in var.ROLES["guardian angel"]:
if var.GUARDED.get(gangel) in var.ROLES["wolf"]+var.ROLES["werecrow"]: if var.GUARDED.get(gangel) in var.ROLES["wolf"]+var.ROLES["werecrow"]:
r = random.random() r = random.random()
if r < 0.50: if r < var.GUARDIAN_ANGEL_DIES_CHANCE:
message.append(("\u0002{0}\u0002, a guardian angel, "+ message.append(("\u0002{0}\u0002, a guardian angel, "+
"made the unfortunate mistake of guarding a wolf "+ "made the unfortunate mistake of guarding a wolf "+
"last night, attempted to escape, but failed "+ "last night, attempted to escape, but failed "+
@ -1212,7 +1212,7 @@ def investigate(cli, nick, rest):
var.INVESTIGATED.append(nick) var.INVESTIGATED.append(nick)
cli.msg(nick, ("The results of your investigation have returned. \u0002{0}\u0002"+ cli.msg(nick, ("The results of your investigation have returned. \u0002{0}\u0002"+
" is a... \u0002{1}\u0002!").format(victim, var.get_role(victim))) " is a... \u0002{1}\u0002!").format(victim, var.get_role(victim)))
if random.random() < 0.4: # 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, ("\0002{0}\0002 accidentally drops a paper. The paper reveals "+

Loading…
Cancel
Save