add back DISABLED_GAMEMODES

can be used by bot operators to disable & hide a gamemode entirely
This commit is contained in:
jacob1 2016-07-25 00:06:38 -04:00
parent 265a1cc442
commit dc1b1e7f6a
2 changed files with 18 additions and 13 deletions

View File

@ -306,6 +306,9 @@ TEMPLATE_RESTRICTIONS["assassin"] -= {"fallen angel"}
# Roles listed here cannot be used in !fgame roles=blah. If they are defined in ROLE_GUIDE they may still be used. # Roles listed here cannot be used in !fgame roles=blah. If they are defined in ROLE_GUIDE they may still be used.
DISABLED_ROLES = frozenset() DISABLED_ROLES = frozenset()
# Game modes that cannot be randomly picked or voted for
DISABLED_GAMEMODES = frozenset()
GIF_CHANCE = 1/50 GIF_CHANCE = 1/50
FORTUNE_CHANCE = 1/25 FORTUNE_CHANCE = 1/25

View File

@ -7471,7 +7471,7 @@ def start(cli, nick, chan, forced = False, restart = ""):
cgamemode(cli, random.choice(voted)) cgamemode(cli, random.choice(voted))
else: else:
possiblegamemodes = [] possiblegamemodes = []
for gamemode in var.GAME_MODES.keys(): for gamemode in var.GAME_MODES.keys() - var.DISABLED_GAMEMODES:
if len(villagers) >= var.GAME_MODES[gamemode][1] and len(villagers) <= var.GAME_MODES[gamemode][2] and var.GAME_MODES[gamemode][3] > 0: if len(villagers) >= var.GAME_MODES[gamemode][1] and len(villagers) <= var.GAME_MODES[gamemode][2] and var.GAME_MODES[gamemode][3] > 0:
possiblegamemodes += [gamemode]*(var.GAME_MODES[gamemode][3]+votes.get(gamemode, 0)*15) possiblegamemodes += [gamemode]*(var.GAME_MODES[gamemode][3]+votes.get(gamemode, 0)*15)
cgamemode(cli, random.choice(possiblegamemodes)) cgamemode(cli, random.choice(possiblegamemodes))
@ -9048,8 +9048,9 @@ def listroles(cli, nick, chan, rest):
elif rest[0] and not rest[0].isdigit(): elif rest[0] and not rest[0].isdigit():
gamemode = rest[0] gamemode = rest[0]
if gamemode not in var.GAME_MODES.keys(): if gamemode not in var.GAME_MODES.keys():
gamemode, _ = complete_match(rest[0], var.GAME_MODES.keys() - ["roles", "villagergame"]) gamemode, _ = complete_match(rest[0], var.GAME_MODES.keys() - ["roles", "villagergame"] - var.DISABLED_GAMEMODES)
if gamemode in var.GAME_MODES.keys() and gamemode != "roles" and gamemode != "villagergame" and hasattr(var.GAME_MODES[gamemode][0](), "ROLE_GUIDE"): validMode = gamemode in var.GAME_MODES.keys() and gamemode != "roles" and gamemode != "villagergame" and gamemode not in var.DISABLED_GAMEMODES
if validMode and hasattr(var.GAME_MODES[gamemode][0](), "ROLE_GUIDE"):
mode = var.GAME_MODES[gamemode][0]() mode = var.GAME_MODES[gamemode][0]()
if hasattr(mode, "ROLE_INDEX") and hasattr(mode, "ROLE_GUIDE"): if hasattr(mode, "ROLE_INDEX") and hasattr(mode, "ROLE_GUIDE"):
roleindex = mode.ROLE_INDEX roleindex = mode.ROLE_INDEX
@ -9059,7 +9060,7 @@ def listroles(cli, nick, chan, rest):
roleguide = var.ORIGINAL_SETTINGS["ROLE_GUIDE"] roleguide = var.ORIGINAL_SETTINGS["ROLE_GUIDE"]
rest.pop(0) rest.pop(0)
else: else:
if gamemode in var.GAME_MODES and gamemode != "roles" and gamemode != "villagergame" and not hasattr(var.GAME_MODES[gamemode][0](), "ROLE_GUIDE"): if validMode and not hasattr(var.GAME_MODES[gamemode][0](), "ROLE_GUIDE"):
msg.append("{0}: {1}roles is disabled for the {2} game mode.".format(nick, botconfig.CMD_CHAR, gamemode)) msg.append("{0}: {1}roles is disabled for the {2} game mode.".format(nick, botconfig.CMD_CHAR, gamemode))
else: else:
msg.append("{0}: {1} is not a valid game mode.".format(nick, rest[0])) msg.append("{0}: {1} is not a valid game mode.".format(nick, rest[0]))
@ -9354,14 +9355,14 @@ def vote_gamemode(cli, nick, chan, gamemode, doreply):
return return
if gamemode not in var.GAME_MODES.keys(): if gamemode not in var.GAME_MODES.keys():
match, _ = complete_match(gamemode, var.GAME_MODES.keys() - ["roles", "villagergame"]) match, _ = complete_match(gamemode, var.GAME_MODES.keys() - ["roles", "villagergame"] - var.DISABLED_GAMEMODES)
if not match: if not match:
if doreply: if doreply:
cli.notice(nick, messages["invalid_mode_no_list"].format(gamemode)) cli.notice(nick, messages["invalid_mode_no_list"].format(gamemode))
return return
gamemode = match gamemode = match
if gamemode != "roles" and gamemode != "villagergame": if gamemode != "roles" and gamemode != "villagergame" and gamemode not in var.DISABLED_GAMEMODES:
if var.GAMEMODE_VOTES.get(nick) == gamemode: if var.GAMEMODE_VOTES.get(nick) == gamemode:
cli.notice(nick, messages["already_voted_game"].format(gamemode)) cli.notice(nick, messages["already_voted_game"].format(gamemode))
else: else:
@ -9378,7 +9379,8 @@ def game(cli, nick, chan, rest):
vote_gamemode(cli, nick, chan, rest.lower().split()[0], True) vote_gamemode(cli, nick, chan, rest.lower().split()[0], True)
else: else:
gamemodes = ", ".join("\u0002{0}\u0002".format(gamemode) if len(var.list_players()) in range(var.GAME_MODES[gamemode][1], gamemodes = ", ".join("\u0002{0}\u0002".format(gamemode) if len(var.list_players()) in range(var.GAME_MODES[gamemode][1],
var.GAME_MODES[gamemode][2]+1) else gamemode for gamemode in var.GAME_MODES.keys() if gamemode != "roles" and gamemode != "villagergame") var.GAME_MODES[gamemode][2]+1) else gamemode for gamemode in var.GAME_MODES.keys() if gamemode != "roles" and
gamemode != "villagergame" and gamemode not in var.DISABLED_GAMEMODES)
cli.notice(nick, messages["no_mode_specified"] + gamemodes) cli.notice(nick, messages["no_mode_specified"] + gamemodes)
return return
@ -9386,14 +9388,14 @@ def game(cli, nick, chan, rest):
def show_modes(cli, nick, chan, rest): def show_modes(cli, nick, chan, rest):
"""Show the available game modes.""" """Show the available game modes."""
msg = messages["available_modes"] msg = messages["available_modes"]
modes = "\u0002, \u0002".join(sorted(var.GAME_MODES.keys() - {"roles", "villagergame"})) modes = "\u0002, \u0002".join(sorted(var.GAME_MODES.keys() - {"roles", "villagergame"} - var.DISABLED_GAMEMODES))
reply(cli, nick, chan, msg + modes + "\u0002", private=True) reply(cli, nick, chan, msg + modes + "\u0002", private=True)
def game_help(args=""): def game_help(args=""):
return (messages["available_mode_setters_help"] + return (messages["available_mode_setters_help"] +
", ".join("\u0002{0}\u0002".format(gamemode) if len(var.list_players()) in range(var.GAME_MODES[gamemode][1], var.GAME_MODES[gamemode][2]+1) ", ".join("\u0002{0}\u0002".format(gamemode) if len(var.list_players()) in range(var.GAME_MODES[gamemode][1], var.GAME_MODES[gamemode][2]+1)
else gamemode for gamemode in var.GAME_MODES.keys() if gamemode != "roles")) else gamemode for gamemode in var.GAME_MODES.keys() if gamemode != "roles" and gamemodes not in var.DISABLED_GAMEMODES))
game.__doc__ = game_help game.__doc__ = game_help
@ -9693,9 +9695,9 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
gamemode = parts[0] gamemode = parts[0]
modeargs = None modeargs = None
if gamemode not in var.GAME_MODES.keys(): if gamemode not in var.GAME_MODES.keys() - var.DISABLED_GAMEMODES:
gamemode = gamemode.split()[0] gamemode = gamemode.split()[0]
gamemode, _ = complete_match(gamemode, var.GAME_MODES.keys()) gamemode, _ = complete_match(gamemode, var.GAME_MODES.keys() - var.DISABLED_GAMEMODES)
if not gamemode: if not gamemode:
cli.notice(nick, messages["invalid_mode_no_list"].format(rest)) cli.notice(nick, messages["invalid_mode_no_list"].format(rest))
return return
@ -9711,8 +9713,8 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
args = args.strip() args = args.strip()
if not args: if not args:
return messages["available_mode_setters"] + ", ".join(var.GAME_MODES.keys()) return messages["available_mode_setters"] + ", ".join(var.GAME_MODES.keys() - var.DISABLED_GAMEMODES)
elif args in var.GAME_MODES.keys(): elif args in var.GAME_MODES.keys() and args not in var.DISABLED_GAMEMODES:
return var.GAME_MODES[args][0].__doc__ or messages["setter_no_doc"].format(args) return var.GAME_MODES[args][0].__doc__ or messages["setter_no_doc"].format(args)
else: else:
return messages["setter_not_found"].format(args) return messages["setter_not_found"].format(args)