Capture current source, content data, tests, asset licenses, and original-specification traceability. Original implementation remains incomplete. The accepted matching UI generation passed 154 suites and 12,253 checks, with eight rendered staff-contract screens reviewed. Latest native Windows and full-original acceptance remain outstanding.
57 lines
4.0 KiB
GDScript
57 lines
4.0 KiB
GDScript
extends SceneTree
|
|
var checks := 0
|
|
var failures := 0
|
|
var runtime: Variant
|
|
var clock: Variant
|
|
var state: Variant
|
|
func expect(ok: bool, message: String) -> void:
|
|
checks += 1
|
|
if not ok: failures += 1; push_error(message)
|
|
func _initialize() -> void: call_deferred("run")
|
|
func build(id: StringName, origin: Vector3i) -> bool:
|
|
var result: CommandResult=runtime.submit_command(&"build_facility",{&"definition_id":id,&"origin":origin})
|
|
expect(result.is_success(),"normal build %s: %s" % [id,result.message])
|
|
if not result.is_success(): return false
|
|
clock.advance_minutes(runtime.definition_registry.get_facility(id).build_minutes)
|
|
return true
|
|
func run() -> void:
|
|
runtime=load("res://autoload/simulation_runtime.gd").new()
|
|
clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
|
clock.reset(1,6,0);state.reset();runtime.initialize(clock,state,42504);clock.set_paused(true)
|
|
expect(runtime.enable_production_operations()[&"ok"],"production operations enable physical staff rest")
|
|
var definition: FacilityDefinition=runtime.definition_registry.get_facility(&"staff_dormitory")
|
|
expect(definition!=null and definition.footprint==Vector2i(2,1) and definition.layer==1 and definition.customer_capacity==0,"normal dormitory definition has original geometry and excludes customer use")
|
|
if not build(&"warehouse",Vector3i(-6,0,1)) or not build(&"staff_dormitory",Vector3i(-6,2,1)) or not build(&"service_stairs",Vector3i(-7,1,1)) or not build(&"service_stairs",Vector3i(-7,2,1)): finish();return
|
|
var registered: CommandResult=runtime.submit_command(&"register_staff",{&"staff_id":&"dorm_sleeper",&"role_id":&"porter",&"options":{&"health":20,&"fatigue":20,&"current_cell":Vector3i(5,0,0),&"state":StaffRuntime.State.OFF_DUTY}})
|
|
expect(registered.is_success(),"register off-duty worker on front corridor")
|
|
var worker: StaffRuntime=runtime.staff_service.get_staff(&"dorm_sleeper")
|
|
var room_id: StringName=&""
|
|
for room: FacilityInstance in runtime.facility_service.get_instances():
|
|
if room.definition_id==&"staff_dormitory": room_id=room.instance_id
|
|
expect(runtime.path_service.find_path(Vector3i(5,0,0),Vector3i(-7,2,1)).is_empty(),"guest-access routing cannot enter dormitory via staff door and service stairs")
|
|
var snapshot: Dictionary=runtime.create_snapshot()
|
|
clock.advance_minutes(60)
|
|
expect(runtime.get_staff_rest_report(worker.staff_id).get(&"resting",false) and worker.current_cell==Vector3i(-7,2,1),"off-duty worker physically crosses staff door and stairs to dormitory")
|
|
expect(worker.health>20 and worker.fatigue<20,"staff recover only after reaching dormitory")
|
|
expect(runtime.get_staff_rest_report(worker.staff_id)[&"label"]=="宿舎で休憩中","status identifies dormitory instead of waiting room")
|
|
var arrived: Dictionary=runtime.create_snapshot()
|
|
expect(runtime.restore_snapshot(snapshot),"restore pre-rest movement")
|
|
clock.advance_minutes(60)
|
|
expect(runtime.create_snapshot()==arrived,"staff movement and recovery replay exactly")
|
|
worker=runtime.staff_service.get_staff(&"dorm_sleeper")
|
|
var health:=worker.health
|
|
state.set_resource(&"mana",0);clock.advance_minutes(30)
|
|
expect(worker.health==health and not runtime.get_staff_rest_report(worker.staff_id).get(&"resting",false),"unpowered dormitory stops recovery")
|
|
expect(runtime.restore_snapshot(runtime.create_snapshot()),"stopped dormitory and staff position restore")
|
|
worker=runtime.staff_service.get_staff(&"dorm_sleeper")
|
|
state.set_resource(&"mana",100);clock.advance_minutes(40)
|
|
expect(worker.health>health,"power recovery resumes rest")
|
|
runtime.facility_service.set_operational_status(room_id,{&"operator_open":false},clock.absolute_minute)
|
|
health=worker.health;clock.advance_minutes(30)
|
|
expect(worker.health==health,"closed dormitory cannot restore health")
|
|
expect(runtime.restore_snapshot(runtime.create_snapshot()),"closed dormitory remains saveable")
|
|
finish()
|
|
func finish() -> void:
|
|
runtime.free();clock.free();state.free()
|
|
print("Staff dormitory: %d checks, %d failures" % [checks,failures]);quit(failures)
|