ADR-007 calls for full auto-chaining plus an expedition mode, but every node still ended at a result modal that required a manual click to continue. That is repeated, understood labour the incremental loop should automate while preserving the real decision. Added an auto-expedition toggle in the skyport (persisted in the profile). When on, clearing a normal node advances to the next available node after a short beat; the result modal shows the auto-advance action and the player can still cancel by returning to the map. The chain deliberately STOPS at event nodes (state-dependent player choices) and at the chapter boss (a milestone), so automation removes friction without automating the interesting decisions. Added an auto-run evidence test driving real BattleScene ticks and the real SceneTree timer: N01 chains to N02, event N04 is not an auto target, and a boss clear does not chain. tools/run_p2_checks.sh now runs 18 gates; all pass. Verified the toggle and its explanation render in a real captured skyport.
112 lines
3.8 KiB
GDScript
112 lines
3.8 KiB
GDScript
extends SceneTree
|
|
|
|
## Auto-expedition evidence.
|
|
##
|
|
## With auto_run on, clearing a normal node chains into the next available
|
|
## node after a short beat. The chain must STOP at events (a real choice) and
|
|
## at the chapter boss (a milestone). Turning it off keeps the old flow.
|
|
|
|
const OUTPUT_PATH := "res://artifacts/auto_run_test.json"
|
|
|
|
var _problems: Array = []
|
|
var _steps: Array = []
|
|
|
|
|
|
func _init() -> void:
|
|
_run.call_deferred()
|
|
|
|
|
|
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 profile := shell.get_profile()
|
|
profile["gold"] = 0
|
|
profile["crystal"] = 0
|
|
profile["hero_levels"] = {}
|
|
profile["unlocked_heroes"] = ["H01", "H02", "H03"]
|
|
profile["completed_nodes"] = []
|
|
profile["claimed_rewards"] = []
|
|
profile["auto_run"] = true
|
|
shell.set_auto_run_for_test(true)
|
|
|
|
# Next-auto-node logic: N01 first; events and boss must not be auto targets.
|
|
var first := shell.next_auto_node_for_test()
|
|
_check(first == "R1-C01-N01", "first auto node should be N01, got %s" % first)
|
|
_record("first_target", {"node": first})
|
|
|
|
# Clear N01 -> should auto-advance to N02 after the timer.
|
|
shell.start_node("R1-C01-N01")
|
|
await process_frame
|
|
await process_frame
|
|
var battle := shell.get_battle()
|
|
battle.set_process(false)
|
|
var guard := 0
|
|
while not battle.finished and guard < 900:
|
|
battle.advance_ticks(1)
|
|
guard += 1
|
|
await process_frame
|
|
await process_frame
|
|
_check(str(battle.state.get("result", "")) == "win", "N01 should be winnable")
|
|
# Wait past the 0.9s auto-advance timer using real process frames.
|
|
await _wait_seconds(1.1)
|
|
var active := shell.active_node_for_test()
|
|
_check(active == "R1-C01-N02", "auto-run should advance to N02, got %s" % active)
|
|
_record("auto_advanced", {"from": "R1-C01-N01", "to": active})
|
|
|
|
# Event nodes are not auto targets: when only an event is next, no chain.
|
|
profile = shell.get_profile()
|
|
profile["completed_nodes"] = ["R1-C01-N01", "R1-C01-N02", "R1-C01-N03"]
|
|
# N04 is an event and should block the chain.
|
|
var next := shell.next_auto_node_for_test()
|
|
_check(next.is_empty() or next != "R1-C01-N04", "event N04 must not be an auto target, got %s" % next)
|
|
_record("event_stops_chain", {"next": next})
|
|
|
|
# Boss clear: should not auto-advance even with auto_run on.
|
|
profile["completed_nodes"] = []
|
|
for n in ["R1-C01-N01", "R1-C01-N02", "R1-C01-N03", "R1-C01-N04",
|
|
"R1-C01-N05", "R1-C01-N06", "R1-C01-N07", "R1-C01-N08", "R1-C01-N09"]:
|
|
profile["completed_nodes"].append(n)
|
|
var should := shell.should_auto_advance_for_test("R1-C01-N10")
|
|
_check(not should, "boss clear must stop the auto chain")
|
|
_record("boss_stops_chain", {"should_advance": should})
|
|
|
|
var passed := _problems.is_empty()
|
|
var report := {
|
|
"schema": 1, "kind": "windroost_auto_run_test",
|
|
"overall": "PASS" if passed else "FAIL",
|
|
"problems": _problems, "steps": _steps,
|
|
}
|
|
var artifact_dir := ProjectSettings.globalize_path("res://artifacts")
|
|
DirAccess.make_dir_recursive_absolute(artifact_dir)
|
|
var file := FileAccess.open(artifact_dir.path_join("auto_run_test.json"), FileAccess.WRITE)
|
|
if file != null:
|
|
file.store_string(JSON.stringify(report, "\t", true))
|
|
file.close()
|
|
for entry in _steps:
|
|
print("AUTO_RUN_STEP %s" % JSON.stringify(entry))
|
|
if passed:
|
|
print("AUTO_RUN_PASS %d stages verified" % _steps.size())
|
|
else:
|
|
print("AUTO_RUN_FAIL %s" % "; ".join(_problems))
|
|
quit(0 if passed else 1)
|
|
|
|
|
|
func _wait_seconds(seconds: float) -> void:
|
|
var start := Time.get_ticks_msec()
|
|
while float(Time.get_ticks_msec() - start) / 1000.0 < seconds:
|
|
await process_frame
|
|
|
|
|
|
func _check(condition: bool, message: String) -> void:
|
|
if not condition:
|
|
_problems.append(message)
|
|
|
|
|
|
func _record(name: String, data: Dictionary) -> void:
|
|
var entry := data.duplicate()
|
|
entry["step"] = name
|
|
_steps.append(entry)
|