extends SceneTree ## PLAN-verb smoke: starts a shift, focuses one person, then exercises the verbs ## added after the radial pass — recognize, request reason, body camera, formal ## warning (which must arm the body camera), and blocking (which must move the ## guard between the person and the door). Also checks that an incident is ## actually recorded, then closing it at shift end. ## ## Usage: ## godot --headless --path . --script res://src/test/smoke_plan_verbs.gd ## Exit code 0 = pass, 1 = failure. const MAX_FRAMES := 1200 var frame := 0 var gm: Node = null var started := false var step := 0 var failures: Array[String] = [] func _initialize() -> void: root.size = Vector2i(1280, 720) root.add_child(load("res://scenes/main.tscn").instantiate()) func _process(_delta: float) -> bool: frame += 1 if gm == null: gm = root.find_child("GameManager", true, false) return false if not started: gm.call("_on_venue_selected", "hollywood_building") started = true return false if frame > MAX_FRAMES: _fail("timeout before the verbs ran") return true if frame < 200: return false if step == 0: if gm.npcs.is_empty(): _fail("no NPCs spawned to test the verbs on") return true var npc: Node = gm.npcs[0] gm.call("_on_guard_target", npc) var controller: Object = npc.get_npc_controller() gm.call("_recognize_target") _check(controller.player_recognized, "recognize marks the person as recognized") gm.call("_request_reason") _check(typeof(controller.last_reason_reply) == TYPE_STRING, "reason request returns a reply") gm.call("_set_body_camera", false, "smoke") _check(not gm.body_camera_on, "body camera can be switched off") gm.call("_apply_interaction", 2, "formal warning") _check(gm.body_camera_on, "formal warning arms the body camera") var before: Vector3 = gm.guard.global_position gm.call("_apply_interaction", 3, "blocking") _check(before.distance_to(gm.guard.global_position) > 0.05, "blocking moves the guard") _check(gm.coordinator.recorder.open_incidents_count() > 0 or gm.coordinator.recorder.incidents.size() > 0, "an incident was recorded") gm.coordinator.call("_finish_shift") _check(gm.coordinator.recorder.open_incidents_count() == 0, "open incidents close at shift end") _check(gm.coordinator.recorder.incidents.size() > 0, "shift history keeps the incident") step = 1 if step == 1: _finish() return true return false func _check(condition: bool, message: String) -> void: if condition: print("ok: " + message) else: _fail(message) func _fail(message: String) -> void: failures.append(message) _finish() func _finish() -> void: if failures.is_empty(): print("SMOKE OK: PLAN verbs (recognize, reason, body camera, warning, blocking)") quit(0) else: for message in failures: printerr("SMOKE FAIL: " + message) quit(1)