Added possibility to cancel a legislative phase

This commit is contained in:
Elnath 2021-06-20 21:35:14 +02:00
parent 45afcee8fb
commit a00120d559
2 changed files with 23 additions and 0 deletions

View File

@ -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)]

View File

@ -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)