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)