fix(map): require single-character legend keys

This commit is contained in:
2026-09-20 17:43:50 +02:00
parent c46e636d12
commit 205ddece0b
2 changed files with 27 additions and 0 deletions
+7
View File
@@ -183,6 +183,13 @@ def load_map(path: Path) -> MapSpec:
terrain = _split_rows(raw.terrain, "terrain", path)
height, width = len(terrain), len(terrain[0])
multi_char = sorted(key for key in raw.legend if len(key) != 1)
if multi_char:
msg = (
"legend keys must be exactly one character (one char = one "
f"square), got: {multi_char}"
)
raise MapValidationError(path, msg)
unknown = sorted({ch for row in terrain for ch in row if ch not in raw.legend})
if unknown:
msg = f"terrain chars missing from legend: {unknown}"