diff --git a/games.py b/games.py index d598c26..be84067 100644 --- a/games.py +++ b/games.py @@ -386,6 +386,8 @@ class game(object): 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: self.flip_inning() @@ -654,8 +656,7 @@ class game(object): format_list.append("None") self.voice.post_format = [] result["displaytext"] = result["displaytext"].format(*format_list) - - + if self.outs < 3: result["offense_team"].score += scores_to_add #only add points if inning isn't over else: @@ -663,7 +664,7 @@ class game(object): self.get_batter().game_stats["rbis"] += scores_to_add self.get_pitcher().game_stats["runs_allowed"] += scores_to_add result["offense_team"].lineup_position += 1 #put next batter up - self.choose_next_batter() + self.choose_next_batter() self.weather.post_activate(self, result) diff --git a/main_controller.py b/main_controller.py index 95d4f82..6b92b5c 100644 --- a/main_controller.py +++ b/main_controller.py @@ -256,4 +256,4 @@ def update_loop(): socket_thread = threading.Thread(target=socketio.emit, args=("states_update", game_states)) socket_thread.start() #socketio.emit("states_update", game_states) - time.sleep(8) \ No newline at end of file + time.sleep(3) \ No newline at end of file diff --git a/the_prestige.py b/the_prestige.py index 8b8ce14..b89d68b 100644 --- a/the_prestige.py +++ b/the_prestige.py @@ -170,7 +170,7 @@ class StartGameCommand(Command): 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.") - 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.") 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) 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 title_string += f" with {game.inning - (game.max_innings+1)} extra innings.\n" else: diff --git a/weather.py b/weather.py index 0c95f22..b4cf74e 100644 --- a/weather.py +++ b/weather.py @@ -29,6 +29,12 @@ class Weather: def activate(self, game, result): # activates after the batter calculation. modify result, or just return another thing pass + + def steal_activate(self, game, result): + pass + + def steal_post_activate(self, game, result): + pass def post_activate(self, game, result): pass @@ -475,39 +481,69 @@ class LeafEddies(Weather): out_counter = 0 sent = False 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): - if out_counter >= (game.max_innings * 3): - result["swap"] = True - elif out_counter % 3 == 0 and not out_counter == 0 and not sent: - if first: - first = False - updatetext = "The leaves have distracted the umpires, and they've been unable to keep track of outs!" - else: - leaf = random.choice(leaves) - eddy = random.choice(eddy_types) - updatetext = f"A{eddy} of {leaf} blows through, and the umpires remain distracted!" - sent = True - result.clear() - result.update({ - "text": updatetext, - "text_only": True, - "weather_message": True - }) + if game.inning == 1: + if self.out_counter % 3 == 0 and not self.out_counter == 0 and not self.sent: + if self.first: + self.first = False + updatetext = "The leaves have distracted the umpires, and they've been unable to keep track of outs!" + else: + leaf = random.sample(self.leaves, 2) + eddy = random.choice(self.eddy_types) + updatetext = f"A{eddy} of {leaf[0]} and {leaf[1]} leaves blows through, and the umpires remain distracted!" + self.sent = True + result.clear() + result.update({ + "text": updatetext, + "text_only": 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): - if game.outs > 0: - self.out_counter += game.outs - sent = False - game.outs = 0 - - if "swap" in result and game.top_of_inning: - self.out_counter = 0 + if game.inning == 1: + if game.outs > 0: + self.out_counter += game.outs + game.outs = 0 + self.sent = False + if self.out_counter < (self.original_innings * 3): + 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 + if game.top_of_inning: + game.inning += 1 + game.top_of_inning = False def modify_top_of_inning_message(self, game, state): 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(): weathers_dic = {