gave half-innings and start of game some room to breathe
This commit is contained in:
parent
14c324c2cb
commit
a1970d6077
51
games.py
51
games.py
|
@ -410,31 +410,34 @@ class game(object):
|
||||||
return self.gamestate_display_full()
|
return self.gamestate_display_full()
|
||||||
|
|
||||||
def gamestate_display_full(self):
|
def gamestate_display_full(self):
|
||||||
punc = ""
|
try:
|
||||||
if self.last_update[0]["defender"] != "":
|
punc = ""
|
||||||
punc = "."
|
if self.last_update[0]["defender"] != "":
|
||||||
if not self.over:
|
punc = "."
|
||||||
if self.top_of_inning:
|
if not self.over:
|
||||||
inningtext = "top"
|
if self.top_of_inning:
|
||||||
|
inningtext = "top"
|
||||||
|
else:
|
||||||
|
inningtext = "bottom"
|
||||||
|
|
||||||
|
updatestring = f"{self.last_update[0]['batter']} {self.last_update[0]['text'].value} {self.last_update[0]['defender']}{punc}\n"
|
||||||
|
|
||||||
|
if self.last_update[1] > 0:
|
||||||
|
updatestring += f"{self.last_update[1]} runs scored!"
|
||||||
|
|
||||||
|
return f"""Last update: {updatestring}
|
||||||
|
|
||||||
|
Score: {self.teams['away'].score} - {self.teams['home'].score}.
|
||||||
|
Current inning: {inningtext} of {self.inning}. {self.outs} outs.
|
||||||
|
Pitcher: {self.get_pitcher().name}
|
||||||
|
Batter: {self.get_batter().name}
|
||||||
|
Bases: 3: {str(self.bases[3])} 2: {str(self.bases[2])} 1: {str(self.bases[1])}
|
||||||
|
"""
|
||||||
else:
|
else:
|
||||||
inningtext = "bottom"
|
return f"""Game over! Final score: **{self.teams['away'].score} - {self.teams['home'].score}**
|
||||||
|
Last update: {self.last_update[0]['batter']} {self.last_update[0]['text'].value} {self.last_update[0]['defender']}{punc}"""
|
||||||
updatestring = f"{self.last_update[0]['batter']} {self.last_update[0]['text'].value} {self.last_update[0]['defender']}{punc}\n"
|
except TypeError:
|
||||||
|
return "Game not started."
|
||||||
if self.last_update[1] > 0:
|
|
||||||
updatestring += f"{self.last_update[1]} runs scored!"
|
|
||||||
|
|
||||||
return f"""Last update: {updatestring}
|
|
||||||
|
|
||||||
Score: {self.teams['away'].score} - {self.teams['home'].score}.
|
|
||||||
Current inning: {inningtext} of {self.inning}. {self.outs} outs.
|
|
||||||
Pitcher: {self.get_pitcher().name}
|
|
||||||
Batter: {self.get_batter().name}
|
|
||||||
Bases: 3: {str(self.bases[3])} 2: {str(self.bases[2])} 1: {str(self.bases[1])}
|
|
||||||
"""
|
|
||||||
else:
|
|
||||||
return f"""Game over! Final score: **{self.teams['away'].score} - {self.teams['home'].score}**
|
|
||||||
Last update: {self.last_update[0]['batter']} {self.last_update[0]['text'].value} {self.last_update[0]['defender']}{punc}"""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -314,29 +314,49 @@ async def watch_game(channel, game):
|
||||||
if game[1]:
|
if game[1]:
|
||||||
use_emoji_names = False
|
use_emoji_names = False
|
||||||
gamesarray.append((newgame,use_emoji_names))
|
gamesarray.append((newgame,use_emoji_names))
|
||||||
|
pause = 0
|
||||||
|
top_of_inning = True
|
||||||
|
|
||||||
|
while not newgame.over or newgame.top_of_inning != top_of_inning:
|
||||||
|
state = newgame.gamestate_display_full()
|
||||||
|
|
||||||
while not newgame.over:
|
|
||||||
state = newgame.gamestate_update_full()
|
|
||||||
punc = ""
|
|
||||||
if newgame.last_update[0]["defender"] != "":
|
|
||||||
punc = "."
|
|
||||||
new_embed = discord.Embed(color=discord.Color.purple(), title=f"{newgame.teams['away'].name} at {newgame.teams['home'].name}")
|
new_embed = discord.Embed(color=discord.Color.purple(), title=f"{newgame.teams['away'].name} at {newgame.teams['home'].name}")
|
||||||
new_embed.add_field(name=newgame.teams['away'].name, value=newgame.teams['away'].score, inline=True)
|
new_embed.add_field(name=newgame.teams['away'].name, value=newgame.teams['away'].score, inline=True)
|
||||||
new_embed.add_field(name=newgame.teams['home'].name, value=newgame.teams['home'].score, inline=True)
|
new_embed.add_field(name=newgame.teams['home'].name, value=newgame.teams['home'].score, inline=True)
|
||||||
if newgame.top_of_inning:
|
if top_of_inning:
|
||||||
new_embed.add_field(name="Inning:", value=f"🔼 {newgame.inning}", inline=True)
|
new_embed.add_field(name="Inning:", value=f"🔼 {newgame.inning}", inline=True)
|
||||||
else:
|
else:
|
||||||
new_embed.add_field(name="Inning:", value=f"🔽 {newgame.inning}", inline=True)
|
new_embed.add_field(name="Inning:", value=f"🔽 {newgame.inning}", inline=True)
|
||||||
new_embed.add_field(name="Outs:", value=f"{str(out_emoji)*newgame.outs+str(in_emoji)*(2-newgame.outs)}", inline=True)
|
new_embed.add_field(name="Outs:", value=f"{str(out_emoji)*newgame.outs+str(in_emoji)*(2-newgame.outs)}", inline=False)
|
||||||
new_embed.add_field(name="Pitcher:", value=newgame.get_pitcher(), inline=False)
|
new_embed.add_field(name="Pitcher:", value=newgame.get_pitcher(), inline=False)
|
||||||
new_embed.add_field(name="Batter:", value=newgame.get_batter(), inline=False)
|
new_embed.add_field(name="Batter:", value=newgame.get_batter(), inline=False)
|
||||||
|
|
||||||
updatestring = f"{newgame.last_update[0]['batter']} {newgame.last_update[0]['text'].value} {newgame.last_update[0]['defender']}{punc} "
|
if state == "Game not started.":
|
||||||
if newgame.last_update[1] > 0:
|
new_embed.add_field(name="🍿", value="Play blall!", inline=False)
|
||||||
updatestring += f"{newgame.last_update[1]} runs scored!"
|
|
||||||
|
|
||||||
new_embed.add_field(name="🏏", value=updatestring, inline=False)
|
elif newgame.top_of_inning != top_of_inning:
|
||||||
|
pause = 2
|
||||||
|
new_embed.set_field_at(4, name="Pitcher:", value="-", inline=False)
|
||||||
|
new_embed.set_field_at(5, name="Batter:", value="-", inline=False)
|
||||||
|
if newgame.top_of_inning:
|
||||||
|
new_embed.set_field_at(2,name="Inning:",value=f"🔽 {newgame.inning-1}")
|
||||||
|
|
||||||
|
if pause == 1:
|
||||||
|
if newgame.top_of_inning:
|
||||||
|
new_embed.add_field(name="🍿", value=f"Top of {newgame.inning}. {newgame.teams['away'].name} batting!", inline=False)
|
||||||
|
else:
|
||||||
|
new_embed.add_field(name="🍿", value=f"Bottom of {newgame.inning}. {newgame.teams['home'].name} batting!", inline=False)
|
||||||
|
|
||||||
|
if pause != 1 and state != "Game not started.":
|
||||||
|
punc = ""
|
||||||
|
if newgame.last_update[0]["defender"] != "":
|
||||||
|
punc = "."
|
||||||
|
|
||||||
|
updatestring = f"{newgame.last_update[0]['batter']} {newgame.last_update[0]['text'].value} {newgame.last_update[0]['defender']}{punc}"
|
||||||
|
if newgame.last_update[1] > 0:
|
||||||
|
updatestring += f"{newgame.last_update[1]} runs scored!"
|
||||||
|
|
||||||
|
new_embed.add_field(name="🏏", value=updatestring, inline=False)
|
||||||
|
|
||||||
basemessage = str(blank_emoji)
|
basemessage = str(blank_emoji)
|
||||||
if newgame.bases[2] is not None:
|
if newgame.bases[2] is not None:
|
||||||
|
@ -359,22 +379,24 @@ async def watch_game(channel, game):
|
||||||
new_embed.add_field(name="Bases:", value=basemessage, inline = False)
|
new_embed.add_field(name="Bases:", value=basemessage, inline = False)
|
||||||
|
|
||||||
await embed.edit(content=None, embed=new_embed)
|
await embed.edit(content=None, embed=new_embed)
|
||||||
await asyncio.sleep(.5)
|
top_of_inning = newgame.top_of_inning
|
||||||
await asyncio.sleep(5)
|
if pause <= 1:
|
||||||
|
newgame.gamestate_update_full()
|
||||||
|
|
||||||
|
pause -= 1
|
||||||
|
await asyncio.sleep(6)
|
||||||
|
|
||||||
punc = ""
|
|
||||||
if newgame.last_update[0]["defender"] != "":
|
|
||||||
punc = "."
|
|
||||||
final_embed = discord.Embed(color=discord.Color.dark_purple(), title=f"{newgame.teams['away'].name} at {newgame.teams['home'].name}")
|
final_embed = discord.Embed(color=discord.Color.dark_purple(), title=f"{newgame.teams['away'].name} at {newgame.teams['home'].name}")
|
||||||
final_embed.add_field(name="Final score:", value=f"{newgame.teams['away'].score} to {newgame.teams['home'].score}")
|
|
||||||
final_embed.add_field(name="Last update:", value=f"{newgame.last_update[0]['batter']} {newgame.last_update[0]['text'].value} {newgame.last_update[0]['defender']}{punc}" )
|
|
||||||
await embed.edit(content=None, embed=final_embed)
|
|
||||||
if newgame.teams['away'].score > newgame.teams['home'].score:
|
|
||||||
await msg_top.edit(content = f"Game over!\n{newgame.teams['away'].name} wins!")
|
|
||||||
else:
|
|
||||||
await msg_top.edit(content = f"Game over!\n{newgame.teams['home'].name} wins!")
|
|
||||||
|
|
||||||
await msg_bot.delete()
|
scorestring = f"{newgame.teams['away'].score} to {newgame.teams['home'].score}\n"
|
||||||
|
if newgame.teams['away'].score > newgame.teams['home'].score:
|
||||||
|
scorestring += f"{newgame.teams['away'].name} wins!"
|
||||||
|
else:
|
||||||
|
scorestring += f"{newgame.teams['home'].name} wins!"
|
||||||
|
|
||||||
|
final_embed.add_field(name="Final score:", value=scorestring)
|
||||||
|
await embed.edit(content=None, embed=final_embed)
|
||||||
|
|
||||||
gamesarray.pop(gamesarray.index((newgame,use_emoji_names))) #cleanup is important!
|
gamesarray.pop(gamesarray.index((newgame,use_emoji_names))) #cleanup is important!
|
||||||
del newgame
|
del newgame
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user