/schedule defaults to current week; weather includes season and time of day

This commit is contained in:
Cal Corum 2025-01-29 22:33:44 -06:00
parent 81933e8329
commit 45fe08c29a
2 changed files with 34 additions and 3 deletions

1
.gitignore vendored
View File

@ -59,3 +59,4 @@ team-rocket*
card-creation/
.dockerignore
docker-compose.yml
venv/

View File

@ -986,6 +986,9 @@ class Players(commands.Cog):
if week_num is not None:
param_list.append(('week', week_num))
if len(param_list) == 1:
param_list.append(('week', current['week']))
g_query = await db_get('games', params=param_list)
if g_query['count'] == 0:
await interaction.edit_original_response(
@ -1141,11 +1144,38 @@ class Players(commands.Cog):
await ctx.send(f'I could not find a weather chart for you.')
team = t_query['teams'][0]
g_query = await db_get('games', params=[('team1_id', team['id']), ('week', current['week'])])
night_str = '\U0001F319 Night'
day_str = '\U0001F31E Day'
is_div_week = current['week'] in [1, 3, 6, 14, 16, 18]
season_str = f'\U0001F3D6 **Summer**'
if current['week'] <= 5:
season_str = f'\U0001F33C **Spring**'
elif current['week'] > 14:
season_str = f'\U0001F342 **Fall**'
d_twenty = random.randint(1, 20)
embed = get_team_embed('Weather Chart', team, thumbnail=False)
embed = get_team_embed('Weather Check', team, thumbnail=False)
embed.set_image(url=team['stadium'])
embed.add_field(name=f'Weather roll for {ctx.author.name}',
value=f'```md\n# {d_twenty}\nDetails:[1d20 ({d_twenty})]\n```')
embed.add_field(name='Season', value=f'{season_str}')
if g_query['count'] > 0:
played_games = sum(1 for g in g_query['games'] if g.get('home_score') is not None)
if played_games in [0, 2] or (played_games == 1 and is_div_week):
time_of_day = night_str
elif played_games in [1, 3]:
time_of_day = day_str
else:
time_of_day = f'{night_str} / {night_str if is_div_week else day_str} / {night_str} / {day_str}'
embed.add_field(name='Time of Day', value=time_of_day)
embed.add_field(
name=f'Weather roll for {ctx.author.name}',
value=f'```md\n# {d_twenty}\nDetails:[1d20 ({d_twenty})]\n```',
inline=False
)
await ctx.send(content=None, embed=embed)