Source-bound generator/validator/QA plus WR328 enemy weak-tag and WR330 hero unlock checkers. UI text is a 3-way merge: source event short keys and content keys added, all HEAD S3/S4/S5/S6 keys retained. No runtime/shell code ported.
144 lines
6.7 KiB
Python
144 lines
6.7 KiB
Python
#!/usr/bin/env python3
|
|
"""L4 content QA gate — catch the design's anti-goal (recolored/duplicate content).
|
|
|
|
Checks the full pack for real variety:
|
|
- no two adjacent nodes in a chapter have the same (type, enemy_ids) pair;
|
|
- each chapter's innovation constraint rotates (10 chapters cover constraints);
|
|
- boss names are unique and each has mechanics;
|
|
- enemy variants carry distinct weak tags so they demand different answers;
|
|
- names are non-placeholder (no '敌族1' / '首领1').
|
|
This does NOT prove a node is fun — that needs human play. It guards against
|
|
mechanical duplication, the cheapest form of fake content.
|
|
"""
|
|
import json
|
|
import sys
|
|
from collections import Counter
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def main() -> int:
|
|
pack = json.loads((ROOT / "data" / "full_game_content.json").read_text(encoding="utf-8"))
|
|
nodes = pack["nodes"]
|
|
enemies = pack["enemies"]
|
|
bosses = pack["bosses"]
|
|
problems = []
|
|
|
|
# Adjacent node variety within each chapter.
|
|
for ch in sorted({n["chapter"] for n in nodes}):
|
|
ch_nodes = sorted([n for n in nodes if n["chapter"] == ch], key=lambda n: n["index"])
|
|
for a, b in zip(ch_nodes, ch_nodes[1:]):
|
|
if (a["type"], tuple(a["waves"][0] if a["waves"] else ())) == \
|
|
(b["type"], tuple(b["waves"][0] if b["waves"] else ())):
|
|
problems.append(f"{ch}: N{a['index']} and N{b['index']} are identical (recolored)")
|
|
|
|
# Innovation rotation across chapters.
|
|
innovations = {n["chapter"]: n["innovation"] for n in nodes}
|
|
distinct = len(set(innovations.values()))
|
|
if distinct < 8:
|
|
problems.append(f"only {distinct} distinct innovation constraints across 60 chapters")
|
|
|
|
# Boss names unique + mechanics present.
|
|
names = [b["name"] for b in bosses]
|
|
if len(names) != len(set(names)):
|
|
problems.append("boss names not unique")
|
|
if any(not b.get("mechanics") for b in bosses):
|
|
problems.append("a boss has no mechanics")
|
|
|
|
# Talent design rule (CONTENT_PLAN 3.1): every hero has >=2 behaviour-changing
|
|
# talents, and none is a bare "+10%" stat stick.
|
|
talents = pack["talents"]
|
|
from collections import defaultdict
|
|
per_hero = defaultdict(list)
|
|
for t in talents:
|
|
if t.get("kind") == "hero_talent":
|
|
per_hero[t["hero"]].append(t)
|
|
for hid, ts in per_hero.items():
|
|
behavior_count = sum(1 for t in ts if t.get("changes_behavior"))
|
|
if behavior_count < 2:
|
|
problems.append(f"{hid}: only {behavior_count} behaviour-changing talents (need >=2)")
|
|
if any(not t.get("behavior") for t in ts):
|
|
problems.append(f"{hid}: a talent has no behaviour definition")
|
|
# skill (slot 3) and ultimate (slot 4) must both change behaviour
|
|
slots = {t["slot"]: t for t in ts}
|
|
if not slots.get(3, {}).get("changes_behavior") or not slots.get(4, {}).get("changes_behavior"):
|
|
problems.append(f"{hid}: skill/ultimate talent must change behaviour")
|
|
|
|
# Enemy variants demand different answers (weak tags vary within a family).
|
|
by_family = {}
|
|
for e in enemies:
|
|
by_family.setdefault(e["id"][:e["id"].rfind("-V")], set()).add(e["weak_tag"])
|
|
if any(len(v) < 4 for v in by_family.values()):
|
|
problems.append("an enemy family's variants don't cover 4 weak tags")
|
|
|
|
# Placeholder-name rejection.
|
|
all_names = [e["name"] for e in enemies] + names
|
|
if any("敌族1" in n or "首领1" in n for n in all_names):
|
|
problems.append("placeholder names still present")
|
|
|
|
# Record text coverage: all 167 records must have real title + description
|
|
# in both shipped locales (L5 content polish), no Chinese leaking into en.
|
|
import re as _re
|
|
for loc in ("zh_CN", "en_US"):
|
|
strings = json.loads((ROOT / "data" / f"ui_text.{loc}.json").read_text(encoding="utf-8"))["strings"]
|
|
for r in pack.get("records", []):
|
|
rid = str(r["id"])
|
|
for suffix in (".title", ".desc"):
|
|
k = f"record.{rid}{suffix}"
|
|
if k not in strings or not str(strings[k]).strip():
|
|
problems.append(f"{loc}: missing/empty record text {k}")
|
|
elif loc == "en_US" and _re.search(r"[\u4e00-\u9fff]", str(strings[k])):
|
|
problems.append(f"en_US record text {k} contains Chinese")
|
|
|
|
# Side-system design rules (FINAL_GAME_DESIGN 11):
|
|
# partners never enter combat; records have no miss penalty; black market
|
|
# is crystal-only and never sells pay-to-win power.
|
|
for p in pack.get("partners", []):
|
|
if p.get("combat"):
|
|
problems.append(f"partner {p['id']} enters combat (design forbids)")
|
|
for r in pack.get("records", []):
|
|
if r.get("miss_penalty"):
|
|
problems.append(f"record {r['id']} has a miss penalty (design forbids)")
|
|
for m in pack.get("market", []):
|
|
if m.get("currency") != "crystal":
|
|
problems.append(f"market {m['id']} uses non-crystal currency")
|
|
if m.get("pay_to_win"):
|
|
problems.append(f"market {m['id']} sells pay-to-win power")
|
|
# Record category counts match the shipped pack. WR-163 moves A137/A142
|
|
# from the partner metric to the dedicated garrison metric while keeping
|
|
# the total at 167 records.
|
|
from collections import Counter
|
|
cat_counts = Counter(r["category"] for r in pack.get("records", []))
|
|
expected_cats = {"推进":25,"战斗":30,"英雄":24,"Build":20,"转生":18,
|
|
"经济":15,"伙伴":8,"驻扎":2,"收集":15,"终局":10}
|
|
for cat, n in expected_cats.items():
|
|
if cat_counts.get(cat) != n:
|
|
problems.append(f"record category {cat}: {cat_counts.get(cat)} != {n}")
|
|
|
|
# Event text coverage: every event's title/body/choice keys exist in both
|
|
# shipped locales, and en_US must not leak raw Chinese.
|
|
import re
|
|
for loc in ("zh_CN", "en_US"):
|
|
p = ROOT / "data" / f"ui_text.{loc}.json"
|
|
strings = json.loads(p.read_text(encoding="utf-8"))["strings"]
|
|
for ev in pack["events"]:
|
|
keys = [ev["title_key"], ev["body_key"]] + [c["label_key"] for c in ev["choices"]]
|
|
for k in keys:
|
|
if k not in strings:
|
|
problems.append(f"{loc}: missing event text {k}")
|
|
elif loc == "en_US" and re.search(r"[\u4e00-\u9fff]", str(strings[k])):
|
|
problems.append(f"en_US event text {k} contains Chinese")
|
|
|
|
if problems:
|
|
print(f"CONTENT_QA_FAIL {len(problems)} problem(s)")
|
|
for p in problems[:30]:
|
|
print(" " + p)
|
|
return 1
|
|
print(f"CONTENT_QA_PASS {len(nodes)} nodes, {len(bosses)} named bosses, variety OK")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|