use embed for tirage resume

This commit is contained in:
ddorn 2020-04-30 00:53:34 +02:00
parent bc4e62c717
commit 3a8f388a94
1 changed files with 35 additions and 11 deletions

View File

@ -54,8 +54,21 @@ class Team(yaml.YAMLObject):
return 2 - 0.5 * (len(self.rejected[round]) - MAX_REFUSE) return 2 - 0.5 * (len(self.rejected[round]) - MAX_REFUSE)
def details(self, round): def details(self, round):
return f"""{self.mention}:
- Accepté: {self.accepted_problems[round]} info = {
# "Accepté": self.accepted_problems[round],
"Refusés": ", ".join(p[0] for p in self.rejected[round])
if self.rejected[round]
else "aucun",
"Coefficient": self.coeff(round),
# "Ordre passage": self.passage_order[round],
}
width = max(map(len, info))
return "\n".join(f"`{n.rjust(width)}`: {v}" for n, v in info.items())
return f""" - Accepté: {self.accepted_problems[round]}
- Refusés: {", ".join(p[0] for p in self.rejected[round]) if self.rejected[round] else "aucun"} - Refusés: {", ".join(p[0] for p in self.rejected[round]) if self.rejected[round] else "aucun"}
- Coefficient: {self.coeff(round)} - Coefficient: {self.coeff(round)}
- Ordre au tirage: {self.tirage_order[round]} - Ordre au tirage: {self.tirage_order[round]}
@ -160,8 +173,7 @@ class Tirage(yaml.YAMLObject):
] ]
async def show(self, ctx): async def show(self, ctx):
teams = ", ".join(team.mention for team in self.teams) teams = ", ".join(team.name for team in self.teams)
msg = f"Voici un résumé du tirage entre les équipes {teams}."
if len(self.teams) == 3: if len(self.teams) == 3:
table = """``` table = """```
@ -192,13 +204,25 @@ class Tirage(yaml.YAMLObject):
+-----+---------+---------+---------+---------+ +-----+---------+---------+---------+---------+
```""" ```"""
await ctx.send(msg) embed = discord.Embed(
for round in (0, 1): title=f"Résumé du tirage entre {teams}", color=EMBED_COLOR
msg = f"\n\n**{ROUND_NAMES[round].capitalize()}**:\n" )
msg += table.format(*self.records(round)) + "\n"
for team in self.teams: for r in (0, 1):
msg += team.details(round) embed.add_field(
await ctx.send(msg) name=ROUND_NAMES[r].capitalize(),
value=table.format(*self.records(r)),
inline=False,
)
for team in in_passage_order(self.teams, r):
embed.add_field(
name=team.name + " - " + team.accepted_problems[r],
value=team.details(r),
inline=True,
)
await ctx.send(embed=embed)
async def show_tex(self, ctx): async def show_tex(self, ctx):
if len(self.teams) == 3: if len(self.teams) == 3: