From 7f0623b4b066b603619ff2c020ab2e8182f107e5 Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Sat, 4 Jul 2015 23:47:23 +0200 Subject: [PATCH] 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. --- src/settings.py | 8 +++++--- src/wolfgame.py | 32 ++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/settings.py b/src/settings.py index bd662a3..64c42ee 100644 --- a/src/settings.py +++ b/src/settings.py @@ -463,10 +463,12 @@ class ChangedRolesMode(GameMode): raise InvalidModeException("The default role must be either \u0002villager\u0002 or \u0002cultist\u0002.") elif role.lower() == "role reveal" or role.lower() == "reveal roles": 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 - elif num == "off" or num == "false" or num == "no" or num == "0": + elif num in ("off", "false", "no", "0"): self.ROLE_REVEAL = False + elif num == "partial": + self.ROLE_REVEAL = "partial" else: raise InvalidModeException("Did not recognize value \u0002{0}\u0002 for role reveal.".format(num)) else: @@ -766,7 +768,7 @@ class RandomMode(GameMode): self.LOVER_WINS_WITH_FOOL = True self.MAD_SCIENTIST_SKIPS_DEAD_PLAYERS = 0 # always make it happen 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.TOTEM_CHANCES = { # shaman , crazed diff --git a/src/wolfgame.py b/src/wolfgame.py index 404bf95..d1a272b 100644 --- a/src/wolfgame.py +++ b/src/wolfgame.py @@ -1236,7 +1236,7 @@ def stats(cli, nick, chan, rest): else: 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 message = [] @@ -6118,8 +6118,16 @@ def start(cli, nick, chan, forced = False, restart = ""): var.LAST_VOTES = None 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 "+ - "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") 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 if rest: - rest = gamemode = rest.strip().lower() - if rest not in var.GAME_MODES.keys() and not rest.startswith("roles"): - rest = rest.split()[0] - gamemode, _ = complete_match(rest, var.GAME_MODES.keys()) + gamemode = rest.strip().lower() + + force_reveal = None + + 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: cli.notice(nick, "\u0002{0}\u0002 is not a valid game mode.".format(rest)) return 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 " "successfully.").format(nick)) var.FGAMED = True