Add weather-driven ambient messages
Rain, storm, snow, and fog now have atmospheric ambient messages. Clear and cloudy conditions return empty list. Messages are evocative and lowercase, ready to be mixed with zone-specific ambience.
This commit is contained in:
parent
4c4d947ce2
commit
25339edbf5
2 changed files with 81 additions and 0 deletions
|
|
@ -261,3 +261,32 @@ def tick_weather(season: str = "summer", climate: str = "temperate") -> None:
|
|||
global _current_weather
|
||||
current = get_current_weather()
|
||||
_current_weather = advance_weather(current, season=season, climate=climate)
|
||||
|
||||
|
||||
def get_weather_ambience(condition: WeatherCondition) -> list[str]:
|
||||
"""Return ambient messages appropriate for the weather."""
|
||||
if condition == WeatherCondition.rain:
|
||||
return [
|
||||
"rain patters on the ground around you.",
|
||||
"water drips from above.",
|
||||
"you hear the steady rhythm of rainfall.",
|
||||
]
|
||||
elif condition == WeatherCondition.storm:
|
||||
return [
|
||||
"thunder cracks overhead.",
|
||||
"lightning flashes in the distance.",
|
||||
"the wind howls fiercely.",
|
||||
]
|
||||
elif condition == WeatherCondition.snow:
|
||||
return [
|
||||
"snowflakes drift silently down.",
|
||||
"the world is muffled under falling snow.",
|
||||
]
|
||||
elif condition == WeatherCondition.fog:
|
||||
return [
|
||||
"mist swirls around your feet.",
|
||||
"shapes loom and fade in the fog.",
|
||||
]
|
||||
else:
|
||||
# clear or cloudy: no extra ambience
|
||||
return []
|
||||
|
|
|
|||
|
|
@ -206,3 +206,55 @@ def test_advance_weather_accepts_all_seasons():
|
|||
for season in ["spring", "summer", "autumn", "winter"]:
|
||||
new_state = advance_weather(current, season=season, rng=rng)
|
||||
assert isinstance(new_state, WeatherState)
|
||||
|
||||
|
||||
def test_get_weather_ambience_rain():
|
||||
from mudlib.weather import get_weather_ambience
|
||||
|
||||
messages = get_weather_ambience(WeatherCondition.rain)
|
||||
assert isinstance(messages, list)
|
||||
assert len(messages) > 0
|
||||
assert all(isinstance(msg, str) for msg in messages)
|
||||
|
||||
|
||||
def test_get_weather_ambience_storm():
|
||||
from mudlib.weather import get_weather_ambience
|
||||
|
||||
messages = get_weather_ambience(WeatherCondition.storm)
|
||||
assert isinstance(messages, list)
|
||||
assert len(messages) > 0
|
||||
assert all(isinstance(msg, str) for msg in messages)
|
||||
|
||||
|
||||
def test_get_weather_ambience_snow():
|
||||
from mudlib.weather import get_weather_ambience
|
||||
|
||||
messages = get_weather_ambience(WeatherCondition.snow)
|
||||
assert isinstance(messages, list)
|
||||
assert len(messages) > 0
|
||||
assert all(isinstance(msg, str) for msg in messages)
|
||||
|
||||
|
||||
def test_get_weather_ambience_fog():
|
||||
from mudlib.weather import get_weather_ambience
|
||||
|
||||
messages = get_weather_ambience(WeatherCondition.fog)
|
||||
assert isinstance(messages, list)
|
||||
assert len(messages) > 0
|
||||
assert all(isinstance(msg, str) for msg in messages)
|
||||
|
||||
|
||||
def test_get_weather_ambience_clear():
|
||||
from mudlib.weather import get_weather_ambience
|
||||
|
||||
messages = get_weather_ambience(WeatherCondition.clear)
|
||||
assert isinstance(messages, list)
|
||||
assert len(messages) == 0
|
||||
|
||||
|
||||
def test_get_weather_ambience_cloudy():
|
||||
from mudlib.weather import get_weather_ambience
|
||||
|
||||
messages = get_weather_ambience(WeatherCondition.cloudy)
|
||||
assert isinstance(messages, list)
|
||||
assert len(messages) == 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue