From a00120d5595bb77b418ce68a0556325e5c4f97de Mon Sep 17 00:00:00 2001 From: Elnath Date: Sun, 20 Jun 2021 21:35:14 +0200 Subject: [PATCH] Added possibility to cancel a legislative phase --- GameFiles/Game.py | 9 +++++++++ SecretBot.py | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/GameFiles/Game.py b/GameFiles/Game.py index 8229d08..cab386b 100644 --- a/GameFiles/Game.py +++ b/GameFiles/Game.py @@ -457,6 +457,15 @@ class Game: self.config["drawn"] = [self.config["deck"].pop(0) for _ in range(3)] return [Policy(p) for p in self.config["drawn"]] + @game_started + @policies_drawn + @save_on_success + async def cancel_draw(self): + logger.info(f"[{self.guild.name}] Cancelling draw") + new_deck = self.config["drawn"] + self.config["deck"] + self.config["drawn"] = None + self.config["deck"] = new_deck + @game_started async def peek_policies(self) -> List[Policy]: return [Policy(self.config["deck"][i]) for i in range(3)] diff --git a/SecretBot.py b/SecretBot.py index 4a32863..af8c9bb 100755 --- a/SecretBot.py +++ b/SecretBot.py @@ -290,6 +290,20 @@ class SecretBot(commands.Cog): ] await ctx.reply("\n".join(message_content)) + @commands.command("CancelLegislate", help = "Cancel a legislative phase and put the policies back on top of the deck") + async def cancel_legislate_with_confirmation(self, ctx: commands.Context): + await self.check_is_administrator_or_gm(ctx) + await self.confirm_action("Are you sure that you want to cancel the legislative phase?", ctx.channel, self.cancel_legislate(ctx), ctx.message) + + async def cancel_legislate(self, ctx: commands.Context): + game = await self.get_running_game_or_error_message(ctx) + await self.check_is_administrator_or_gm(ctx) + if game.is_legislative_phase(): + await game.cancel_draw() + await ctx.reply(":white_check_mark: The legislative phase has been canceled and the policy cards put on top of the deck") + else: + await ctx.reply(":x: The game is not in a legislative phase") + @commands.command("Enact", help = "Legislative session only: enact one of the previously drawn policies") async def enact_drawn_policy(self, ctx: commands.Context, policy_number: int): game = await self.get_running_game_or_error_message(ctx)