fixed the leguin bug, allowed more customization of chances
This commit is contained in:
parent
276ecb53b5
commit
2a324cbc8d
@ -194,16 +194,22 @@ class IRCClient(object):
|
||||
|
||||
for el in data:
|
||||
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,
|
||||
[arg.decode('utf_8')
|
||||
for arg in args
|
||||
if isinstance(arg, bytes)], prefix))
|
||||
fargs, prefix))
|
||||
try:
|
||||
largs = list(args)
|
||||
if prefix is not None:
|
||||
prefix = prefix.decode("utf-8")
|
||||
prefix = prefix.decode(enc)
|
||||
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:
|
||||
self.command_handler[command](self, prefix,*largs)
|
||||
elif "" in self.command_handler:
|
||||
|
3
var.py
3
var.py
@ -16,8 +16,9 @@ GAME_COMMAND_ADMIN_ONLY = True
|
||||
GUN_CHANCES = ( 5/7 , 1/7 , 1/7 )
|
||||
DRUNK_GUN_CHANCES = ( 4/7 , 2/7 , 1/7 )
|
||||
MANSLAUGHTER_CHANCE = 1/5
|
||||
GUN_KILLS_WOLF_CHANCE = 1/2
|
||||
GUNNER_KILLS_WOLF_AT_NIGHT_CHANCE = 1/2
|
||||
GUARDIAN_ANGEL_DIES_CHANCE = 1/2
|
||||
DETECTIVE_REVEALED_CHANCE = 2/5
|
||||
|
||||
GAME_MODES = {}
|
||||
|
||||
|
@ -39,11 +39,7 @@ def main():
|
||||
nickname=botconfig.NICK,
|
||||
connect_cb=wolfgame.connect_callback
|
||||
)
|
||||
try:
|
||||
cli.mainLoop()
|
||||
except Exception as e:
|
||||
cli.msg(botconfig.CHANNEL, "An error has occured: "+str(e))
|
||||
raise e
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -854,7 +854,7 @@ def transition_day(cli, gameid=0):
|
||||
message.append("The wolves' selected victim was a harlot, "+
|
||||
"but she wasn't home.")
|
||||
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"]
|
||||
for crow in wc:
|
||||
if crow in var.OBSERVED.keys():
|
||||
@ -888,7 +888,7 @@ def transition_day(cli, gameid=0):
|
||||
for gangel in var.ROLES["guardian angel"]:
|
||||
if var.GUARDED.get(gangel) in var.ROLES["wolf"]+var.ROLES["werecrow"]:
|
||||
r = random.random()
|
||||
if r < 0.50:
|
||||
if r < var.GUARDIAN_ANGEL_DIES_CHANCE:
|
||||
message.append(("\u0002{0}\u0002, a guardian angel, "+
|
||||
"made the unfortunate mistake of guarding a wolf "+
|
||||
"last night, attempted to escape, but failed "+
|
||||
@ -1212,7 +1212,7 @@ def investigate(cli, nick, rest):
|
||||
var.INVESTIGATED.append(nick)
|
||||
cli.msg(nick, ("The results of your investigation have returned. \u0002{0}\u0002"+
|
||||
" 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!
|
||||
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 "+
|
||||
|
Loading…
Reference in New Issue
Block a user