Files
windroost/tools/fullgame/event_text.py
T
wushenghua d2904d6935 feat: full-game expedition world UI over 600 nodes (L3/L5 runtime)
Continued FULL_GAME_GOAL. The 600-node world existed as data+engine but the
playable map still used the 10-node slice. Added an additive world navigator
that leaves the proven slice loop untouched.

- Skyport entry -> 远征世界 page: 5 region tabs / 12 chapters / 10 nodes
  (two-column grids), lock rule order <= highest_node+1, node detail card and
  launch CTA placed above the lists so they are visible on 390x844.
- Launch runs a real WorldContent scenario through the shared battle shell
  with growth modifiers applied. Victory routes through battle_finished:
  grants gold/crystal once, advances highest_node, derives chapter/region/boss/
  final counters from the cleared set, accumulates prestige essence source;
  defeat returns to the world. zh/en labels incl. 60 chapter-theme translations.
- Fixed two real bugs uncovered while wiring: WorldContent's regions()/
  chapters()/nodes() did not initialise the lazy cache (first open rendered
  empty), and GameRoot paused the battle after setup with no resume, freezing
  real-time play at frame 0. Tests can still pause explicitly after start_node.
- world_map_ui_test drives navigation/lock/launch/win/locale through real UI
  hooks; registered in the full gate. Added a p3a_world capture shot and the
  regenerated-artifact ignore entries.

All gates pass incl. 24 UI captures; P2_CHECKS_PASS. prototype/ untracked.
2026-11-18 16:15:59 +08:00

128 lines
6.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""Generate real event texts for all 60 full-game events (L4 content).
Each event gets a title, body and two choice labels, built from its chapter
theme + one of several event archetypes rotated so texts vary. zh_CN + en_US.
Merges into data/ui_text.<locale>.json (idempotent: existing keys untouched).
"""
from __future__ import annotations
import json
from pathlib import Path
from typing import Any, Dict
ROOT = Path(__file__).resolve().parents[2]
PACK = ROOT / "data" / "full_game_content.json"
# (zh title pattern, zh body, choice A zh, choice B zh, en title, en body, en A, en B)
ARCHETYPES = [
("废弃的{theme}", "旅团在{theme}发现一处弃置营地。救援幸存者,还是搜刮物资?",
"救援(金币+{g1},风晶+1)", "搜刮(金币+{g2})",
"Abandoned {theme}", "The company finds a derelict camp at {theme}. Rescue the survivors or strip the supplies?",
"Rescue (+{g1} gold, +1 crystal)", "Scavenge (+{g2} gold)"),
("{theme}的抉择", "{theme}的守路人提出交易:用金币换情报,或用风晶换安全通行。",
"购买情报(金币-{g3},风晶+1)", "支付通行(金币-{g4})",
"Choice at {theme}", "A watchkeeper at {theme} offers a trade: gold for intel, or crystal for safe passage.",
"Buy intel (-{g3} gold, +1 crystal)", "Pay passage (-{g4} gold)"),
("{theme}的宝藏", "传说{theme}埋着一份宝藏,但守卫仍在。强攻还是智取?",
"强攻(金币+{g2},风险)", "智取(金币+{g1},风晶+1)",
"Treasure of {theme}", "A hoard is said to lie in {theme}, but guards remain. Assault or cunning?",
"Assault (+{g2} gold, risky)", "Cunning (+{g1} gold, +1 crystal)"),
]
def theme_zh(chapter: str, pack: Dict[str, Any]) -> str:
for n in pack["nodes"]:
if n["chapter"] == chapter:
return n["theme"]
return chapter
THEME_EN = {
# R1
"破风码头": "Windbreak Docks", "草原航线": "Grassland Route", "空盗侦察": "Bandit Scout",
"风车荒地": "Windmill Wastes", "失控风门": "Runaway Windgate", "狼群高地": "Wolf Highlands",
"云上商路": "Skybound Trade Road", "风暴前哨": "Storm Outpost", "破碎航标": "Broken Beacon",
"红鸢封锁线": "Red Kite Blockade", "天兽巢穴": "Skybeast Den", "平原地区战": "Plains Regional Battle",
# R2
"林缘雾径": "Mistwood Edge", "月泉": "Moon Spring", "毒藤谷": "Poisonvine Vale",
"暗影树海": "Shadowwood", "叛军箭路": "Rebel Archer Path", "根须迷宫": "Root Maze",
"精灵旧城": "Ancient Elf City", "夜行林冠": "Night Canopy", "古树记忆": "Elder Tree Memory",
"影狼祭场": "Shadow Wolf Rite", "毒冠王庭": "Poison Crown Court", "森林地区战": "Forest Regional Battle",
# R3
"山脚矿道": "Foothill Mines", "铆钉桥": "Rivet Bridge", "熔炉入口": "Furnace Entrance",
"地精工坊": "Goblin Workshop", "岩脉隧道": "Vein Tunnel", "断裂升降台": "Broken Lift",
"旧王矿井": "Old King's Shaft", "火山风口": "Volcanic Vent", "龙骨峡": "Dragonbone Gorge",
"爆破大师营": "Bombmaster Camp", "熔炉王座": "Furnace Throne", "山脉地区战": "Mountain Regional Battle",
# R4
"沙海边缘": "Sand Sea Edge", "失水驿站": "Dry Waystation", "埋骨商路": "Bone Road",
"盗墓入口": "Tomb Entrance", "古井阶梯": "Ancient Well Stairs", "太阳神殿": "Sun Temple",
"沙虫巢": "Sandworm Nest", "王城外墙": "Capital Walls", "诅咒宫门": "Cursed Gate",
"亡祭大殿": "Death Rite Hall", "沙暴王庭": "Sandstorm Court", "沙漠地区战": "Desert Regional Battle",
# R5
"云海断桥": "Broken Cloud Bridge", "风暴阶梯": "Storm Stairs", "天空守卫站": "Sky Guard Post",
"虚空裂口": "Void Rift", "古代机械层": "Ancient Machinery", "失重回廊": "Weightless Hall",
"星辉观测台": "Starlight Observatory", "风暴核心": "Storm Core", "神殿外环": "Temple Outer Ring",
"虚空先知庭": "Void Prophet Court", "巨像封印": "Colossus Seal", "天空神殿终局": "Sky Temple Finale",
}
def theme_en(theme_zh_: str) -> str:
return THEME_EN.get(theme_zh_, theme_zh_)
def generate(pack: Dict[str, Any]) -> Dict[str, Dict[str, str]]:
out = {"zh_CN": {}, "en_US": {}}
for i, ev in enumerate(pack["events"]):
ck = ev["chapter"]
th = theme_zh(ck, pack)
a = ARCHETYPES[i % len(ARCHETYPES)]
g1 = ev["choices"][0]["gold"]
g2 = ev["choices"][1]["gold"]
g3 = int(g1 * 0.6)
g4 = int(g2 * 0.5)
f = lambda s: s.format(theme=th, g1=g1, g2=g2, g3=g3, g4=g4)
out["zh_CN"][ev["title_key"]] = f(a[0])
out["zh_CN"][ev["body_key"]] = f(a[1])
out["zh_CN"][ev["choices"][0]["label_key"]] = f(a[2])
out["zh_CN"][ev["choices"][1]["label_key"]] = f(a[3])
th_en = theme_en(th)
fe = lambda s: s.format(theme=th_en, g1=g1, g2=g2, g3=g3, g4=g4)
out["en_US"][ev["title_key"]] = fe(a[4])
out["en_US"][ev["body_key"]] = fe(a[5])
out["en_US"][ev["choices"][0]["label_key"]] = fe(a[6])
out["en_US"][ev["choices"][1]["label_key"]] = fe(a[7])
# World-map theme labels: one per chapter, used by the expedition page in
# both shipped locales. Keyed by chapter so all 10 nodes share it.
seen = set()
for n in pack["nodes"]:
ck = n["chapter"]
if ck in seen:
continue
seen.add(ck)
out["zh_CN"][f"world.theme.{ck}"] = n["theme"]
out["en_US"][f"world.theme.{ck}"] = theme_en(n["theme"])
return out
def main() -> int:
pack = json.loads(PACK.read_text(encoding="utf-8"))
texts = generate(pack)
# Merge into main tables (do not overwrite existing slice keys).
for loc in ("zh_CN", "en_US"):
p = ROOT / "data" / f"ui_text.{loc}.json"
data = json.loads(p.read_text(encoding="utf-8"))
before = len(data["strings"])
# These event keys are owned by this generator; overwrite them so
# translation improvements propagate (slice keys are never in this set).
for k, v in texts[loc].items():
data["strings"][k] = v
after = len(data["strings"])
p.write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
print(f"{loc}: +{after-before} keys (total {after})")
return 0
if __name__ == "__main__":
raise SystemExit(main())