finished implementing leaf eddies
This commit is contained in:
parent
1adb7e5b4e
commit
f1a9735cf6
3
games.py
3
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()
|
||||
|
||||
|
@ -655,7 +657,6 @@ class game(object):
|
|||
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:
|
||||
|
|
|
@ -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)
|
||||
time.sleep(3)
|
|
@ -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:
|
||||
|
|
86
weather.py
86
weather.py
|
@ -30,6 +30,12 @@ class Weather:
|
|||
# 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
|
||||
|
||||
|
@ -476,38 +482,68 @@ class LeafEddies(Weather):
|
|||
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 = {
|
||||
|
|
Loading…
Reference in a new issue