From 4d9ac39e82c50c33916d13e6a744502b48769c77 Mon Sep 17 00:00:00 2001 From: Bobloy Date: Wed, 2 May 2018 14:08:06 -0400 Subject: [PATCH] string roles and other nonsense --- werewolf/builder.py | 10 +++++----- werewolf/game.py | 4 +++- werewolf/werewolf.py | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/werewolf/builder.py b/werewolf/builder.py index 03a84c7..572fb9d 100644 --- a/werewolf/builder.py +++ b/werewolf/builder.py @@ -164,21 +164,21 @@ async def encode(roles, rand_roles): if digit_sort: out_code += "T" for role in digit_sort: - out_code += role + out_code += str(role) # werewolf sort digit_sort = sorted(role for role in rand_roles if 10 < role <= 20) if digit_sort: out_code += "W" for role in digit_sort: - out_code += role + out_code += str(role) # neutral sort digit_sort = sorted(role for role in rand_roles if 20 < role <= 30) if digit_sort: out_code += "N" for role in digit_sort: - out_code += role + out_code += str(role) return out_code @@ -242,7 +242,7 @@ def role_from_name(name: str): for idx, role in enumerate(ROLE_LIST) if name in role.__name__] -def say_role_list(code_list): +def say_role_list(code_list, rand_roles): roles = [ROLE_LIST[idx] for idx in code_list] embed = discord.Embed(title="Currently selected roles") role_dict = defaultdict(int) @@ -290,7 +290,7 @@ class GameBuilder: except discord.NotFound: pass - await ctx.send(embed=say_role_list(self.code)) + await ctx.send(embed=say_role_list(self.code, self.rand_roles)) return await menu(ctx, pages, controls, message=message, page=page, timeout=timeout) diff --git a/werewolf/game.py b/werewolf/game.py index a46d2ce..22d9289 100644 --- a/werewolf/game.py +++ b/werewolf/game.py @@ -150,7 +150,7 @@ class Game: "Grant Bot appropriate permissions or assign a game_channel") return False else: - self.save_perms[self.village_channel] = self.village_channel.overwrites() + self.save_perms[self.village_channel] = self.village_channel.overwrites try: await self.village_channel.edit(name="🔵Werewolf", category=self.channel_category, @@ -790,6 +790,8 @@ class Game: try: await self.village_channel.edit(reason=reason, name="Werewolf") + for target, overwrites in self.save_perms[self.village_channel]: + await self.village_channel.set_permissions(target, overwrite=overwrites, reason=reason) await self.village_channel.set_permissions(self.game_role, overwrite=None, reason=reason) except (discord.HTTPException, discord.NotFound, discord.errors.NotFound): pass diff --git a/werewolf/werewolf.py b/werewolf/werewolf.py index 1f00dbc..e513678 100644 --- a/werewolf/werewolf.py +++ b/werewolf/werewolf.py @@ -387,4 +387,5 @@ class Werewolf: await ctx.send("Log Channel is invalid") return False, None, None, None, None - return True, role, category, channel, log_channel \ No newline at end of file + return True, role, category, channel, log_channel +