Add partial role reveal

Roles are revealed upon death, but not shown in !stats.

This will be used for the random game mode with a 50% chance.
The variant used is displayed when the game is started, and
admins can force a specific variant with !fgame.

Also, ignore conceal_roles in !stats, because partial role reveal
handles that now.
This commit is contained in:
nyuszika7h 2015-07-04 23:47:23 +02:00
parent 649649a355
commit 7f0623b4b0
2 changed files with 31 additions and 9 deletions

View File

@ -463,10 +463,12 @@ class ChangedRolesMode(GameMode):
raise InvalidModeException("The default role must be either \u0002villager\u0002 or \u0002cultist\u0002.") raise InvalidModeException("The default role must be either \u0002villager\u0002 or \u0002cultist\u0002.")
elif role.lower() == "role reveal" or role.lower() == "reveal roles": elif role.lower() == "role reveal" or role.lower() == "reveal roles":
num = num.lower() num = num.lower()
if num == "on" or num == "true" or num == "yes" or num == "1": if num in ("on", "true", "yes", "1"):
self.ROLE_REVEAL = True self.ROLE_REVEAL = True
elif num == "off" or num == "false" or num == "no" or num == "0": elif num in ("off", "false", "no", "0"):
self.ROLE_REVEAL = False self.ROLE_REVEAL = False
elif num == "partial":
self.ROLE_REVEAL = "partial"
else: else:
raise InvalidModeException("Did not recognize value \u0002{0}\u0002 for role reveal.".format(num)) raise InvalidModeException("Did not recognize value \u0002{0}\u0002 for role reveal.".format(num))
else: else:
@ -766,7 +768,7 @@ class RandomMode(GameMode):
self.LOVER_WINS_WITH_FOOL = True self.LOVER_WINS_WITH_FOOL = True
self.MAD_SCIENTIST_SKIPS_DEAD_PLAYERS = 0 # always make it happen self.MAD_SCIENTIST_SKIPS_DEAD_PLAYERS = 0 # always make it happen
self.ALPHA_WOLF_NIGHTS = 2 self.ALPHA_WOLF_NIGHTS = 2
self.ROLE_REVEAL = False self.ROLE_REVEAL = random.choice(("partial", False))
self.TEMPLATE_RESTRICTIONS = {template: [] for template in TEMPLATE_RESTRICTIONS} self.TEMPLATE_RESTRICTIONS = {template: [] for template in TEMPLATE_RESTRICTIONS}
self.TOTEM_CHANCES = { # shaman , crazed self.TOTEM_CHANCES = { # shaman , crazed

View File

@ -1236,7 +1236,7 @@ def stats(cli, nick, chan, rest):
else: else:
cli.notice(nick, msg) cli.notice(nick, msg)
if var.PHASE == "join" or not var.ROLE_REVEAL or var.GAME_MODES[var.CURRENT_GAMEMODE.name][4]: if var.PHASE == "join" or var.ROLE_REVEAL is not True:
return return
message = [] message = []
@ -6118,8 +6118,16 @@ def start(cli, nick, chan, forced = False, restart = ""):
var.LAST_VOTES = None var.LAST_VOTES = None
if not restart: if not restart:
gamemode = var.CURRENT_GAMEMODE.name
if gamemode == "random":
if var.ROLE_REVEAL == "partial":
gamemode = "random_reveal"
else:
gamemode = "random_noreveal"
cli.msg(chan, ("{0}: Welcome to Werewolf, the popular detective/social party "+ cli.msg(chan, ("{0}: Welcome to Werewolf, the popular detective/social party "+
"game (a theme of Mafia). Using the \u0002{1}\u0002 game mode.").format(", ".join(pl), var.CURRENT_GAMEMODE.name)) "game (a theme of Mafia). Using the \u0002{1}\u0002 game mode.").format(", ".join(pl), gamemode))
cli.mode(chan, "+m") cli.mode(chan, "+m")
var.ORIGINAL_ROLES = copy.deepcopy(var.ROLES) # Make a copy var.ORIGINAL_ROLES = copy.deepcopy(var.ROLES) # Make a copy
@ -7529,15 +7537,27 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
return return
if rest: if rest:
rest = gamemode = rest.strip().lower() gamemode = rest.strip().lower()
if rest not in var.GAME_MODES.keys() and not rest.startswith("roles"):
rest = rest.split()[0] force_reveal = None
gamemode, _ = complete_match(rest, var.GAME_MODES.keys())
if gamemode == "random_reveal":
gamemode = "random"
force_reveal = "partial"
elif gamemode == "random_noreveal":
gamemode = "random"
force_reveal = False
if gamemode not in var.GAME_MODES.keys() and not gamemode.startswith("roles"):
gamemode = gamemode.split()[0]
gamemode, _ = complete_match(gamemode, var.GAME_MODES.keys())
if not gamemode: if not gamemode:
cli.notice(nick, "\u0002{0}\u0002 is not a valid game mode.".format(rest)) cli.notice(nick, "\u0002{0}\u0002 is not a valid game mode.".format(rest))
return return
if cgamemode(cli, gamemode): if cgamemode(cli, gamemode):
if force_reveal is not None:
var.ROLE_REVEAL = force_reveal
cli.msg(chan, ("\u0002{0}\u0002 has changed the game settings " cli.msg(chan, ("\u0002{0}\u0002 has changed the game settings "
"successfully.").format(nick)) "successfully.").format(nick))
var.FGAMED = True var.FGAMED = True