text tweaks

This commit is contained in:
joe 2021-01-04 21:41:51 -08:00
parent b17d3a3042
commit b76c7de8bc
2 changed files with 9 additions and 9 deletions

View File

@ -119,16 +119,16 @@ class Draft:
return player return player
def get_teams(self): def get_teams(self):
teams = {} teams = []
if self._active_participant != BOOKMARK: if self._active_participant != BOOKMARK:
teams[self._active_participant.handle] = self._active_participant.team teams.append((self._active_participant.handle, self._active_participant.team))
for participant in self._participants: for participant in self._participants:
if participant != BOOKMARK: if participant != BOOKMARK:
teams[participant.handle] = participant.team teams.append((self._active_participant.handle, self._active_participant.team))
return teams return teams
def finish_draft(self): def finish_draft(self):
for handle, team in self.get_teams().items(): for handle, team in self.get_teams():
success = games.save_team(team, int(handle[3:-1])) success = games.save_team(team, int(handle[3:-1]))
if not success: if not success:
raise Exception(f'Error saving team for {handle}') raise Exception(f'Error saving team for {handle}')

View File

@ -639,7 +639,7 @@ top of the list with each mention, teamname, and slogan on a new line (shift+ent
choosing = 'pitcher⚾' if draft.round == DRAFT_ROUNDS else '🏏hitter🏏' choosing = 'pitcher⚾' if draft.round == DRAFT_ROUNDS else '🏏hitter🏏'
await msg.channel.send( await msg.channel.send(
f'Round {draft.round}/{DRAFT_ROUNDS}: {draft.active_drafter}, choose a {choosing} for {draft.active_drafting_team}.', f'Round {draft.round}/{DRAFT_ROUNDS}: {draft.active_drafter}, choose a {choosing} for {draft.active_drafting_team}.',
embed=build_draft_embed(draft.get_draftees()), embed=build_draft_embed(draft.get_draftees(), footer=f"{choosing[0]}You must choose"),
) )
try: try:
draft_message = await self.wait_draft(msg.channel, draft) draft_message = await self.wait_draft(msg.channel, draft)
@ -651,7 +651,7 @@ top of the list with each mention, teamname, and slogan on a new line (shift+ent
except ValueError as e: except ValueError as e:
await msg.channel.send(str(e)) await msg.channel.send(str(e))
for handle, team in draft.get_teams().items(): for handle, team in draft.get_teams():
await msg.channel.send(f'{handle} behold your team', embed=build_team_embed(team)) await msg.channel.send(f'{handle} behold your team', embed=build_team_embed(team))
try: try:
draft.finish_draft() draft.finish_draft()
@ -1147,13 +1147,13 @@ async def team_delete_confirm(channel, team, owner):
return return
def build_draft_embed(names): def build_draft_embed(names, title="The Draft", footer="You must choose"):
embed = discord.Embed(color=discord.Color.purple(), title="The Draft") embed = discord.Embed(color=discord.Color.purple(), title=title)
column_size = 7 column_size = 7
for i in range(0, len(names), column_size): for i in range(0, len(names), column_size):
draft = '\n'.join(names[i:i + column_size]) draft = '\n'.join(names[i:i + column_size])
embed.add_field(name="-", value=draft, inline=True) embed.add_field(name="-", value=draft, inline=True)
embed.set_footer(text="You must choose") embed.set_footer(text=footer)
return embed return embed