Browse Source

cleanup of fgame

master
Jimmy Cao 13 years ago
parent
commit
7fb6b6eb80
  1. 34
      modules/wolfgame.py
  2. 2
      settings/wolfgame.py

34
modules/wolfgame.py

@ -94,7 +94,6 @@ def connect_callback(cli):
var.DEAD = [] var.DEAD = []
var.ORIGINAL_SETTINGS = {} var.ORIGINAL_SETTINGS = {}
var.SETTINGS_CHANGE_REQUESTER = None
var.LAST_SAID_TIME = {} var.LAST_SAID_TIME = {}
@ -138,8 +137,6 @@ def reset_settings():
setattr(var, attr, var.ORIGINAL_SETTINGS[attr]) setattr(var, attr, var.ORIGINAL_SETTINGS[attr])
dict.clear(var.ORIGINAL_SETTINGS) dict.clear(var.ORIGINAL_SETTINGS)
var.SETTINGS_CHANGE_REQUESTER = None
def reset(cli): def reset(cli):
chan = botconfig.CHANNEL chan = botconfig.CHANNEL
@ -2069,6 +2066,9 @@ def transition_night(cli):
def cgamemode(cli, *args): def cgamemode(cli, *args):
chan = botconfig.CHANNEL chan = botconfig.CHANNEL
if var.ORIGINAL_SETTINGS: # needs reset
reset_settings()
for arg in args: for arg in args:
modeargs = arg.split("=", 1) modeargs = arg.split("=", 1)
modeargs[0] = modeargs[0].strip() modeargs[0] = modeargs[0].strip()
@ -2359,7 +2359,10 @@ def get_help(cli, rnick, rest):
nick, mode, user, cloak = parse_nick(rnick) nick, mode, user, cloak = parse_nick(rnick)
fns = [] fns = []
cname = rest.strip().replace(botconfig.CMD_CHAR, "").lower() rest = rest.strip().replace(botconfig.CMD_CHAR, "", 1).lower()
splitted = re.split(" +", rest, 1)
cname = splitted.pop(0)
rest = splitted[0] if splitted else ""
found = False found = False
if cname: if cname:
for c in (COMMANDS,PM_COMMANDS): for c in (COMMANDS,PM_COMMANDS):
@ -2368,8 +2371,11 @@ def get_help(cli, rnick, rest):
for fn in c[cname]: for fn in c[cname]:
if fn.__doc__: if fn.__doc__:
if nick == botconfig.CHANNEL: if nick == botconfig.CHANNEL:
var.LOGGER.logMessage(botconfig.CMD_CHAR+cname+": "+fn.__doc__) var.LOGGER.logMessage(botconfig.CMD_CHAR+cname+": "+fn.__doc__(rest))
cli.msg(nick, botconfig.CMD_CHAR+cname+": "+fn.__doc__) if callable(fn.__doc__):
cli.msg(nick, botconfig.CMD_CHAR+cname+": "+fn.__doc__(rest))
else:
cli.msg(nick, botconfig.CMD_CHAR+cname+": "+fn.__doc__)
return return
else: else:
continue continue
@ -2594,16 +2600,22 @@ if botconfig.DEBUG_MODE:
if nick not in pl: if nick not in pl:
cli.notice(nick, "You're currently not playing.") cli.notice(nick, "You're currently not playing.")
return return
if var.SETTINGS_CHANGE_REQUESTER:
cli.notice(nick, "There is already an existing "+
"settings change request.")
return
rest = rest.strip().lower() rest = rest.strip().lower()
if rest: if rest:
if cgamemode(cli, *re.split(" +",rest)): if cgamemode(cli, *re.split(" +",rest)):
var.SETTINGS_CHANGE_REQUESTER = nick
cli.msg(chan, ("\u0002{0}\u0002 has changed the "+ cli.msg(chan, ("\u0002{0}\u0002 has changed the "+
"game settings successfully.").format(nick)) "game settings successfully.").format(nick))
def fgame_help(args = ""):
args = args.strip()
if not args:
return "Available game mode setters: "+ ", ".join(var.GAME_MODES.keys())
elif args in var.GAME_MODES.keys():
return var.GAME_MODES[args].__doc__
else:
return "Game mode setter {0} not found.".format(args)
game.__doc__ = fgame_help
# DO NOT MAKE THIS A PMCOMMAND ALSO # DO NOT MAKE THIS A PMCOMMAND ALSO

2
settings/wolfgame.py

@ -135,7 +135,7 @@ class Normal(object):
# TODO: implement game modes # TODO: implement game modes
@game_mode("roles") @game_mode("roles")
class ChangedRolesMode(object): class ChangedRolesMode(object):
"""Example: !game roles=wolves:1,seers:0,angels:1""" """Example: !fgame roles=wolves:1,seers:0,angels:1"""
def __init__(self, arg): def __init__(self, arg):
self.ROLES_GUIDE = ROLES_GUIDE.copy() self.ROLES_GUIDE = ROLES_GUIDE.copy()

Loading…
Cancel
Save