fixed game_watcher, maybe
This commit is contained in:
parent
971444fb4b
commit
9c4eae8ec1
|
@ -792,35 +792,38 @@ async def team_pages(msg, all_teams, search_term=None):
|
||||||
|
|
||||||
async def game_watcher():
|
async def game_watcher():
|
||||||
while True:
|
while True:
|
||||||
this_array = gamesarray.copy()
|
try:
|
||||||
for i in range(0,len(this_array)):
|
this_array = gamesarray.copy()
|
||||||
game, channel, user, key = this_array[i]
|
for i in range(0,len(this_array)):
|
||||||
if game.over and main_controller.master_games_dic[key][1]["end_delay"] <= 2:
|
game, channel, user, key = this_array[i]
|
||||||
title_string = f"{game.teams['away'].name} at {game.teams['home'].name} ended after {game.inning-1} innings"
|
if game.over and main_controller.master_games_dic[key][1]["end_delay"] <= 9:
|
||||||
if (game.inning - 1) > game.max_innings: #if extra innings
|
title_string = f"{game.teams['away'].name} at {game.teams['home'].name} ended after {game.inning-1} innings"
|
||||||
title_string += f" with {game.inning - (game.max_innings+1)} extra innings."
|
if (game.inning - 1) > game.max_innings: #if extra innings
|
||||||
else:
|
title_string += f" with {game.inning - (game.max_innings+1)} extra innings."
|
||||||
title_string += "."
|
else:
|
||||||
|
title_string += "."
|
||||||
|
|
||||||
winning_team = game.teams['home'].name if game.teams['home'].score > game.teams['away'].score else game.teams['away'].name
|
winning_team = game.teams['home'].name if game.teams['home'].score > game.teams['away'].score else game.teams['away'].name
|
||||||
winstring = f"{game.teams['away'].score} to {game.teams['home'].score}\n"
|
winstring = f"{game.teams['away'].score} to {game.teams['home'].score}\n"
|
||||||
if game.victory_lap and winning_team == game.teams['home'].name:
|
if game.victory_lap and winning_team == game.teams['home'].name:
|
||||||
winstring += f"{winning_team} wins with a victory lap!"
|
winstring += f"{winning_team} wins with a victory lap!"
|
||||||
elif winning_team == game.teams['home'].name:
|
elif winning_team == game.teams['home'].name:
|
||||||
winstring += f"{winning_team} wins, shaming {game.teams['away'].name}!"
|
winstring += f"{winning_team} wins, shaming {game.teams['away'].name}!"
|
||||||
else:
|
else:
|
||||||
winstring += f"{winning_team} wins!"
|
winstring += f"{winning_team} wins!"
|
||||||
|
|
||||||
if user is not None:
|
if user is not None:
|
||||||
await channel.send(f"{user.mention}'s game just ended.")
|
await channel.send(f"{user.mention}'s game just ended.")
|
||||||
else:
|
else:
|
||||||
await channel.send("A game started from this channel just ended.")
|
await channel.send("A game started from this channel just ended.")
|
||||||
|
|
||||||
final_embed = discord.Embed(color=discord.Color.dark_purple(), title=title_string)
|
final_embed = discord.Embed(color=discord.Color.dark_purple(), title=title_string)
|
||||||
final_embed.add_field(name="Final score:", value=winstring)
|
final_embed.add_field(name="Final score:", value=winstring)
|
||||||
await channel.send(embed=final_embed)
|
await channel.send(embed=final_embed)
|
||||||
gamesarray.pop(i)
|
gamesarray.pop(i)
|
||||||
break
|
break
|
||||||
|
except:
|
||||||
|
print("something broke in game_watcher")
|
||||||
|
|
||||||
await asyncio.sleep(6)
|
await asyncio.sleep(6)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user