Added command for observers and gm to peek at all the deck
This commit is contained in:
parent
ee1619c757
commit
2e7d31ad2a
|
|
@ -163,6 +163,14 @@ class Game:
|
|||
def get_gm_channel(self) -> discord.TextChannel:
|
||||
return self.guild.get_channel(self.get_gm_channel_id())
|
||||
|
||||
@game_started
|
||||
def get_observer_channel_id(self) -> int:
|
||||
return self.config["observer_chan"]
|
||||
|
||||
@game_started
|
||||
def get_observer_channel(self) -> discord.TextChannel:
|
||||
return self.guild.get_channel(self.get_observer_channel_id())
|
||||
|
||||
@game_started
|
||||
def is_vote_running(self) -> bool:
|
||||
return self.config["vote"] is not None
|
||||
|
|
@ -464,8 +472,12 @@ class Game:
|
|||
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)]
|
||||
async def peek_deck(self) -> List[Policy]:
|
||||
return [Policy(policy_code) for policy_code in self.config["deck"]]
|
||||
|
||||
@game_started
|
||||
async def peek_top_3_policies(self) -> List[Policy]:
|
||||
return (await self.peek_deck())[:3]
|
||||
|
||||
@game_started
|
||||
@policies_drawn
|
||||
|
|
|
|||
23
SecretBot.py
23
SecretBot.py
|
|
@ -320,7 +320,7 @@ class SecretBot(commands.Cog):
|
|||
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()])
|
||||
" ".join([":blue_square:" if policy == Policy.LIBERAL else ":red_square:" for policy in await game.peek_top_3_policies()])
|
||||
]
|
||||
await ctx.reply("\n".join(message_content))
|
||||
|
||||
|
|
@ -382,6 +382,27 @@ class SecretBot(commands.Cog):
|
|||
else:
|
||||
await ctx.reply(":x: There is no vote running")
|
||||
|
||||
@commands.command("PeekAll", help = "Show the content of the whole deck, in order")
|
||||
async def peek_all_deck(self, ctx: commands.Context):
|
||||
game = await self.get_running_game_or_error_message(ctx)
|
||||
if ctx.channel in (game.get_observer_channel(), game.get_gm_channel()):
|
||||
policies = await game.peek_deck()
|
||||
policies_text_elements = []
|
||||
for i, policy in enumerate(policies):
|
||||
if policy == Policy.LIBERAL:
|
||||
policies_text_elements.append(":blue_square:")
|
||||
else:
|
||||
policies_text_elements.append(":red_square:")
|
||||
if i % 3 == 2:
|
||||
policies_text_elements.append(" ")
|
||||
message = [
|
||||
":eyes: The deck contains the following policies",
|
||||
f"||{' '.join(policies_text_elements).strip()}||",
|
||||
]
|
||||
await ctx.reply("\n".join(message))
|
||||
else:
|
||||
await ctx.reply(":warning: You should do this in a channel that is hidden from the players!")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
argparser = argparse.ArgumentParser(description = "Secret Hitler helper bot", formatter_class = argparse.ArgumentDefaultsHelpFormatter)
|
||||
|
|
|
|||
Loading…
Reference in New Issue