From 25339edbf50d850cec739018b9948896b14bb4d4 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Sat, 14 Feb 2026 16:06:40 -0500 Subject: [PATCH] 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. --- src/mudlib/weather.py | 29 ++++++++++++++++++++++++ tests/test_weather.py | 52 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/src/mudlib/weather.py b/src/mudlib/weather.py index 4002301..d6d9582 100644 --- a/src/mudlib/weather.py +++ b/src/mudlib/weather.py @@ -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 [] diff --git a/tests/test_weather.py b/tests/test_weather.py index f75c034..7583156 100644 --- a/tests/test_weather.py +++ b/tests/test_weather.py @@ -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