finished implementing leaf eddies

This commit is contained in:
Sakimori 2021-04-18 14:39:34 -04:00
parent 1adb7e5b4e
commit f1a9735cf6
4 changed files with 71 additions and 31 deletions

View file

@ -386,6 +386,8 @@ class game(object):
self.voice.stealing(outcome, baserunner.name, base_string(start_base+1), defender.name, successful) self.voice.stealing(outcome, baserunner.name, base_string(start_base+1), defender.name, successful)
self.weather.steal_post_activate(self, outcome)
if self.outs >= 3: if self.outs >= 3:
self.flip_inning() self.flip_inning()
@ -655,7 +657,6 @@ class game(object):
self.voice.post_format = [] self.voice.post_format = []
result["displaytext"] = result["displaytext"].format(*format_list) result["displaytext"] = result["displaytext"].format(*format_list)
if self.outs < 3: if self.outs < 3:
result["offense_team"].score += scores_to_add #only add points if inning isn't over result["offense_team"].score += scores_to_add #only add points if inning isn't over
else: else:

View file

@ -256,4 +256,4 @@ def update_loop():
socket_thread = threading.Thread(target=socketio.emit, args=("states_update", game_states)) socket_thread = threading.Thread(target=socketio.emit, args=("states_update", game_states))
socket_thread.start() socket_thread.start()
#socketio.emit("states_update", game_states) #socketio.emit("states_update", game_states)
time.sleep(8) time.sleep(3)

View file

@ -170,7 +170,7 @@ class StartGameCommand(Command):
except ValueError: except ValueError:
raise CommandError("That number of innings isn't even an integer, chief. We can't do fractional innings, nor do we want to.") raise CommandError("That number of innings isn't even an integer, chief. We can't do fractional innings, nor do we want to.")
if innings is not None and innings < 2: if innings is not None and innings < 2 and msg.author.id not in config()["owners"]:
raise CommandError("Anything less than 2 innings isn't even an outing. Try again.") raise CommandError("Anything less than 2 innings isn't even an outing. Try again.")
elif innings is not None and innings > 200 and msg.author.id not in config()["owners"]: elif innings is not None and innings > 200 and msg.author.id not in config()["owners"]:
@ -2245,7 +2245,10 @@ async def game_watcher():
await asyncio.sleep(4) await asyncio.sleep(4)
def game_over_embed(game): def game_over_embed(game):
title_string = f"{game.teams['away'].name} at {game.teams['home'].name} ended after {game.inning-1} innings" if game.inning != 2:
title_string = f"{game.teams['away'].name} at {game.teams['home'].name} ended after {game.inning-1} innings"
else:
title_string = f"{game.teams['away'].name} at {game.teams['home'].name} ended after 1 inning"
if (game.inning - 1) > game.max_innings: #if extra innings if (game.inning - 1) > game.max_innings: #if extra innings
title_string += f" with {game.inning - (game.max_innings+1)} extra innings.\n" title_string += f" with {game.inning - (game.max_innings+1)} extra innings.\n"
else: else:

View file

@ -30,6 +30,12 @@ class Weather:
# activates after the batter calculation. modify result, or just return another thing # activates after the batter calculation. modify result, or just return another thing
pass pass
def steal_activate(self, game, result):
pass
def steal_post_activate(self, game, result):
pass
def post_activate(self, game, result): def post_activate(self, game, result):
pass pass
@ -476,38 +482,68 @@ class LeafEddies(Weather):
sent = False sent = False
first = True first = True
def __init__(self, game):
self.name = f"Leaf Eddies: {roman.roman_convert(str(game.max_innings*3))}"
self.original_innings = game.max_innings
game.max_innings = 1
self.inning_text = "The umpires have remembered their jobs. They shoo the defenders off the field!"
def activate(self, game, result): def activate(self, game, result):
if out_counter >= (game.max_innings * 3): if game.inning == 1:
result["swap"] = True if self.out_counter % 3 == 0 and not self.out_counter == 0 and not self.sent:
elif out_counter % 3 == 0 and not out_counter == 0 and not sent: if self.first:
if first: self.first = False
first = False updatetext = "The leaves have distracted the umpires, and they've been unable to keep track of outs!"
updatetext = "The leaves have distracted the umpires, and they've been unable to keep track of outs!" else:
else: leaf = random.sample(self.leaves, 2)
leaf = random.choice(leaves) eddy = random.choice(self.eddy_types)
eddy = random.choice(eddy_types) updatetext = f"A{eddy} of {leaf[0]} and {leaf[1]} leaves blows through, and the umpires remain distracted!"
updatetext = f"A{eddy} of {leaf} blows through, and the umpires remain distracted!" self.sent = True
sent = True result.clear()
result.clear() result.update({
result.update({ "text": updatetext,
"text": updatetext, "text_only": True,
"text_only": True, "weather_message": True
"weather_message": True })
}) else:
game.outs = 2
def steal_post_activate(self, game, result):
self.post_activate(game, result)
def post_activate(self, game, result): def post_activate(self, game, result):
if game.outs > 0: if game.inning == 1:
self.out_counter += game.outs if game.outs > 0:
sent = False self.out_counter += game.outs
game.outs = 0 game.outs = 0
self.sent = False
if "swap" in result and game.top_of_inning: if self.out_counter < (self.original_innings * 3):
self.out_counter = 0 self.name = f"Leaf Eddies: {roman.roman_convert(str(self.original_innings*3-self.out_counter))}"
else:
self.name = "Leaf Eddies"
self.out_counter = 0
game.outs = 3
elif game.teams["home"].score != game.teams["away"].score:
game.outs = 3 game.outs = 3
if game.top_of_inning:
game.inning += 1
game.top_of_inning = False
def modify_top_of_inning_message(self, game, state): def modify_top_of_inning_message(self, game, state):
state["update_emoji"] = self.emoji state["update_emoji"] = self.emoji
state["update_text"] = "The umpires have remembered their jobs. They shoo the defenders off the field, and the sides finally switch!" if game.inning == 1:
self.name = f"Leaf Eddies: {roman.roman_convert(str(self.original_innings*3-self.out_counter))}"
else:
self.name = "Leaf Eddies: Golden Run"
state["update_emoji"] = ""
self.inning_text = "SUDDEN DEATH ⚠"
state["update_text"] = self.inning_text
state["weather_text"] = self.name
def modify_atbat_message(self, game, state):
if game.inning == 1:
state["weather_text"] = self.name
def all_weathers(): def all_weathers():
weathers_dic = { weathers_dic = {