From 03bd13309e4e5a1b49fa0b5f4b6901e048b13589 Mon Sep 17 00:00:00 2001 From: Bobloy Date: Wed, 2 May 2018 15:17:19 -0400 Subject: [PATCH] better pages --- werewolf/builder.py | 22 ++++++++++++++-------- werewolf/roles/seer.py | 2 +- werewolf/roles/villager.py | 2 +- werewolf/werewolf.py | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/werewolf/builder.py b/werewolf/builder.py index 572fb9d..5113a0b 100644 --- a/werewolf/builder.py +++ b/werewolf/builder.py @@ -21,7 +21,7 @@ WW_ROLES = [(idx, role) for idx, role in enumerate(ROLE_LIST) if role.alignment OTHER_ROLES = [(idx, role) for idx, role in enumerate(ROLE_LIST) if role.alignment not in [0, 1]] ROLE_PAGES = [] -PAGE_GROUPS = [] +PAGE_GROUPS = [0] ROLE_CATEGORIES = { 1: "Random", 2: "Investigative", 3: "Protective", 4: "Government", @@ -45,9 +45,6 @@ def role_embed(idx, role, color): def setup(): # Roles - if len(ROLE_PAGES) - 1 not in PAGE_GROUPS: - PAGE_GROUPS.append(len(ROLE_PAGES) - 1) - last_alignment = ROLE_LIST[0].alignment for idx, role in enumerate(ROLE_LIST): if role.alignment != last_alignment and len(ROLE_PAGES) - 1 not in PAGE_GROUPS: @@ -61,7 +58,7 @@ def setup(): PAGE_GROUPS.append(len(ROLE_PAGES) - 1) for k, v in ROLE_CATEGORIES.items(): if 0 < k <= 6: - ROLE_PAGES.append(discord.Embed(title="RANDOM Town Role", description="Town {}".format(v), color=0x008000)) + ROLE_PAGES.append(discord.Embed(title="RANDOM:Town Role", description="Town {}".format(v), color=0x008000)) CATEGORY_COUNT.append(k) # Random WW Roles @@ -70,7 +67,7 @@ def setup(): for k, v in ROLE_CATEGORIES.items(): if 10 < k <= 16: ROLE_PAGES.append( - discord.Embed(title="RANDOM Werewolf Role", description="Werewolf {}".format(v), color=0xff0000)) + discord.Embed(title="RANDOM:Werewolf Role", description="Werewolf {}".format(v), color=0xff0000)) CATEGORY_COUNT.append(k) # Random Neutral Roles if len(ROLE_PAGES) - 1 not in PAGE_GROUPS: @@ -78,7 +75,7 @@ def setup(): for k, v in ROLE_CATEGORIES.items(): if 20 < k <= 26: ROLE_PAGES.append( - discord.Embed(title="RANDOM Neutral Role", description="Neutral {}".format(v), color=0xc0c0c0)) + discord.Embed(title="RANDOM:Neutral Role", description="Neutral {}".format(v), color=0xc0c0c0)) CATEGORY_COUNT.append(k) @@ -117,6 +114,7 @@ async def parse_code(code, game): if len(built) < digits: built += c + continue try: idx = int(built) @@ -249,6 +247,14 @@ def say_role_list(code_list, rand_roles): for role in roles: role_dict[str(role.__name__)] += 1 + for role in rand_roles: + if 0 < role <= 6: + role_dict["Town {}".format(ROLE_CATEGORIES[role])] += 1 + if 10 < role <= 16: + role_dict["Werewolf {}".format(ROLE_CATEGORIES[role])] += 1 + if 20 < role <= 26: + role_dict["Neutral {}".format(ROLE_CATEGORIES[role])] += 1 + for k, v in role_dict.items(): embed.add_field(name=k, value="Count: {}".format(v), inline=True) @@ -306,7 +312,7 @@ class GameBuilder: pass if page >= len(ROLE_LIST): - self.rand_roles.append(CATEGORY_COUNT[len(ROLE_LIST) - page]) + self.rand_roles.append(CATEGORY_COUNT[page-len(ROLE_LIST)]) else: self.code.append(page) diff --git a/werewolf/roles/seer.py b/werewolf/roles/seer.py index 7b3fe5d..96260d9 100644 --- a/werewolf/roles/seer.py +++ b/werewolf/roles/seer.py @@ -2,7 +2,7 @@ from werewolf.role import Role class Seer(Role): - rand_choice = False # Determines if it can be picked as a random role (False for unusually disruptive roles) + rand_choice = True # Determines if it can be picked as a random role (False for unusually disruptive roles) category = [1, 2] # List of enrolled categories (listed above) alignment = 1 # 1: Town, 2: Werewolf, 3: Neutral channel_id = "" # Empty for no private channel diff --git a/werewolf/roles/villager.py b/werewolf/roles/villager.py index f1b8016..4935275 100644 --- a/werewolf/roles/villager.py +++ b/werewolf/roles/villager.py @@ -2,7 +2,7 @@ from werewolf.role import Role class Villager(Role): - rand_choice = False # Determines if it can be picked as a random role (False for unusually disruptive roles) + rand_choice = True # Determines if it can be picked as a random role (False for unusually disruptive roles) category = [1] # List of enrolled categories (listed above) alignment = 1 # 1: Town, 2: Werewolf, 3: Neutral channel_id = "" # Empty for no private channel diff --git a/werewolf/werewolf.py b/werewolf/werewolf.py index e513678..97bbede 100644 --- a/werewolf/werewolf.py +++ b/werewolf/werewolf.py @@ -40,7 +40,7 @@ class Werewolf: gb = GameBuilder() code = await gb.build_game(ctx) - if code is not None: + if code != "": await ctx.send("Your game code is **{}**".format(code)) else: await ctx.send("No code generated")