Command to peek top three cards
This commit is contained in:
parent
ad439faed0
commit
3bc3077de8
|
|
@ -304,9 +304,13 @@ class Game:
|
|||
@game_started
|
||||
@save_on_success
|
||||
async def draw_policies(self) -> List[Policy]:
|
||||
self.config["drawn"] = [self.config["deck"].pop() for _ in range(3)]
|
||||
self.config["drawn"] = [self.config["deck"].pop(0) for _ in range(3)]
|
||||
return [Policy(p) for p in self.config["drawn"]]
|
||||
|
||||
@game_started
|
||||
async def peek_policies(self) -> List[Policy]:
|
||||
return [Policy(self.config["deck"][i]) for i in range(3)]
|
||||
|
||||
@game_started
|
||||
@save_on_success
|
||||
async def enact_drawn_policy(self, index: int):
|
||||
|
|
|
|||
32
SecretBot.py
32
SecretBot.py
|
|
@ -105,6 +105,15 @@ class SecretBot(commands.Cog):
|
|||
await ctx.reply(":x: Game is not running")
|
||||
raise utils.CheckFailDoNotNotify
|
||||
|
||||
@staticmethod
|
||||
async def check_in_admin_channel_or_error_message(ctx: commands.Context, game: Game):
|
||||
"""
|
||||
If the message has not been sent in the game's admin channel, send an error message and raise utils.CheckFailDoNotNotify
|
||||
"""
|
||||
if ctx.channel != game.get_gm_channel():
|
||||
await ctx.reply(":warning: You should do this in the admin channel!")
|
||||
raise utils.CheckFailDoNotNotify
|
||||
|
||||
@commands.command(help = "See if I'm alive")
|
||||
async def ping(self, ctx: commands.Context):
|
||||
await ctx.reply(":ping_pong:", mention_author = True)
|
||||
|
|
@ -174,13 +183,11 @@ class SecretBot(commands.Cog):
|
|||
await game.stop_vote()
|
||||
await ctx.message.delete()
|
||||
|
||||
@commands.command("Legislate")
|
||||
@commands.command("Legislate", help = "Start the legislative session by drawing three policies")
|
||||
async def draw_policies(self, ctx: commands.Context):
|
||||
game = await self.get_running_game_or_error_message(ctx)
|
||||
await self.check_is_administrator_or_gm(ctx)
|
||||
if ctx.channel != game.get_gm_channel():
|
||||
await ctx.reply(":warning: You should do this in your own channel!")
|
||||
return
|
||||
await self.check_in_admin_channel_or_error_message(ctx, game)
|
||||
policies = await game.draw_policies()
|
||||
message_content = [
|
||||
"The following policies have been drawn:",
|
||||
|
|
@ -189,17 +196,26 @@ class SecretBot(commands.Cog):
|
|||
]
|
||||
await ctx.reply("\n".join(message_content))
|
||||
|
||||
@commands.command("Enact")
|
||||
@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)
|
||||
await self.check_is_administrator_or_gm(ctx)
|
||||
if ctx.channel != game.get_gm_channel():
|
||||
await ctx.reply(":warning: You should do this in your own channel!")
|
||||
return
|
||||
await self.check_in_admin_channel_or_error_message(ctx, game)
|
||||
policy_number = policy_number - 1
|
||||
await game.enact_drawn_policy(policy_number)
|
||||
await ctx.reply(":white_check_mark: Done")
|
||||
|
||||
@commands.command("Peek", help = "Look at the top three cards of the deck without drawing them")
|
||||
async def peek_policies(self, ctx: commands.Context):
|
||||
game = await self.get_running_game_or_error_message(ctx)
|
||||
await self.check_is_administrator_or_gm(ctx)
|
||||
await self.check_in_admin_channel_or_error_message(ctx, game)
|
||||
message_content = [
|
||||
"The top three cards of the deck are the following:",
|
||||
" ".join([":blue_square:" if policy == Policy.LIBERAL else ":red_square:" for policy in await game.peek_policies()])
|
||||
]
|
||||
await ctx.reply("\n".join(message_content))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
argparser = argparse.ArgumentParser(description = "Secret Hitler helper bot", formatter_class = argparse.ArgumentDefaultsHelpFormatter)
|
||||
|
|
|
|||
Loading…
Reference in New Issue