Skip to content

Commit

Permalink
handle mute/unmute party channels
Browse files Browse the repository at this point in the history
  • Loading branch information
huybt22 committed Mar 14, 2024
1 parent 20dc2db commit 25b456b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions game/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,19 @@ def get_voted_list(self, voter_dict):
voted_list.append(voted)
return voted_list

async def handle_party_channel(self, mute=False):
# Mute/Unmute all alive players in config.WEREWOLF_CHANNEL
await asyncio.gather(
*[self.interface.add_user_to_channel(_id, config.WEREWOLF_CHANNEL, is_read=True, is_send=not mute)
for _id, player in self.players.items() if player.is_alive() and isinstance(player, roles.Werewolf)]
)

# Mute/Unmute all alive players in config.COUPLE_CHANNEL
await asyncio.gather(
*[self.interface.add_user_to_channel(_id, config.COUPLE_CHANNEL, is_read=True, is_send=not mute)
for _id, player in self.players.items() if player.is_alive() and _id in self.cupid_dict]
)

async def do_new_daytime_phase(self):
print("do_new_daytime_phase")
self.day += 1
Expand All @@ -564,6 +577,9 @@ async def do_new_daytime_phase(self):
event_name=self.new_moon_mode.get_current_event_name()
)

# Mute all party channels
await self.handle_party_channel(True)

# Unmute all alive players in config.GAMEPLAY_CHANNEL
await asyncio.gather(
*[self.interface.add_user_to_channel(_id, config.GAMEPLAY_CHANNEL, is_read=True, is_send=True)
Expand Down Expand Up @@ -617,6 +633,9 @@ async def do_end_daytime_phase(self):
players_embed_data = text_template.generate_player_list_embed(self.get_all_players(), reveal_role=self.modes.get("reveal_role", False))
await self.interface.send_embed_to_channel(players_embed_data, config.GAMEPLAY_CHANNEL)

# Unmute all party channels
await self.handle_party_channel()

# Mute all players in config.GAMEPLAY_CHANNEL
await asyncio.gather(
*[self.interface.add_user_to_channel(_id, config.GAMEPLAY_CHANNEL, is_read=True, is_send=False)
Expand Down

0 comments on commit 25b456b

Please sign in to comment.