"""Preset weather and time values for the dev server Weather/Time tab.""" from __future__ import annotations # Each preset is (label, fw_console_arg). # `fw_console_arg` is passed directly to the in-game `fw` command on the # current world-state host client # (8-digit hex form ID, not an editor name like CommonwealthRain). WEATHER_PRESETS: list[tuple[str, str]] = [ ("Clear", "0002b52a"), ("Cloudy", "001cc186"), ("Overcast", "001c8556"), ("Fog", "001c3473"), ("Rain", "001ca7e4"), ("Radstorm", "001c3d5e"), ("Glowing Sea", "000f1033"), ] # HHmm values for the in-game `set gamehour to HHmm` console command. TIME_PRESETS: list[tuple[str, str]] = [ ("Midnight", "0000"), ("Dawn", "0600"), ("Morning", "0900"), ("Noon", "1200"), ("Afternoon", "1500"), ("Evening", "1800"), ("Dusk (7 PM)", "1900"), ("Night", "2200"), ] def normalize_fw_console_arg(value: str) -> str: text = str(value).strip().lower() if text.startswith("0x"): text = text[2:] return f"{int(text, 16):08x}" def relay_weather_form_id(fw_console_arg: str) -> str: return f"{int(fw_console_arg, 16):08X}" def hhmm_to_game_hour(hhmm: str) -> float | None: text = str(hhmm).strip() if not text.isdigit() or len(text) > 4: return None padded = text.zfill(4) hours = int(padded[:2]) minutes = int(padded[2:]) if hours > 23 or minutes > 59: return None return hours + (minutes / 60.0) def format_hhmm_label(hhmm: str) -> str: text = str(hhmm).strip().zfill(4) hours = int(text[:2]) minutes = int(text[2:]) suffix = "AM" if hours < 12 else "PM" display_hour = hours % 12 if display_hour == 0: display_hour = 12 if minutes: return f"{display_hour}:{minutes:02d} {suffix}" return f"{display_hour} {suffix}"