Files
windroost/p2_godot_sample/scripts/skill_runtime_ui_test.gd
T
wushenghua 9da35bcbc5 feat: per-hero skill archetypes for all 54 heroes (stage B complete)
Continued PRODUCTION/51. Skills are now real, differentiated data for every
hero, built on stage-A effect primitives (no longer just name strings):

- skill_archetypes.py: 15 archetypes -> effect-primitive definitions, assigns
  each of 54 heroes 4 skills (a1/a2/passive/ultimate) by signature direction +
  origin, with per-hero value scales so all 54 combos are unique (ADR-008).
  Output data/hero_skills.json (symlinked into Godot project data/).
- hero_skill_loader.py / .gd: scales coefficient values by hero base DPS into
  runtime `skills`; parity 6 heroes python==gd.
- check_hero_skills.py PASS: 54 heroes/15 archetypes unique, py==gd, and 6
  signature heroes yield 6 distinct combat outcomes.
- REAL RUNTIME: game_root.gd injects skills like growth_modifiers on the live
  P3a node path. run_skill_runtime_ui_test.sh PASS in actual game_root ->
  battle_scene battle: H01 fires damage/debuff/buff/execute, H05 fires
  buff/summon/shield/cleanse -- completely distinct primitive sets.
- 2 new gates registered; full P2_CHECKS_PASS (72 gates), identity preserved.

This directly addresses "不能敷衍,各种系统不能全部都一样": each hero now
triggers its own real combat effects. Stages C-E (talent behaviour, edict rules,
enemy/boss mechanics) remain. prototype/ untracked.
2026-11-19 13:39:19 +08:00

103 lines
3.1 KiB
GDScript

extends SceneTree
## Real-runtime proof (game_root -> battle_scene -> sim): different unlocked
## heroes fire DIFFERENT skill-effect primitives in an actual battle, with the
## skill pack attached by the live game shell (not a test-only scenario).
const OUTPUT_PATH := "res://artifacts/skill_runtime_ui_test.json"
const NODE := "R1-C01-N01"
var _problems: Array = []
var _records: Array = []
func _init() -> void:
_run.call_deferred()
func _fail(msg: String) -> void:
_problems.append(msg)
func _run() -> void:
var shell := load("res://scenes/game_root.tscn").instantiate() as GameRoot
root.add_child(shell)
await process_frame
await process_frame
var sets := {
"H01": ["H01"], # single: pierce/single_strike/buff/execute
"H05": ["H05"], # tempo: buff/summon/shield/cleanse
}
var primitive_sets := {}
for key in sets.keys():
var profile := shell.get_profile()
profile["gold"] = 0
profile["crystal"] = 0
profile["hero_levels"] = {}
profile["unlocked_heroes"] = sets[key]
profile["completed_nodes"] = []
profile["claimed_rewards"] = []
shell.start_node(NODE)
await process_frame
await process_frame
var battle := shell.get_battle()
if battle == null:
_fail("%s: no battle instance" % key)
continue
battle.set_process(false)
var guard := 0
while not battle.finished and guard < 600:
battle.advance_ticks(1)
guard += 1
var skill_prims := {}
var skill_count := 0
for e in battle.state.get("event_log", []):
if str((e as Dictionary).get("type", "")) == "skill_effect":
skill_count += 1
var p := str((e as Dictionary).get("primitive", ""))
skill_prims[p] = int(skill_prims.get(p, 0)) + 1
primitive_sets[key] = skill_prims
_records.append({"set": key, "skill_events": skill_count,
"primitives": skill_prims, "result": battle.state.get("result", "")})
if skill_count <= 0:
_fail("%s: no skill_effect events fired in real battle" % key)
var a = primitive_sets.get("H01", {})
var b = primitive_sets.get("H05", {})
var ka = {}
for p in a.keys():
ka[p] = true
var kb = {}
for p in b.keys():
kb[p] = true
var only_a: Array = []
for p in ka.keys():
if not kb.has(p):
only_a.append(p)
var only_b: Array = []
for p in kb.keys():
if not ka.has(p):
only_b.append(p)
if only_a.is_empty() or only_b.is_empty():
_fail("H01 and H05 must fire distinct primitive sets; only_H01=%s only_H05=%s" % [only_a, only_b])
var payload := {"records": _records, "only_H01": only_a, "only_H05": only_b,
"problems": _problems}
var dir := ProjectSettings.globalize_path("res://artifacts")
DirAccess.make_dir_recursive_absolute(dir)
var f := FileAccess.open(OUTPUT_PATH, FileAccess.WRITE)
if f != null:
f.store_string(JSON.stringify(payload, "\t", true))
f.close()
for rec in _records:
print("SKILL_UI %s events=%d prims=%s result=%s" % [rec["set"], rec["skill_events"],
str(rec["primitives"]), rec["result"]])
if _problems.is_empty():
print("SKILL_UI_PASS distinct primitives in real runtime")
else:
print("SKILL_UI_FAIL %d problem(s)" % _problems.size())
for p in _problems:
print(" " + p)
quit(0 if _problems.is_empty() else 1)