Update gauntlets.py
Add record tracking to /gauntlets status embed
This commit is contained in:
parent
c6bf41c280
commit
82cab33718
35
gauntlets.py
35
gauntlets.py
@ -477,7 +477,7 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
|
||||
return final_embed
|
||||
|
||||
|
||||
def get_embed(this_run=None, this_event=None):
|
||||
def get_embed(this_run=None, this_event=None, this_team=None):
|
||||
logging.info(f'get_embed - this_run:\n{this_run}\n\nthis_event:\n{this_event}')
|
||||
|
||||
if this_run is None and this_event is None:
|
||||
@ -496,7 +496,7 @@ def get_embed(this_run=None, this_event=None):
|
||||
|
||||
embed.add_field(name='Event Info', value=this_event['short_desc'], inline=False)
|
||||
if this_run is not None:
|
||||
embed.add_field(name='Record', value=f'{this_run["wins"]}-{this_run["losses"]}', inline=False)
|
||||
embed.add_field(name='Current Record', value=f'{this_run["wins"]}-{this_run["losses"]}', inline=False)
|
||||
|
||||
r_query = db_get('gauntletrewards', params=[('gauntlet_id', this_event['id'])])
|
||||
reward_string = ''
|
||||
@ -517,10 +517,37 @@ def get_embed(this_run=None, this_event=None):
|
||||
elif x['reward']['pack_type']:
|
||||
reward_string += f' {x["reward"]["pack_type"]["name"]} Pack\n'
|
||||
if len(reward_string) > 0:
|
||||
embed.add_field(name='Rewards', value=reward_string, inline=False)
|
||||
embed.add_field(name='Rewards', value=reward_string)
|
||||
|
||||
if this_team is not None:
|
||||
run_query = db_get('gauntletruns', params=[('team_id', this_team['id']), ('gauntlet_id', this_event['id'])])
|
||||
record_name = f'{this_team["abbrev"].split("-")[1]} Record'
|
||||
else:
|
||||
run_query = db_get('gauntletruns', params=[('gauntlet_id', this_event['id'])])
|
||||
record_name = f'League Record'
|
||||
|
||||
record_value = ''
|
||||
if run_query['count'] > 0:
|
||||
max_wins, victories, perfects = 0, 0, 0
|
||||
record_value += f'Attempts: {run_query["count"]}\n'
|
||||
|
||||
for x in run_query['runs']:
|
||||
if x['wins'] > max_wins:
|
||||
max_wins = x['wins']
|
||||
if x['wins'] == 10:
|
||||
victories += 1
|
||||
if x['losses'] == 0:
|
||||
perfects += 1
|
||||
|
||||
if victories > 0:
|
||||
record_value += f'Victories: {victories}\n' \
|
||||
f'10-0 Runs: {perfects}'
|
||||
else:
|
||||
record_value += f'Most Wins: {max_wins}'
|
||||
embed.add_field(name=record_name, value=record_value)
|
||||
|
||||
if this_run is not None:
|
||||
embed.add_field(name='Team Sheet', value=helpers.get_roster_sheet(this_run['team']))
|
||||
embed.add_field(name='Team Sheet', value=helpers.get_roster_sheet(this_run['team']), inline=False)
|
||||
|
||||
return embed
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user