Files
TheTree_mock/tests/staff/test_shift_rush.gd
T
Takeshi 5dde0c5ec2 Record original-alignment implementation and traceability checkpoint
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.
2026-09-30 23:52:24 +09:00

56 lines
3.6 KiB
GDScript

extends SceneTree
var checks := 0
var failures := 0
func _initialize() -> void: call_deferred("run")
func expect(ok: bool, message: String) -> void:
checks += 1
if not ok: failures += 1;push_error(message)
else: print("PASS: ",message)
func run() -> void:
var clock: Variant = load("res://autoload/game_clock.gd").new()
var state: Variant = load("res://autoload/game_state.gd").new()
var runtime: Variant = load("res://autoload/simulation_runtime.gd").new()
clock.reset(1,6,0);state.reset();runtime.initialize(clock,state,719);clock.set_paused(true)
var origins: Array[Vector3i] = [Vector3i(-10,0,1),Vector3i(-6,0,1),Vector3i(2,0,1),Vector3i(6,0,1)]
for origin: Vector3i in origins:
expect(runtime.submit_command(&"build_facility",{&"definition_id":&"infirmary",&"origin":origin},&"player").is_success(),"build real workplace for shift rush")
clock.advance_minutes(80)
var rooms: Array = runtime.facility_service.get_instances()
for i: int in 8:
var id := StringName("day_%02d" % i)
expect(runtime.submit_command(&"register_staff",{&"staff_id":id,&"role_id":&"medic",&"options":{&"current_cell":Vector3i(0,0,1),&"role_tags":[&"medic"]}},&"player").is_success(),"register daytime employee")
expect(runtime.submit_command(&"set_staff_work_assignment",{&"staff_id":id,&"facility_id":rooms[i/2].instance_id,&"template_id":&"DAY"},&"player").is_success(),"assign daytime employee")
clock.advance_minutes(1079-clock.absolute_minute)
for i: int in 8:
var id := StringName("night_%02d" % i)
expect(runtime.submit_command(&"register_staff",{&"staff_id":id,&"role_id":&"medic",&"options":{&"current_cell":Vector3i(0,0,1),&"role_tags":[&"medic"]}},&"player").is_success(),"register nighttime employee")
expect(runtime.submit_command(&"set_staff_work_assignment",{&"staff_id":id,&"facility_id":rooms[i/2].instance_id,&"template_id":&"NIGHT"},&"player").is_success(),"assign nighttime employee")
clock.advance_minutes(1)
var off_duty := 0
var commuting := 0
var slowed := 0
for i: int in 8:
if runtime.staff_service.get_staff(StringName("day_%02d" % i)).state == StaffRuntime.State.OFF_DUTY: off_duty += 1
var credit: Dictionary = runtime._movement_credits.get(StringName("staff:night_%02d" % i),{})
if int(credit.get(&"credit",0)) == 500: slowed += 1
if runtime.staff_service.get_staff(StringName("night_%02d" % i)).state == StaffRuntime.State.COMMUTING: commuting += 1
expect(off_duty == 8 and commuting > 0,"18:00 removes all eight day workers while night staff still physically commute")
expect(slowed > 0,"crowded shift-change corridor applies the original 50 percent movement speed")
var midpoint: Dictionary = runtime.create_snapshot()
clock.advance_minutes(60)
var working := 0
var delayed := 0
for i: int in 8:
var worker: StaffRuntime = runtime.staff_service.get_staff(StringName("night_%02d" % i))
if worker.state == StaffRuntime.State.AVAILABLE: working += 1
var shift: ShiftInstance = runtime.staff_service.get_shift(worker.shift_id)
if shift != null and shift.actual_started_at > 1080: delayed += 1
expect(working == 8 and delayed > 0,"night workers activate only after real arrivals, including rush delays")
var end: Dictionary = runtime.create_snapshot()
expect(runtime.restore_snapshot(midpoint),"16-employee shift-rush midpoint restores")
clock.advance_minutes(60)
expect(runtime.create_snapshot() == end,"16-employee shift change replays exact positions, attendance and history")
expect(runtime.staff_service.validate_invariants()[&"ok"],"shift rush preserves staff ownership")
runtime.free();clock.free();state.free()
print("Shift rush: %d checks, %d failures" % [checks,failures]);quit(failures)