From 5760ea201eb7f967f2d0bc0d424c0bc68315fde9 Mon Sep 17 00:00:00 2001 From: Elnath Date: Tue, 13 Jul 2021 00:27:40 +0200 Subject: [PATCH] Added possibility to add more policies to the deck --- GameFiles/Game.py | 6 ++++++ SecretBot.py | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/GameFiles/Game.py b/GameFiles/Game.py index 0f0e6db..4c1d784 100644 --- a/GameFiles/Game.py +++ b/GameFiles/Game.py @@ -512,6 +512,12 @@ class Game: async def peek_top_3_policies(self) -> List[Policy]: return (await self.peek_deck())[:3] + @game_started + @save_on_success + async def add_to_deck(self, policies: List[Policy]): + self.config["deck"].extend([policy.value for policy in policies]) + random.shuffle(self.config["deck"]) + @game_started @policies_drawn @save_on_success diff --git a/SecretBot.py b/SecretBot.py index c78edce..a26a429 100755 --- a/SecretBot.py +++ b/SecretBot.py @@ -417,6 +417,19 @@ class SecretBot(commands.Cog): else: await ctx.reply(":warning: You should do this in a channel that is hidden from the players!") + @commands.command("AddToDeck", help = "Add additional cards to the deck and shuffle it (discard pile not modified)", usage = f"({Policy.LIBERAL.value}|{Policy.FASCIST.value})+") + async def add_to_deck(self, ctx: commands.Context, *policies_str): + game = await self.get_running_game_or_error_message(ctx) + await self.check_is_administrator_or_gm(ctx) + policies = [] + for policy_str in policies_str: + try: + policies.append(Policy(policy_str.upper())) + except ValueError: + return await ctx.reply(f":x: Can not interpret `{policy_str}` as a policy value. Valid values are {Policy.LIBERAL.value} and {Policy.FASCIST.value}") + await game.add_to_deck(policies) + await ctx.reply(":white_check_mark: Done. Policies have been added to the deck and the deck has been shuffled (the discard pile has not been modified).") + @commands.command("NbToWin", help = "Set the number of policies needed for a win for each faction") async def set_nb_policies_to_win(self, ctx: commands.Context, nb_liberals: int, nb_fascist: int): game = await self.get_running_game_or_error_message(ctx)