tidied up some edge cases

This commit is contained in:
Sakimori 2021-03-24 23:46:24 -04:00
parent 75101d70f9
commit e146c758cf
3 changed files with 17 additions and 14 deletions

View file

@ -422,6 +422,7 @@ class game(object):
furthest_base, runner = outcome["runners"].pop() #get furthest baserunner
self.bases[furthest_base] = None
outcome["fc_out"] = (runner.name, base_string(furthest_base+1)) #runner thrown out
outcome["runner"] = runner.name
outcome["base"] = furthest_base+1
for index in range(0,len(outcome["runners"])):
base, this_runner = outcome["runners"].pop()
@ -540,6 +541,9 @@ class game(object):
result["defense_team"] = defense_team
result["offense_team"] = offense_team
if "advance" in result.keys() and self.bases[3] is not None:
result["outcome"] = appearance_outcomes.sacrifice
result["runner"] = self.bases[3].name
text_list = getattr(self.voice, result["outcome"].name)
voice_index = random.randrange(0, len(text_list))
result["voiceindex"] = voice_index
@ -601,13 +605,14 @@ class game(object):
if self.outs < 3:
scores_to_add += self.baserunner_check(result["defender"], result)
elif "advance" in result.keys():
elif "advance" in result.keys() or result["outcome"] == appearance_outcomes.sacrifice:
self.get_pitcher().game_stats["outs_pitched"] += 1
self.outs += 1
if self.outs < 3:
if self.bases[3] is not None:
result["runner"] = self.bases[3].name
self.get_batter().game_stats["sacrifices"] += 1
scores_to_add += self.baserunner_check(defender, result)
scores_to_add += self.baserunner_check(result["defender"], result)
elif result["outcome"] == appearance_outcomes.strikeoutlooking or result["outcome"] == appearance_outcomes.strikeoutswinging:
self.get_pitcher().game_stats["outs_pitched"] += 1
@ -627,7 +632,7 @@ class game(object):
if extra_format == "base":
format_list.append(base_string(result["base"]))
elif extra_format == "runner":
format_list.append(result["fc_out"][0])
format_list.append(result["runner"])
self.voice.post_format = []
result["displaytext"] = result["displaytext"].format(*format_list)
@ -694,7 +699,7 @@ class game(object):
def gamestate_update_full(self):
self.play_has_begun = True
attempts = self.thievery_attempts()
if attempts == False:
if attempts == False or "twopart" in self.last_update[0]:
self.last_update = self.batterup()
else:
self.last_update = attempts

View file

@ -18,8 +18,7 @@ class appearance_outcomes(Enum):
class game_strings_base(object):
def __init__(self):
self.intro_counter = 1
post_format = []
self.post_format = []
default_format = ("defender",)
@ -46,7 +45,6 @@ class game_strings_base(object):
no_formats = [strikeoutlooking, strikeoutswinging, doubleplay, walk, single, double, triple, homerun, grandslam]
def activate(self, lastupdate, currentupdate, game):
#try:
if "twopart" in lastupdate:
for key, value in lastupdate.items():
if key != "twopart":
@ -61,7 +59,6 @@ class game_strings_base(object):
})
else:
currentupdate["displaytext"] = f"{currentupdate['batter']} {self.format_gamestring(getattr(self, currentupdate['outcome'].name)[currentupdate['voiceindex']], currentupdate)}"
#pass
def check_for_twopart(self, gamestring):
return gamestring in self.twoparts
@ -80,12 +77,12 @@ class game_strings_base(object):
if string == "defender":
out_list.append(update['defender'].name)
elif string == "base_string":
post_format.append("base")
self.post_format.append("base")
out_list.append("{}")
elif string == "batter":
out_list.append(update['batter'].name)
elif string == "fc_out" or string == "runner":
post_format.append("runner")
self.post_format.append("runner")
out_list.append("{}")
elif string == "defense_team":
out_list.append(update['defense_team'].name)
@ -97,6 +94,7 @@ class TheGoddesses(game_strings_base):
def __init__(self):
self.intro_counter = 4
self.post_format = []
intro = [("💜", "This game is now blessed 💜"), ("🏳️‍⚧️","I'm Sakimori,"), ("🌺", "and i'm xvi! the sim16 goddesses are live and on-site, bringing you today's game."), ("🎆", "Get hyped!!")]

View file

@ -194,14 +194,14 @@ def update_loop():
elif state["update_pause"] != 1 and this_game.play_has_begun:
if "weather_message" in this_game.last_update[0].keys():
if "twopart" in this_game.last_update[0].keys():
state["update_emoji"] = "💬"
elif "weather_message" in this_game.last_update[0].keys():
state["update_emoji"] = this_game.weather.emoji
elif "ishit" in this_game.last_update[0].keys() and this_game.last_update[0]["ishit"]:
state["update_emoji"] = "🏏"
elif "outcome" in this_game.last_update[0].keys() and this_game.last_update[0]["outcome"] == gametext.appearance_outcomes.walk:
state["update_emoji"] = "👟"
elif "twopart" in this_game.last_update[0].keys():
state["update_emoji"] = "💬"
else:
state["update_emoji"] = "🗞"
@ -246,4 +246,4 @@ def update_loop():
state["update_pause"] -= 1
socketio.emit("states_update", game_states)
time.sleep(3)
time.sleep(8)