pipeworks_mud_mapper.services.exit_utils
Exit parsing helpers for local vs cross-zone exits.
This module centralizes the tiny bits of exit parsing logic used by the UI, validation, and map rendering layers. It keeps the rules for detecting cross-zone exits (“zone_id:room_id”) consistent across the codebase.
Functions
|
Split exits into local (same-zone) and zone (cross-zone) mappings. |
|
Parse a cross-zone exit target into (zone_id, room_id). |
|
Format a zone + room selection into the stored exit value. |
Module Contents
- pipeworks_mud_mapper.services.exit_utils.split_exits_by_scope(exits)[source]
Split exits into local (same-zone) and zone (cross-zone) mappings.
- Parameters:
exits (
dict[Direction,str] | None) – Exit mapping from a room. Values that contain “:” are treated as cross-zone exits (“zone_id:room_id”). All others are local exits.- Returns:
(local_exits, zone_exits) where each dict is keyed by direction.
- Return type:
tuple[dict[Direction,str],dict[Direction,str]]
Notes
This is deliberately small and conservative: we only treat values as cross-zone exits if they include a colon. Any other value is treated as local, even if it might be malformed.
- pipeworks_mud_mapper.services.exit_utils.parse_zone_exit(target)[source]
Parse a cross-zone exit target into (zone_id, room_id).
- Parameters:
target (
str | None) – Exit target string, expected in “zone_id:room_id” format.- Returns:
(zone_id, room_id). Returns (None, None) if the input is missing or does not contain a valid colon-separated pair.
- Return type:
tuple[str | None,str | None]
- pipeworks_mud_mapper.services.exit_utils.format_zone_exit(zone_id, room_id)[source]
Format a zone + room selection into the stored exit value.
- Parameters:
zone_id (
str | None) – Selected zone ID.room_id (
str | None) – Selected room ID.
- Returns:
“zone_id:room_id” if both parts are present; otherwise None.
- Return type:
str | None