tidied up some edge cases
This commit is contained in:
parent
75101d70f9
commit
e146c758cf
13
games.py
13
games.py
|
@ -422,6 +422,7 @@ class game(object):
|
||||||
furthest_base, runner = outcome["runners"].pop() #get furthest baserunner
|
furthest_base, runner = outcome["runners"].pop() #get furthest baserunner
|
||||||
self.bases[furthest_base] = None
|
self.bases[furthest_base] = None
|
||||||
outcome["fc_out"] = (runner.name, base_string(furthest_base+1)) #runner thrown out
|
outcome["fc_out"] = (runner.name, base_string(furthest_base+1)) #runner thrown out
|
||||||
|
outcome["runner"] = runner.name
|
||||||
outcome["base"] = furthest_base+1
|
outcome["base"] = furthest_base+1
|
||||||
for index in range(0,len(outcome["runners"])):
|
for index in range(0,len(outcome["runners"])):
|
||||||
base, this_runner = outcome["runners"].pop()
|
base, this_runner = outcome["runners"].pop()
|
||||||
|
@ -540,6 +541,9 @@ class game(object):
|
||||||
result["defense_team"] = defense_team
|
result["defense_team"] = defense_team
|
||||||
result["offense_team"] = offense_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)
|
text_list = getattr(self.voice, result["outcome"].name)
|
||||||
voice_index = random.randrange(0, len(text_list))
|
voice_index = random.randrange(0, len(text_list))
|
||||||
result["voiceindex"] = voice_index
|
result["voiceindex"] = voice_index
|
||||||
|
@ -601,13 +605,14 @@ class game(object):
|
||||||
if self.outs < 3:
|
if self.outs < 3:
|
||||||
scores_to_add += self.baserunner_check(result["defender"], result)
|
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.get_pitcher().game_stats["outs_pitched"] += 1
|
||||||
self.outs += 1
|
self.outs += 1
|
||||||
if self.outs < 3:
|
if self.outs < 3:
|
||||||
if self.bases[3] is not None:
|
if self.bases[3] is not None:
|
||||||
|
result["runner"] = self.bases[3].name
|
||||||
self.get_batter().game_stats["sacrifices"] += 1
|
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:
|
elif result["outcome"] == appearance_outcomes.strikeoutlooking or result["outcome"] == appearance_outcomes.strikeoutswinging:
|
||||||
self.get_pitcher().game_stats["outs_pitched"] += 1
|
self.get_pitcher().game_stats["outs_pitched"] += 1
|
||||||
|
@ -627,7 +632,7 @@ class game(object):
|
||||||
if extra_format == "base":
|
if extra_format == "base":
|
||||||
format_list.append(base_string(result["base"]))
|
format_list.append(base_string(result["base"]))
|
||||||
elif extra_format == "runner":
|
elif extra_format == "runner":
|
||||||
format_list.append(result["fc_out"][0])
|
format_list.append(result["runner"])
|
||||||
self.voice.post_format = []
|
self.voice.post_format = []
|
||||||
result["displaytext"] = result["displaytext"].format(*format_list)
|
result["displaytext"] = result["displaytext"].format(*format_list)
|
||||||
|
|
||||||
|
@ -694,7 +699,7 @@ class game(object):
|
||||||
def gamestate_update_full(self):
|
def gamestate_update_full(self):
|
||||||
self.play_has_begun = True
|
self.play_has_begun = True
|
||||||
attempts = self.thievery_attempts()
|
attempts = self.thievery_attempts()
|
||||||
if attempts == False:
|
if attempts == False or "twopart" in self.last_update[0]:
|
||||||
self.last_update = self.batterup()
|
self.last_update = self.batterup()
|
||||||
else:
|
else:
|
||||||
self.last_update = attempts
|
self.last_update = attempts
|
||||||
|
|
10
gametext.py
10
gametext.py
|
@ -18,8 +18,7 @@ class appearance_outcomes(Enum):
|
||||||
class game_strings_base(object):
|
class game_strings_base(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.intro_counter = 1
|
self.intro_counter = 1
|
||||||
|
self.post_format = []
|
||||||
post_format = []
|
|
||||||
|
|
||||||
default_format = ("defender",)
|
default_format = ("defender",)
|
||||||
|
|
||||||
|
@ -46,7 +45,6 @@ class game_strings_base(object):
|
||||||
no_formats = [strikeoutlooking, strikeoutswinging, doubleplay, walk, single, double, triple, homerun, grandslam]
|
no_formats = [strikeoutlooking, strikeoutswinging, doubleplay, walk, single, double, triple, homerun, grandslam]
|
||||||
|
|
||||||
def activate(self, lastupdate, currentupdate, game):
|
def activate(self, lastupdate, currentupdate, game):
|
||||||
#try:
|
|
||||||
if "twopart" in lastupdate:
|
if "twopart" in lastupdate:
|
||||||
for key, value in lastupdate.items():
|
for key, value in lastupdate.items():
|
||||||
if key != "twopart":
|
if key != "twopart":
|
||||||
|
@ -61,7 +59,6 @@ class game_strings_base(object):
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
currentupdate["displaytext"] = f"{currentupdate['batter']} {self.format_gamestring(getattr(self, currentupdate['outcome'].name)[currentupdate['voiceindex']], currentupdate)}"
|
currentupdate["displaytext"] = f"{currentupdate['batter']} {self.format_gamestring(getattr(self, currentupdate['outcome'].name)[currentupdate['voiceindex']], currentupdate)}"
|
||||||
#pass
|
|
||||||
|
|
||||||
def check_for_twopart(self, gamestring):
|
def check_for_twopart(self, gamestring):
|
||||||
return gamestring in self.twoparts
|
return gamestring in self.twoparts
|
||||||
|
@ -80,12 +77,12 @@ class game_strings_base(object):
|
||||||
if string == "defender":
|
if string == "defender":
|
||||||
out_list.append(update['defender'].name)
|
out_list.append(update['defender'].name)
|
||||||
elif string == "base_string":
|
elif string == "base_string":
|
||||||
post_format.append("base")
|
self.post_format.append("base")
|
||||||
out_list.append("{}")
|
out_list.append("{}")
|
||||||
elif string == "batter":
|
elif string == "batter":
|
||||||
out_list.append(update['batter'].name)
|
out_list.append(update['batter'].name)
|
||||||
elif string == "fc_out" or string == "runner":
|
elif string == "fc_out" or string == "runner":
|
||||||
post_format.append("runner")
|
self.post_format.append("runner")
|
||||||
out_list.append("{}")
|
out_list.append("{}")
|
||||||
elif string == "defense_team":
|
elif string == "defense_team":
|
||||||
out_list.append(update['defense_team'].name)
|
out_list.append(update['defense_team'].name)
|
||||||
|
@ -97,6 +94,7 @@ class TheGoddesses(game_strings_base):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.intro_counter = 4
|
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!!")]
|
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!!")]
|
||||||
|
|
||||||
|
|
|
@ -194,14 +194,14 @@ def update_loop():
|
||||||
|
|
||||||
elif state["update_pause"] != 1 and this_game.play_has_begun:
|
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
|
state["update_emoji"] = this_game.weather.emoji
|
||||||
elif "ishit" in this_game.last_update[0].keys() and this_game.last_update[0]["ishit"]:
|
elif "ishit" in this_game.last_update[0].keys() and this_game.last_update[0]["ishit"]:
|
||||||
state["update_emoji"] = "🏏"
|
state["update_emoji"] = "🏏"
|
||||||
elif "outcome" in this_game.last_update[0].keys() and this_game.last_update[0]["outcome"] == gametext.appearance_outcomes.walk:
|
elif "outcome" in this_game.last_update[0].keys() and this_game.last_update[0]["outcome"] == gametext.appearance_outcomes.walk:
|
||||||
state["update_emoji"] = "👟"
|
state["update_emoji"] = "👟"
|
||||||
elif "twopart" in this_game.last_update[0].keys():
|
|
||||||
state["update_emoji"] = "💬"
|
|
||||||
else:
|
else:
|
||||||
state["update_emoji"] = "🗞"
|
state["update_emoji"] = "🗞"
|
||||||
|
|
||||||
|
@ -246,4 +246,4 @@ def update_loop():
|
||||||
state["update_pause"] -= 1
|
state["update_pause"] -= 1
|
||||||
|
|
||||||
socketio.emit("states_update", game_states)
|
socketio.emit("states_update", game_states)
|
||||||
time.sleep(3)
|
time.sleep(8)
|
Loading…
Reference in a new issue