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:
Jared Miller 2026-02-14 16:06:40 -05:00
parent 4c4d947ce2
commit 25339edbf5
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C
2 changed files with 81 additions and 0 deletions

View file

@ -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 []

View file

@ -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