"""Tests for visibility calculations.""" from mudlib.visibility import get_visibility from mudlib.weather import WeatherCondition, WeatherState def test_clear_day_full_visibility(): hour = 12 # noon weather = WeatherState(condition=WeatherCondition.clear, intensity=0.5) width, height = get_visibility(hour, weather) assert width == 21 assert height == 11 def test_night_reduces_visibility(): hour = 22 # night (20-4) weather = WeatherState(condition=WeatherCondition.clear, intensity=0.5) width, height = get_visibility(hour, weather) assert width == 15 # 21 - 6 assert height == 9 # 11 - 2 def test_thick_fog_during_day(): hour = 12 # noon weather = WeatherState(condition=WeatherCondition.fog, intensity=0.8) width, height = get_visibility(hour, weather) assert width == 13 # 21 - 8 assert height == 7 # 11 - 4 def test_night_plus_thick_fog_clamps_to_minimum(): hour = 22 # night weather = WeatherState(condition=WeatherCondition.fog, intensity=0.9) width, height = get_visibility(hour, weather) # Night: -6 width, -2 height (21x11 -> 15x9) # Thick fog: -8 width, -4 height (15x9 -> 7x5) # Should clamp to minimum 7x5 assert width == 7 assert height == 5 def test_storm_reduces_visibility(): hour = 12 # noon weather = WeatherState(condition=WeatherCondition.storm, intensity=0.7) width, height = get_visibility(hour, weather) assert width == 17 # 21 - 4 assert height == 9 # 11 - 2 def test_dawn_subtle_dimming(): hour = 5 # dawn (5-6) weather = WeatherState(condition=WeatherCondition.clear, intensity=0.5) width, height = get_visibility(hour, weather) assert width == 19 # 21 - 2 assert height == 11 # 11 - 0 def test_dusk_subtle_dimming(): hour = 18 # dusk (18-19) weather = WeatherState(condition=WeatherCondition.clear, intensity=0.5) width, height = get_visibility(hour, weather) assert width == 19 # 21 - 2 assert height == 11 # 11 - 0 def test_moderate_fog(): hour = 12 # noon weather = WeatherState(condition=WeatherCondition.fog, intensity=0.5) width, height = get_visibility(hour, weather) assert width == 17 # 21 - 4 assert height == 9 # 11 - 2 def test_light_fog_no_reduction(): hour = 12 # noon weather = WeatherState(condition=WeatherCondition.fog, intensity=0.3) width, height = get_visibility(hour, weather) assert width == 21 # no reduction for light fog assert height == 11 def test_cloudy_no_visibility_reduction(): hour = 12 # noon weather = WeatherState(condition=WeatherCondition.cloudy, intensity=0.7) width, height = get_visibility(hour, weather) assert width == 21 assert height == 11 def test_rain_no_visibility_reduction(): hour = 12 # noon weather = WeatherState(condition=WeatherCondition.rain, intensity=0.7) width, height = get_visibility(hour, weather) assert width == 21 assert height == 11 def test_snow_no_visibility_reduction(): hour = 12 # noon weather = WeatherState(condition=WeatherCondition.snow, intensity=0.7) width, height = get_visibility(hour, weather) assert width == 21 assert height == 11 def test_custom_base_dimensions(): hour = 12 # noon weather = WeatherState(condition=WeatherCondition.clear, intensity=0.5) width, height = get_visibility(hour, weather, base_width=31, base_height=21) assert width == 31 assert height == 21 def test_night_custom_base(): hour = 22 # night weather = WeatherState(condition=WeatherCondition.clear, intensity=0.5) width, height = get_visibility(hour, weather, base_width=31, base_height=21) assert width == 25 # 31 - 6 assert height == 19 # 21 - 2 def test_midnight_is_night(): hour = 0 # midnight weather = WeatherState(condition=WeatherCondition.clear, intensity=0.5) width, height = get_visibility(hour, weather) assert width == 15 # reduced for night assert height == 9 def test_early_morning_is_night(): hour = 3 # early morning weather = WeatherState(condition=WeatherCondition.clear, intensity=0.5) width, height = get_visibility(hour, weather) assert width == 15 # reduced for night assert height == 9