Better function to announce when a policy is enacted
This commit is contained in:
parent
3bc3077de8
commit
867f7c48eb
|
|
@ -14,6 +14,12 @@ class Policy(Enum):
|
||||||
LIBERAL = "L"
|
LIBERAL = "L"
|
||||||
FASCIST = "F"
|
FASCIST = "F"
|
||||||
|
|
||||||
|
def square_emoji(self):
|
||||||
|
if self == self.LIBERAL:
|
||||||
|
return ":blue_square:"
|
||||||
|
else:
|
||||||
|
return ":red_square:"
|
||||||
|
|
||||||
|
|
||||||
def game_started(func):
|
def game_started(func):
|
||||||
"""
|
"""
|
||||||
|
|
@ -328,5 +334,18 @@ class Game:
|
||||||
self.config["deck"].extend(self.config["discard"])
|
self.config["deck"].extend(self.config["discard"])
|
||||||
self.config["discard"] = []
|
self.config["discard"] = []
|
||||||
random.shuffle(self.config["deck"])
|
random.shuffle(self.config["deck"])
|
||||||
enacted = Policy(self.config["enacted"][-1])
|
await self.announce_latest_enacted_policy()
|
||||||
await self.get_announcements_channel().send(f"{self.get_player_role().mention} A **{enacted.name}** policy has been enacted!")
|
|
||||||
|
@game_started
|
||||||
|
async def announce_latest_enacted_policy(self):
|
||||||
|
last_enacted = Policy(self.config["enacted"][-1])
|
||||||
|
enacted_count = defaultdict(int)
|
||||||
|
for policy_str in self.config["enacted"]:
|
||||||
|
enacted_count[Policy(policy_str)] += 1
|
||||||
|
message_content = [
|
||||||
|
f"{self.get_player_role().mention} A **{last_enacted.name}** policy {last_enacted.square_emoji()} has been enacted!",
|
||||||
|
f"In total, **{enacted_count[Policy.LIBERAL]} {Policy.LIBERAL.name}** policies and **{enacted_count[Policy.FASCIST]} {Policy.FASCIST.name}** policies have been enacted",
|
||||||
|
" ".join([Policy.LIBERAL.square_emoji()]*enacted_count[Policy.LIBERAL] + [":black_small_square:"]*(5-enacted_count[Policy.LIBERAL])),
|
||||||
|
" ".join([Policy.FASCIST.square_emoji()] * enacted_count[Policy.FASCIST] + [":black_small_square:"] * (6 - enacted_count[Policy.FASCIST])),
|
||||||
|
]
|
||||||
|
await self.get_announcements_channel().send("\n".join(message_content), allowed_mentions = discord.AllowedMentions(roles = True))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue