Files
windroost/tools/fullgame/generate_content.py
T
wushenghua 3e8346da94 content: port full-game generator, QA and enemy/hero contracts
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.
2026-11-29 10:10:38 +08:00

444 lines
19 KiB
Python

#!/usr/bin/env python3
"""Generate the FULL-GAME content pack from the design grammar (L0).
Produces every content family with stable IDs per CONTENT_PLAN 1.1, combining
the design tables with deterministic templates. Nothing is hand-invented:
names/themes/signatures come from tables.py (transcribed from the design docs);
stats follow the existing launch content ratios and scale per region.
Output: data/full_game_content.json (the scalable successor to mvp_launch_content.json)
The old mvp_launch_content.json (6/10/10 slice) stays intact for the current
runtime; this pack is the authoring source for the full-game build.
Usage:
python3 tools/fullgame/generate_content.py --dry-run
python3 tools/fullgame/generate_content.py --write
"""
from __future__ import annotations
import argparse
import hashlib
import json
import math
from pathlib import Path
from typing import Any, Dict, List
import tables as T
import ch_curve as CH
ROOT = Path(__file__).resolve().parents[2]
OUT = ROOT / "data" / "full_game_content.json"
# WR-151: single source of truth for main-line battle-node HP growth.
# ch_curve.py is the canonical CH formula; check_ch_curve_parity.py proves the
# GDScript mirror (ChCurve.node_hp) agrees with it. No other curve is invented.
CH_CURVE_MODE = "playable"
def node_curve_index(region: int, chapter: int, node: int) -> int:
"""0-based index into the 600-node CH curve (R1-C01-N01 -> 0, R5-C12-N10 -> 599)."""
return (region - 1) * 120 + (chapter - 1) * 10 + (node - 1)
def eid(prefix: str, n: int, width: int = 2) -> str:
return f"{prefix}{n:0{width}d}"
def origin_for(n: int) -> str:
return T.ORIGIN_ORDER[(n - 1) // 6]
def sig_for(n: int) -> str:
return T.SIG_ORDER[(n - 1) % 6]
def scale_for(region: int) -> float:
# Gentle geometric scaling per region (design: difficulty grows per region).
return round(1.0 + 0.6 * (region - 1), 3)
def build_heroes() -> List[Dict[str, Any]]:
heroes = []
flat = [name for row in T.HERO_NAMES for name in row]
for i, name in enumerate(flat, 1):
sig = sig_for(i)
origin = origin_for(i)
culture, mech = T.ORIGINS[origin]
a1, a2, passive, ult = T.SIGNATURES[sig]
# base stats follow the 6-hero launch ratio, nudged by origin index
tier = (i - 1) // 6
base_dps = round(8 + 1.2 * tier + (T.SIG_ORDER.index(sig) % 3), 1)
heroes.append({
"id": eid("H", i), "name": name, "origin": origin, "culture": culture,
"mechanic": mech, "signature": sig, "base_dps": base_dps,
"signature_dps": round(base_dps * 0.45, 1),
"abilities": {"a1": a1, "a2": a2, "passive": passive, "ultimate": ult},
"unlock": T.hero_unlock_node(i),
"art_id": eid("H", i),
})
return heroes
def build_talents(heroes: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
"""Structured talents: every hero has >=2 behaviour-changing talents
(skill + ultimate per CONTENT_PLAN 3.1), not just +10% stat sticks."""
talents = []
for h in heroes:
sig = h["signature"]
behaviors = T.SIGNATURE_BEHAVIOR[sig] # [(skill behaviour, ultimate behaviour)]
for j in range(1, T.COUNTS["talents_per_hero"] + 1):
slot = T.TALENT_SLOTS[j]
a = h["abilities"][["a1", "a2", "passive", "ultimate"][j - 1]]
# slots 3 and 4 change behaviour; slots 1/2 bias stats but also
# carry a hook so no talent is a bare "+10%".
if j == 3:
behavior = behaviors[0][0]
changes_behavior = True
elif j == 4:
behavior = behaviors[1][0]
changes_behavior = True
elif j == 1:
behavior = f"基础攻击方向:{a}"
changes_behavior = False
else:
behavior = f"目标选择方向:{a}"
changes_behavior = False
talents.append({
"id": f"T-{h['id']}-{j:02d}", "hero": h["id"], "slot": j,
"slot_purpose": slot["purpose"], "hook": slot["hook"],
"effect_label": a, "behavior": behavior,
"changes_behavior": changes_behavior,
"stat": slot["stat"], "stat_value": round(0.04 + 0.02 * j, 3),
"kind": "hero_talent", "reset": "rebuild_and_new_sky",
})
for g in range(1, T.COUNTS["global_talents"] + 1):
# Global talents favour unlocks/conversions/limits over raw multiply
# (CONTENT_PLAN 3.2): mostly rule changes, a few stat caps.
rule = "解锁/转换/上限/替代规则" if g <= 19 else "场外指挥/战功/自动化"
talents.append({"id": f"T-G{g:02d}", "kind": "global_talent",
"effect_label": rule, "changes_behavior": g <= 19,
"behavior": rule, "stat": "global", "stat_value": 0.02,
"reset": "rebuild_and_new_sky"})
return talents
def build_enemies() -> List[Dict[str, Any]]:
# 120 = 5 regions * 6 families * 4 variants (CONTENT_PLAN 1.1 ID grammar
# E-R1-F1-V1 .. E-R5-F5-V4; 6th family reaches 120).
enemies = []
for r in range(1, 6):
scale = scale_for(r)
families = T.ENEMY_FAMILIES[f"R{r}"] # 5 named families (name, mechanic)
for f in range(1, 7):
fname, mechanic = families[(f - 1) % len(families)]
family_weak = T.ENEMY_WEAK_TAGS[f"R{r}"][(f - 1) % len(families)]
for v in range(1, 5):
if v == 1:
weak = family_weak
else:
alternatives = [tag for tag in T.WEAK_TAG_ORDER if tag != family_weak]
weak = alternatives[v - 2]
enemies.append({
"id": f"E-R{r}-F{f}-V{v}",
"name": fname if v == 1 else f"{fname}·{['普通','精英','装甲','异变'][v-1]}",
"mechanic": mechanic,
"region": f"R{r}", "family": f, "variant": v, "art_id": "EG01",
"base_hp": round(120 * scale * (1 + 0.08 * (f - 1)) * (1 + 0.05 * (v - 1)), 1),
"weak_tag": weak, "armor": 1 + (r - 1),
})
return enemies[:T.COUNTS["enemies"]]
# Windroost-adapted boss adapter fields (FL-03B). Provenance:
# - source-bound MVP boss (data/mvp_launch_content.json / mvp_battle_rules.json):
# B-R1-01 hp=1500, armor=5, shield=200, timer_sec=30, weak_tag=break,
# rebuild_at=[8,16], rebuild_amount=420.
# - CH-derived timer_sec=30 (BATTLE_RULES_AND_NUMERIC_SPEC.md §2.2,
# CH_TO_WINDROOST_FIELD_MAPPING.md L31, PRODUCTION/00-launch-content-data-pack.md L157).
# - weak_tag taxonomy follows the MVP enemy/boss mapping in 20-launch-binding-table.md:
# shield/armor-break/weak-point -> break; marked/lock -> click;
# poison/curse/heal-block/life-link/burn -> sustain; area/summon/field ->
# aoe; otherwise single.
# - rebuild bundle exists only with a shield keyword. Timing [8,16] and the
# ratios shield=base_hp*200/1500, amount=shield*420/200 come from MVP B-R1-01.
# No shield keyword -> explicit []/0.0 (mirrors MVP no-shield enemies).
MVP_BOSS_SOURCE = {
"id": "B-R1-01", "hp": 1500.0, "armor": 5.0, "shield_max": 200.0,
"timer_sec": 30, "weak_tag": "break", "rebuild_at": [8.0, 16.0],
"rebuild_amount": 420.0,
}
def derive_boss_adapter(row: Dict[str, Any]) -> Dict[str, Any]:
"""Explicit, auditable adapter fields; no generic ID fallback."""
if row["id"] == MVP_BOSS_SOURCE["id"]:
return {k: MVP_BOSS_SOURCE[k] for k in
("hp", "armor", "shield_max", "timer_sec", "weak_tag",
"rebuild_at", "rebuild_amount")}
mech = row["mechanics"]
if any(k in mech for k in ("护盾", "机械护盾", "破甲", "弱点")):
weak = "break"
elif any(k in mech for k in ("标记", "锁定")):
weak = "click"
elif any(k in mech for k in ("毒", "诅咒", "禁疗", "生命链接", "灼烧")):
weak = "sustain"
elif any(k in mech for k in ("扇形", "召唤", "增援", "全队", "全场", "连锁",
"风暴", "旋刃", "场地", "倒计时", "陷阱", "熔岩", "雷击")):
weak = "aoe"
else:
weak = "single"
has_shield = "护盾" in mech
shield = round(row["base_hp"] * 200.0 / 1500.0, 1) if has_shield else 0.0
return {
"hp": row["base_hp"], "armor": 1.0, "shield_max": shield,
"timer_sec": 30, "weak_tag": weak,
"rebuild_at": [8.0, 16.0] if has_shield else [],
"rebuild_amount": round(shield * 420.0 / 200.0, 1) if has_shield else 0.0,
}
def build_bosses() -> List[Dict[str, Any]]:
bosses = []
for r in range(1, 6):
scale = scale_for(r)
named = T.BOSSES[f"R{r}"] # 4 named bosses (name, mechanics)
for b in range(1, 5): # 5 regions * 4 = 20
bname, mech = named[b - 1]
row = {
"id": f"B-R{r}-{b:02d}", "name": bname, "mechanics": mech,
"region": f"R{r}", "art_id": "B01",
"base_hp": round(2000 * scale * b, 1),
"phases": 3 if "三阶段" in mech else 2,
}
row.update(derive_boss_adapter(row))
bosses.append(row)
return bosses
def build_nodes() -> List[Dict[str, Any]]:
nodes = []
boss_idx = 0
for r in range(1, 6):
rk = f"R{r}"
for c in range(1, 13):
ck = f"{rk}-C{c:02d}"
theme = T.CHAPTER_THEMES[rk][c - 1]
innovation = T.INNOVATIONS[(c - 1) % 10]
for n in range(1, 11):
ntype = T.NODE_TYPES[n - 1]
enemies = []
if ntype in ("normal", "elite", "boss", "trial"):
fam = (c + n - 1) % 6 + 1
enemies = [f"E-R{r}-F{fam}-V{(n-1)%4+1}"]
if ntype in ("elite", "boss"):
enemies.append(f"E-R{r}-F{fam%6+1}-V{n%4+1}")
reward_id = f"REWARD-{ck}-N{n:02d}"
node = {
"id": f"{ck}-N{n:02d}", "chapter": ck, "region": rk,
"index": n, "type": ntype, "theme": theme, "innovation": innovation,
"waves": [enemies] if enemies else [], "reward_id": reward_id,
"gold": round(30 * scale_for(r) * (1.15 ** (n - 1))),
"crystal": 1 if ntype in ("elite", "boss") and n == 10 else 0,
}
if ntype in ("normal", "elite", "boss"):
# WR-151: traceable CH HP multiplier on every existing-wave
# main-line battle row. WorldContent.scenario_for_node copies
# node.hp_scale into scenario.hp_scale; BattleSim.create_state
# applies it to enemy hp/max_hp. Event/shop/supply (empty
# waves), trial, the 10-node launch slice, economy, heroes
# and UI stay untouched.
node["hp_scale"] = CH.node_hp(
node_curve_index(r, c, n), 600, CH_CURVE_MODE)
if ntype == "boss":
boss_idx += 1
boss = f"B-R{r}-{(c % 4) + 1:02d}"
node["waves"] = [[boss]]
node["boss"] = boss
# FL-03-FINAL: bind the accepted adapter timer to the canonical
# N10 full-mode scenario only. 30s comes from MVP_BOSS_SOURCE
# (CH-derived baseline); WorldContent.scenario_for_node reads
# node timeout_seconds. No other node timing is changed.
if node["id"] == "R1-C01-N10":
node["timeout_seconds"] = MVP_BOSS_SOURCE["timer_sec"]
nodes.append(node)
return nodes
def build_events() -> List[Dict[str, Any]]:
events = []
for r in range(1, 6):
for c in range(1, 13):
ck = f"R{r}-C{c:02d}"
events.append({
"id": f"EV-{ck}", "chapter": ck,
"title_key": f"event.{ck}.title", "body_key": f"event.{ck}.body",
"choices": [
{"id": "rescue", "label_key": f"event.{ck}.rescue", "gold": 20 + 5 * r, "crystal": 1},
{"id": "take", "label_key": f"event.{ck}.take", "gold": 40 + 10 * r, "crystal": 0},
],
})
return events
def build_simple(prefix: str, count: int, reset: str, width: int = 2,
tier_field: bool = False, **extra: Any) -> List[Dict[str, Any]]:
rows = []
for i in range(1, count + 1):
row = {"id": eid(prefix, i, width), "reset": reset}
if tier_field:
row["tier"] = i
row.update(extra)
rows.append(row)
return rows
# WR-172: per-oath CH Ancient cost source. This is a COST-ONLY binding: the
# oath's effect still comes from oath_rules + stat_value, never from the Ancient
# name. 17 direct bindings (WR164 draft B) keep high semantic confidence; the
# 9 formerly-CUSTOM rows are assigned only a cost curve source at LOW confidence
# by owner decision. All 26 ids are unique and resolve in cf_reference/ancients.
OATH_CH_SOURCE = {
"O01": (5, "high"), "O02": (15, "high"), "O03": (12, "low"),
"O04": (23, "low"), "O05": (25, "low"), "O06": (29, "high"),
"O07": (7, "low"), "O08": (18, "high"), "O09": (17, "low"),
"O10": (6, "high"), "O11": (32, "high"), "O12": (27, "low"),
"O13": (20, "high"), "O14": (24, "high"), "O15": (21, "low"),
"O16": (3, "low"), "O17": (8, "high"), "O18": (28, "high"),
"O19": (30, "high"), "O20": (4, "high"), "O21": (11, "high"),
"O22": (19, "high"), "O23": (22, "high"), "O24": (16, "high"),
"O25": (31, "low"), "O26": (13, "high"),
}
def build_oaths() -> List[Dict[str, Any]]:
"""26 oaths in 5 direction groups; each changes a resource/rule bucket."""
out = []
n = 0
for group, count, bucket, themes in T.OATH_GROUPS:
for j in range(count):
n += 1
oid = f"O{n:02d}"
source_id, confidence = OATH_CH_SOURCE[oid]
out.append({
"id": oid, "name": f"{themes[j]}誓约", "group": group,
"bucket": bucket, "theme": themes[j],
"stat_value": 0.03 + 0.01 * (j % 3),
"max_core": 3, "reset": "new_sky_resets",
"ch_ancient_id": source_id,
"ch_source_confidence": confidence,
})
return out
def build_edicts() -> List[Dict[str, Any]]:
"""9 global directions, each changing one resource/rule (not a multiplier)."""
out = []
for i, (name, bucket, desc) in enumerate(T.EDICT_DIRECTIONS, 1):
out.append({
"id": f"D{i:02d}", "name": f"{name}律令", "bucket": bucket,
"description": desc, "stat_value": 0.03 + 0.01 * (i % 3),
"reset": "permanent",
})
return out
def build_gear() -> List[Dict[str, Any]]:
"""20 families x 6 slots = 120 gear, each with a real stat bucket, the
signature it answers, and a recommended scene (CONTENT_PLAN 7.1/7.2)."""
gear = []
n = 0
scenes = {"single": "单体/Boss", "aoe": "群体清场", "break": "破甲/护盾",
"click": "点击爆发", "tempo": "自动化节奏", "sustain": "持续/召唤"}
for fi, family in enumerate(T.GEAR_FAMILIES):
for si, slot in enumerate(T.GEAR_SLOTS):
n += 1
stat = T.GEAR_SLOT_STAT[slot]
sig = T.GEAR_FAMILY_SIGNATURE[family]
gear.append({
"id": f"G{n:03d}", "name": f"{family}·{slot}",
"family": family, "slot": slot, "stat": stat,
"stat_value": round(0.02 + 0.01 * si, 3),
"signature": sig, "recommended_scene": scenes[sig],
"reset": "rebuild_and_new_sky",
})
return gear
def build_records() -> List[Dict[str, Any]]:
"""167 records across 9 categories, counts from CONTENT_PLAN 11."""
records = []
n = 0
for cat, count, theme in T.RECORD_CATEGORIES:
for j in range(1, count + 1):
n += 1
# Stage rewards (milestones), not daily sign-in; no miss penalty.
rid = f"A{n:03d}"
# WR-163: A137/A142 move from 伙伴 to the 驻扎 (garrison) metric;
# id, order, reward_kind and reward amount stay unchanged.
record_cat = "驻扎" if rid in ("A137", "A142") else cat
record_theme = "安排驻扎/单槽/离线收益" if rid in ("A137", "A142") else theme
records.append({
"id": rid, "category": record_cat, "theme": record_theme,
"order": j, "reward_kind": "stage" if j % 3 == 0 else "one_time",
"miss_penalty": False, "reset": "permanent",
})
return records
def generate() -> Dict[str, Any]:
heroes = build_heroes()
talents = build_talents(heroes)
enemies = build_enemies()
bosses = build_bosses()
nodes = build_nodes()
events = build_events()
gear = build_gear()
relics = build_simple("L", T.COUNTS["relics"], "permanent", tier_field=True)
oaths = build_oaths()
edicts = build_edicts()
partners = []
for i, (pname, prole) in enumerate(T.PARTNERS, 1):
partners.append({"id": f"P{i:02d}", "name": pname, "role": prole,
"combat": False, "reset": "permanent"})
market = []
for i, cat in enumerate(T.MARKET_CATEGORIES, 1):
market.append({"id": f"M{i:02d}", "category": cat, "currency": "crystal",
"pay_to_win": False})
records = build_records()
pack = {
"schema": 1, "kind": "full_game_content", "status": "generated_grammar",
"source": "FINAL_GAME_DESIGN.md / CONTENT_PLAN.md via tools/fullgame",
"counts": {k: len(v) for k, v in {
"heroes": heroes, "talents": talents, "enemies": enemies, "bosses": bosses,
"nodes": nodes, "events": events, "gear": gear, "relics": relics,
"oaths": oaths, "edicts": edicts, "records": records, "partners": partners,
"market": market,
}.items()},
"heroes": heroes, "talents": talents, "enemies": enemies, "bosses": bosses,
"nodes": nodes, "events": events, "gear": gear, "relics": relics,
"oaths": oaths, "edicts": edicts, "records": records, "partners": partners,
"market": market,
}
return pack
def main() -> int:
ap = argparse.ArgumentParser(description=__doc__)
ap.add_argument("--write", action="store_true")
ap.add_argument("--dry-run", action="store_true")
args = ap.parse_args()
pack = generate()
print(json.dumps({"counts": pack["counts"], "output": str(OUT)}, ensure_ascii=False, indent=2))
if args.write:
data = json.dumps(pack, ensure_ascii=False, indent=2) + "\n"
OUT.write_text(data, encoding="utf-8")
print("sha256", hashlib.sha256(data.encode()).hexdigest())
print("WROTE", OUT)
else:
print("DRY_RUN only; pass --write to produce the pack.")
return 0
if __name__ == "__main__":
raise SystemExit(main())