maybe fixed the weird crashes from bad text idk
This commit is contained in:
parent
8c47509c6c
commit
806a2e2700
69
gametext.py
69
gametext.py
|
@ -51,20 +51,23 @@ 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):
|
||||||
if "twopart" in lastupdate:
|
try:
|
||||||
for key, value in lastupdate.items():
|
if "twopart" in lastupdate:
|
||||||
if key != "twopart":
|
for key, value in lastupdate.items():
|
||||||
currentupdate[key] = value
|
if key != "twopart":
|
||||||
currentupdate["displaytext"] = self.format_gamestring(getattr(self, currentupdate["outcome"].name)[currentupdate["voiceindex"]][1], currentupdate)
|
currentupdate[key] = value
|
||||||
|
currentupdate["displaytext"] = self.format_gamestring(getattr(self, currentupdate["outcome"].name)[currentupdate["voiceindex"]][1], currentupdate)
|
||||||
|
|
||||||
elif "outcome" in currentupdate:
|
elif "outcome" in currentupdate:
|
||||||
if self.check_for_twopart(getattr(self, currentupdate["outcome"].name)[currentupdate["voiceindex"]]):
|
if self.check_for_twopart(getattr(self, currentupdate["outcome"].name)[currentupdate["voiceindex"]]):
|
||||||
currentupdate.update({
|
currentupdate.update({
|
||||||
"twopart": True,
|
"twopart": True,
|
||||||
"displaytext": f"{currentupdate['batter']} {self.format_gamestring(getattr(self, currentupdate['outcome'].name)[currentupdate['voiceindex']][0], currentupdate)}"
|
"displaytext": f"{currentupdate['batter']} {self.format_gamestring(getattr(self, currentupdate['outcome'].name)[currentupdate['voiceindex']][0], currentupdate)}"
|
||||||
})
|
})
|
||||||
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)}"
|
||||||
|
except:
|
||||||
|
game_strings_base().activate(lastupdate, currentupdate, game)
|
||||||
|
|
||||||
def check_for_twopart(self, gamestring):
|
def check_for_twopart(self, gamestring):
|
||||||
return gamestring in self.twoparts
|
return gamestring in self.twoparts
|
||||||
|
@ -105,25 +108,29 @@ class game_strings_base(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def stealing(self, currentupdate, runner, base_string, defender, is_successful):
|
def stealing(self, currentupdate, runner, base_string, defender, is_successful):
|
||||||
if is_successful:
|
try:
|
||||||
index = randrange(0, len(self.steal_success))
|
if is_successful:
|
||||||
text = self.steal_success[index]
|
index = randrange(0, len(self.steal_success))
|
||||||
else:
|
text = self.steal_success[index]
|
||||||
index = randrange(0, len(self.steal_caught))
|
else:
|
||||||
text = self.steal_caught[index]
|
index = randrange(0, len(self.steal_caught))
|
||||||
|
text = self.steal_caught[index]
|
||||||
|
|
||||||
|
if text not in self.no_formats:
|
||||||
|
format_list = []
|
||||||
|
for format in self.diff_formats[text]:
|
||||||
|
if format == "runner":
|
||||||
|
format_list.append(runner)
|
||||||
|
elif format == "base_string":
|
||||||
|
format_list.append(base_string)
|
||||||
|
elif format == "defender":
|
||||||
|
format_list.append(defender)
|
||||||
|
currentupdate["steals"] = [text.format(*format_list)]
|
||||||
|
else:
|
||||||
|
currentupdate["steals"] = [text]
|
||||||
|
except:
|
||||||
|
game_strings_base().stealing(currentupdate, runner, base_string, defender, is_successful)
|
||||||
|
|
||||||
if text not in self.no_formats:
|
|
||||||
format_list = []
|
|
||||||
for format in self.diff_formats[text]:
|
|
||||||
if format == "runner":
|
|
||||||
format_list.append(runner)
|
|
||||||
elif format == "base_string":
|
|
||||||
format_list.append(base_string)
|
|
||||||
elif format == "defender":
|
|
||||||
format_list.append(defender)
|
|
||||||
currentupdate["steals"] = [text.format(*format_list)]
|
|
||||||
else:
|
|
||||||
currentupdate["steals"] = [text]
|
|
||||||
|
|
||||||
|
|
||||||
class TheGoddesses(game_strings_base):
|
class TheGoddesses(game_strings_base):
|
||||||
|
|
Loading…
Reference in a new issue