Ground named cargo production event descriptors

This commit is contained in:
Jan Petykiewicz 2026-04-16 23:44:55 -07:00
commit 6a5d028d19
14 changed files with 987 additions and 217 deletions

View file

@ -95,7 +95,20 @@ def locomotive_cost_label(locomotive_id: int) -> str:
return f"Lower-Band Locomotive Cost Slot {locomotive_id}"
def classify(row: dict[str, object]) -> dict[str, object]:
def load_cargo_bindings(raw_table_path: Path) -> dict[int, dict[str, object]]:
bindings_path = raw_table_path.parent / "event-effects-cargo-bindings.json"
if not bindings_path.exists():
return {}
artifact = json.loads(bindings_path.read_text(encoding="utf-8"))
return {
int(binding["descriptor_id"]): binding
for binding in artifact.get("bindings", [])
}
def classify(
row: dict[str, object], cargo_bindings: dict[int, dict[str, object]]
) -> dict[str, object]:
descriptor_id = int(row["descriptor_id"])
label = str(row["label"])
signature_byte_0x63 = int(row["signature_byte_0x63"])
@ -142,6 +155,11 @@ def classify(row: dict[str, object]) -> dict[str, object]:
executable_in_runtime = True
elif 180 <= descriptor_id <= 229:
parameter_family = "cargo_production_scalar"
binding = cargo_bindings.get(descriptor_id)
if binding is not None:
label = f"{binding['cargo_name']} Production"
runtime_status = "executable"
executable_in_runtime = True
elif 230 <= descriptor_id <= 240:
parameter_family = "cargo_production_scalar"
runtime_status = "executable"
@ -213,7 +231,8 @@ def main() -> None:
args = parser.parse_args()
raw_artifact = json.loads(args.raw_table.read_text(encoding="utf-8"))
descriptors = [classify(row) for row in raw_artifact["descriptors"]]
cargo_bindings = load_cargo_bindings(args.raw_table)
descriptors = [classify(row, cargo_bindings) for row in raw_artifact["descriptors"]]
artifact = {
"descriptor_count": len(descriptors),
"raw_table_binary_sha256": raw_artifact.get("binary_sha256"),