implemented Summer Mist, fixed weather messages interacting with voices
This commit is contained in:
parent
f05e1eb9c2
commit
3f029b799d
12
games.py
12
games.py
|
@ -521,11 +521,6 @@ class game(object):
|
|||
|
||||
if "twopart" not in self.last_update[0]:
|
||||
result = self.at_bat()
|
||||
self.weather.activate(self, result) # possibly modify result in-place
|
||||
|
||||
if "text_only" in result:
|
||||
return (result, 0)
|
||||
|
||||
|
||||
if self.top_of_inning:
|
||||
offense_team = self.teams["away"]
|
||||
|
@ -545,6 +540,7 @@ class game(object):
|
|||
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)
|
||||
voice_index = random.randrange(0, len(text_list))
|
||||
result["voiceindex"] = voice_index
|
||||
|
@ -553,6 +549,12 @@ class game(object):
|
|||
|
||||
self.voice.activate(self.last_update[0], result, self)
|
||||
|
||||
if "twopart" not in result:
|
||||
self.weather.activate(self, result) # possibly modify result in-place
|
||||
|
||||
if "text_only" in result:
|
||||
return (result, 0)
|
||||
|
||||
if "twopart" in result:
|
||||
if self.voice.post_format != []:
|
||||
format_list = []
|
||||
|
|
|
@ -231,7 +231,8 @@ def update_loop():
|
|||
|
||||
state["update_text"] = f"{updatestring}"
|
||||
|
||||
this_game.weather.modify_atbat_message(this_game, state)
|
||||
if "twopart" not in this_game.last_update[0].keys():
|
||||
this_game.weather.modify_atbat_message(this_game, state)
|
||||
|
||||
state["bases"] = this_game.named_bases()
|
||||
|
||||
|
@ -255,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(1)
|
||||
time.sleep(8)
|
45
weather.py
45
weather.py
|
@ -1,5 +1,5 @@
|
|||
import random, math, roman
|
||||
from gametext import appearance_outcomes, base_string
|
||||
from gametext import appearance_outcomes, game_strings_base, base_string
|
||||
|
||||
class Weather:
|
||||
name = "Sunny"
|
||||
|
@ -427,6 +427,35 @@ class Downpour(Weather):
|
|||
state["update_emoji"] = self.emoji
|
||||
state["update_text"] = f"{self.target} runs are reached, pleasing the gods. The storm clears."
|
||||
|
||||
class SummerMist(Weather):
|
||||
name = "Summer Mist"
|
||||
emoji = "🌁"
|
||||
duration_range = [1,3]
|
||||
substances = ["yellow mustard", "cat fur", "dread", "caramel", "nacho cheese", "mud", "dirt", "justice", "a green goo", "water, probably", "antimatter", "something not of this world", "live ferrets", "snow", "leaves",
|
||||
"yarn", "seaweed", "sawdust", "stardust", "code fragments", "milk", "lizards", "a large tarp", "feathers"]
|
||||
|
||||
def __init__(self, game):
|
||||
self.missing_players = {game.teams["home"].name: None, game.teams["away"].name: None}
|
||||
self.text = ""
|
||||
|
||||
def activate(self, game, result):
|
||||
if result["outcome"] in [appearance_outcomes.flyout, appearance_outcomes.groundout, appearance_outcomes.sacrifice]:
|
||||
roll = random.random()
|
||||
if roll < .3: #get lost
|
||||
result["mist"] = True
|
||||
self.text = f" {result['batter'].name} gets lost in the mist on the way back to the dugout."
|
||||
if self.missing_players[result["offense_team"].name] is not None:
|
||||
self.text += f" {self.missing_players[result['offense_team'].name].name} wanders back, covered in {random.choice(self.substances)}!"
|
||||
result["offense_team"].lineup[result["offense_team"].lineup_position % len(result["offense_team"].lineup)] = self.missing_players[result["offense_team"].name]
|
||||
else:
|
||||
result["offense_team"].lineup.pop(result["offense_team"].lineup_position % len(result["offense_team"].lineup))
|
||||
self.missing_players[result["offense_team"].name] = result["batter"]
|
||||
|
||||
def modify_atbat_message(self, game, state):
|
||||
if "mist" in game.last_update[0]:
|
||||
state["update_emoji"] = self.emoji
|
||||
state["update_text"] += self.text
|
||||
self.text = ""
|
||||
|
||||
def all_weathers():
|
||||
weathers_dic = {
|
||||
|
@ -443,31 +472,33 @@ def all_weathers():
|
|||
"Meteor Shower" : MeteorShower,
|
||||
"Hurricane" : Hurricane,
|
||||
"Tornado" : Tornado,
|
||||
"Torrential Downpour" : Downpour
|
||||
"Torrential Downpour" : Downpour,
|
||||
"Summer Mist" : SummerMist
|
||||
}
|
||||
return weathers_dic
|
||||
|
||||
class WeatherChains():
|
||||
light = [SlightTailwind, Twilight, Breezy, Drizzle] #basic starting points for weather, good comfortable spots to return to
|
||||
light = [SlightTailwind, Twilight, Breezy, Drizzle, SummerMist] #basic starting points for weather, good comfortable spots to return to
|
||||
magic = [Twilight, ThinnedVeil, MeteorShower, Starlight] #weathers involving breaking the fabric of spacetime
|
||||
sudden = [Tornado, Hurricane, Twilight, Starlight, Midnight, Downpour] #weathers that always happen and leave over 1-3 games
|
||||
disaster = [Hurricane, Tornado, Downpour, Blizzard] #storms
|
||||
aftermath = [Midnight, Starlight, MeteorShower] #calm epilogues
|
||||
aftermath = [Midnight, Starlight, MeteorShower, SummerMist] #calm epilogues
|
||||
|
||||
dictionary = {
|
||||
#Supernova : (magic + sudden + disaster, None), supernova happens leaguewide and shouldn't need a chain, but here just in case
|
||||
Midnight : ([SlightTailwind, Breezy, Drizzle, Starlight, MeteorShower, HeatWave],[2,2,2,4,4,1]),
|
||||
Midnight : ([SlightTailwind, Breezy, Drizzle, Starlight, MeteorShower, HeatWave, SummerMist],[2,2,2,4,4,1,2]),
|
||||
SlightTailwind : ([Breezy, Drizzle, Tornado], [3,3,1]),
|
||||
Blizzard : ([Midnight, Starlight, MeteorShower, Twilight, Downpour], [2,2,2,2,4]),
|
||||
Twilight : ([ThinnedVeil, Midnight, MeteorShower, SlightTailwind], [2,4,2,1]),
|
||||
Twilight : ([ThinnedVeil, Midnight, MeteorShower, SlightTailwind, SummerMist], [2,4,2,1,2]),
|
||||
ThinnedVeil : (light, None),
|
||||
HeatWave : ([Tornado, Hurricane, SlightTailwind, Breezy],[4,4,1,1]),
|
||||
HeatWave : ([Tornado, Hurricane, SlightTailwind, Breezy, SummerMist],[4,4,1,1,2]),
|
||||
Drizzle : ([Hurricane, Downpour, Blizzard],[2,2,1]),
|
||||
Breezy : ([Drizzle, HeatWave, Blizzard, Tornado], [3,3,1,1]),
|
||||
Starlight : ([SlightTailwind, Twilight, Breezy, Drizzle, ThinnedVeil, HeatWave], None),
|
||||
MeteorShower : ([Starlight, ThinnedVeil, HeatWave], None),
|
||||
Hurricane : ([Midnight, Starlight, MeteorShower, Twilight, Downpour], [2,2,2,2,4]),
|
||||
Tornado : ([Midnight, Starlight, MeteorShower, Twilight, Downpour],[2,2,2,2,4]),
|
||||
SummerMist : ([Drizzle, Breezy, Hurricane, Downpour],[2, 1, 1, 1]),
|
||||
Downpour : (aftermath, None)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue