Files
code_of_conquest_dnd/tools/content_build/rungs.py

24 lines
828 B
Python

"""The rung vocabulary, sourced from the bible's disposition-ladder entry. The
bible owns rung names/order; band NUMBERS live in client code and never here."""
from .errors import BuildError
from .model import Entry
LADDER_ID = "rule.disposition-ladder"
NEVER = "never"
def ladder_rungs(entries: list[Entry]) -> list[str]:
ladders = [e for e in entries if e.id == LADDER_ID]
if len(ladders) != 1:
raise BuildError(
f"exactly one '{LADDER_ID}' entry required, found {len(ladders)}")
if not ladders[0].rungs:
raise BuildError("disposition-ladder needs a non-empty 'rungs:' list",
source=ladders[0].source, entry_id=LADDER_ID)
return list(ladders[0].rungs)
def legal_gates(entries: list[Entry]) -> set[str]:
return set(ladder_rungs(entries)) | {NEVER}