Add a way to conceal roles from certain game modes.

This commit is contained in:
Vgr E.Barry 2015-03-08 15:16:18 -04:00
parent 28f4e0a2dd
commit 868db7cf07
2 changed files with 16 additions and 9 deletions

View File

@ -1396,7 +1396,7 @@ def stats(cli, nick, chan, rest):
else:
cli.notice(nick, msg)
if var.PHASE == "join" or not var.ROLE_REVEAL:
if var.PHASE == "join" or not var.ROLE_REVEAL or var.GAME_MODES[var.CURRENT_GAMEMODE][4]:
return
message = []
@ -6639,17 +6639,21 @@ def listroles(cli, nick, chan, rest):
old[r] = 0
rest = re.split(" +", rest.strip(), 1)
#prepend player count if called without any arguments
if not len(rest[0]) and pl > 0:
if var.GAME_MODES[var.CURRENT_GAMEMODE][4]:
txt += " {0}: {1}roles was disabled for this game mode.".format(nick, botconfig.CMD_CHAR)
rest = []
roleindex = {}
elif not len(rest[0]) and pl > 0:
txt += " {0}: There {1} \u0002{2}\u0002 playing.".format(nick, "is" if pl == 1 else "are", pl)
if var.PHASE in ["night", "day"]:
txt += " Using the {0} game mode.".format(var.CURRENT_GAMEMODE)
#read game mode to get roles for
if len(rest[0]) and not rest[0].isdigit():
elif len(rest[0]) and not rest[0].isdigit():
gamemode = rest[0]
if gamemode not in var.GAME_MODES.keys():
gamemode, _ = complete_match(rest[0], var.GAME_MODES.keys() - ["roles"])
if gamemode in var.GAME_MODES.keys() and gamemode != "roles":
if gamemode in var.GAME_MODES.keys() and gamemode != "roles" and not var.GAME_MODES[gamemode][4]:
mode = var.GAME_MODES[gamemode][0]()
if hasattr(mode, "ROLE_INDEX"):
roleindex = getattr(mode, "ROLE_INDEX")
@ -6657,12 +6661,15 @@ def listroles(cli, nick, chan, rest):
roleguide = getattr(mode, "ROLE_GUIDE")
rest.pop(0)
else:
txt += " {0}: {1} is not a valid game mode.".format(nick, rest[0])
if var.GAME_MODES[gamemode][4]:
txt += " {0}: {1}roles was disabled for this game mode.".format(nick, botconfig.CMD_CHAR)
else:
txt += " {0}: {1} is not a valid game mode.".format(nick, rest[0])
rest = []
roleindex = {}
#number of players to print the game mode for
if len(rest) and rest[0].isdigit():
elif len(rest) and rest[0].isdigit():
index = int(rest[0])
for i in range(len(roleindex)-1, -1, -1):
if roleindex[i] <= index:

View File

@ -382,9 +382,9 @@ def break_long_message(phrases, joinstr = " "):
return message
class InvalidModeException(Exception): pass
def game_mode(name, minp, maxp, likelihood = 0):
def game_mode(name, minp, maxp, likelihood = 0, conceal_roles = False):
def decor(c):
GAME_MODES[name] = (c, minp, maxp, likelihood)
GAME_MODES[name] = (c, minp, maxp, likelihood, conceal_roles)
return c
return decor
@ -690,7 +690,7 @@ class MatchmakerMode(object):
"mad scientist" : [(1 if i >= 18 else 0) for i in self.ROLE_INDEX]
})
@game_mode("random", minp = 8, maxp = 24, likelihood = 0)
@game_mode("random", minp = 8, maxp = 24, likelihood = 0, conceal_roles = True)
class RandomMode(object):
"""Completely random and hidden roles."""
def __init__(self):