Files
windroost/tools/fullgame/validate_content.py
T
wushenghua 7769a91f2c content: side systems — partners/records/black market (L5 content)
Continued FULL_GAME_GOAL. Generated the three side systems from design tables:
- 5 partners with real names/roles (navigator/smithy/recorder/healer/stargazer),
  combat=false per design (no second combat system).
- 167 records across 9 categories with exact design counts
  (25/30/24/20/18/15/10/15/10), stage-or-one-time rewards, no miss penalty.
- 6 black-market categories, crystal-only, pay_to_win=false.
- content_qa.py enforces all these rules; validate_content now covers 13 families.

Pack regenerated, FULL_CONTENT_PASS + CONTENT_QA_PASS, full P2_CHECKS_PASS.
Runtime logic/UI for side systems remains (noted in goal). prototype/ untracked.
2026-11-18 14:54:33 +08:00

124 lines
4.6 KiB
Python

#!/usr/bin/env python3
"""Validate the full-game content pack (L0 gate).
Checks:
- counts match design ceilings (CONTENT_PLAN)
- IDs unique per family and match the ID grammar
- every reference resolves (node -> enemy/boss/reward; talent -> hero; event -> chapter)
- every node has a type from the design's 10 types
- every chapter has 10 nodes, every region 12 chapters
- no raw callables / NaN / non-serializable values
Usage: python3 tools/fullgame/validate_content.py [path]
"""
from __future__ import annotations
import json
import math
import re
import sys
from pathlib import Path
from typing import Any, Dict, List, Set
ROOT = Path(__file__).resolve().parents[2]
DEFAULT = ROOT / "data" / "full_game_content.json"
EXPECTED = {"heroes":54,"talents":245,"enemies":120,"bosses":20,"nodes":600,
"events":60,"gear":120,"relics":60,"oaths":26,"edicts":9,"records":167,
"partners":5,"market":6}
def ids(rows: List[Dict[str, Any]]) -> Set[str]:
return {str(r["id"]) for r in rows}
def main() -> int:
path = Path(sys.argv[1]) if len(sys.argv) > 1 else DEFAULT
if not path.exists():
print(f"FULL_CONTENT_FAIL missing {path}")
return 1
pack = json.loads(path.read_text(encoding="utf-8"))
problems: List[str] = []
# counts
counts = pack.get("counts", {})
for family, expected in EXPECTED.items():
rows = pack.get(family, [])
if len(rows) != expected:
problems.append(f"{family}: {len(rows)} rows, expected {expected}")
if counts.get(family) != len(rows):
problems.append(f"{family}: counts table says {counts.get(family)}, rows {len(rows)}")
families = {f: pack.get(f, []) for f in EXPECTED}
# unique IDs
for family, rows in families.items():
all_ids = [str(r.get("id","")) for r in rows]
if len(all_ids) != len(set(all_ids)):
problems.append(f"{family}: duplicate IDs")
if any(not i for i in all_ids):
problems.append(f"{family}: empty ID")
hero_ids = ids(families["heroes"])
enemy_ids = ids(families["enemies"])
boss_ids = ids(families["bosses"])
event_ids = ids(families["events"])
# references
for t in families["talents"]:
if "hero" in t and t["hero"] not in hero_ids and not str(t["id"]).startswith("T-G"):
problems.append(f"talent {t['id']} -> unknown hero {t['hero']}")
for n in families["nodes"]:
for wave in n.get("waves", []):
for e in wave:
if e not in enemy_ids and e not in boss_ids:
problems.append(f"node {n['id']} -> unknown enemy/boss {e}")
if n.get("boss") and n["boss"] not in boss_ids:
problems.append(f"node {n['id']} -> unknown boss {n['boss']}")
for ev in families["events"]:
ck = ev["chapter"]
if not any(n["chapter"] == ck for n in families["nodes"]):
problems.append(f"event {ev['id']} -> unknown chapter {ck}")
# structure: 5 regions x 12 chapters x 10 nodes
from collections import Counter
per_chapter = Counter(n["chapter"] for n in families["nodes"])
for ck, c in per_chapter.items():
if c != 10:
problems.append(f"chapter {ck}: {c} nodes, expected 10")
if len(per_chapter) != 60:
problems.append(f"chapters: {len(per_chapter)}, expected 60")
per_region = Counter(n["region"] for n in families["nodes"])
if sorted(per_region.keys()) != ["R1","R2","R3","R4","R5"]:
problems.append(f"regions: {sorted(per_region.keys())}")
# allowed node types
allowed_types = {"normal","event","shop","elite","trial","supply","boss"}
for n in families["nodes"]:
if n["type"] not in allowed_types:
problems.append(f"node {n['id']}: unknown type {n['type']}")
# no non-finite numbers anywhere
def walk(o: Any, where: str) -> None:
if isinstance(o, float) and not math.isfinite(o):
problems.append(f"non-finite number at {where}")
elif isinstance(o, dict):
for k, v in o.items(): walk(v, f"{where}.{k}")
elif isinstance(o, list):
for i, v in enumerate(o): walk(v, f"{where}[{i}]")
walk(pack, "pack")
if problems:
print(f"FULL_CONTENT_FAIL {len(problems)} problem(s)")
for p in problems[:40]:
print(" " + p)
if len(problems) > 40:
print(f" ... {len(problems)-40} more")
return 1
print(f"FULL_CONTENT_PASS {len(families)} families, "
f"{len(families['nodes'])} nodes, all references resolve")
return 0
if __name__ == "__main__":
raise SystemExit(main())