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.
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
extends SceneTree
|
||||
const Routes=preload("res://scripts/construction/facility_resize_routes.gd")
|
||||
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(),"build legacy fixture %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,42505);clock.set_paused(true);runtime.enable_production_operations()
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS+FacilityCatalog.ORIGINAL_FACILITY_PATHS
|
||||
paths.erase("res://data/facilities/expansion/staff_dormitory.tres");paths.append("res://tests/fixtures/legacy_staff_dormitory.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"register explicit legacy dormitory fixture")
|
||||
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)) or not build(&"service_stairs",Vector3i(-7,3,1)): finish();return
|
||||
var id: StringName=&""
|
||||
for room: FacilityInstance in runtime.facility_service.get_instances():
|
||||
if room.definition_id==&"staff_dormitory": id=room.instance_id
|
||||
expect(runtime.submit_command(&"register_staff",{&"staff_id":&"legacy_sleeper",&"role_id":&"porter",&"options":{&"current_cell":Vector3i(-7,3,1),&"health":20,&"fatigue":20,&"state":StaffRuntime.State.OFF_DUTY}}).is_success(),"old resting worker starts on a valid upper landing")
|
||||
paths.erase("res://tests/fixtures/legacy_staff_dormitory.tres");paths.append("res://data/facilities/expansion/staff_dormitory.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"switch to canonical two-by-one definition")
|
||||
var before: Dictionary=runtime.create_snapshot()
|
||||
expect(runtime.get_staff_rest_report(&"legacy_sleeper")[&"resting"],"legacy worker rests beside the original upper row")
|
||||
runtime.path_service.set_cell_temporary_block(Vector3i(-7,2,1),true)
|
||||
var blocked: Dictionary=runtime.create_snapshot()
|
||||
var rejected: Dictionary=runtime.prepare_facility_dimension_snapshot(id)
|
||||
expect(not rejected[&"ok"] and rejected.get(&"routes",{}).get(&"errors",[]).any(func(error: Variant): return error is Dictionary and error[&"code"]==&"STAFF_ACCESS_LOST"), "blocked lower entrance rejects loss of off-duty rest access")
|
||||
expect(runtime.create_snapshot()==blocked and runtime.restore_snapshot(before),"failed route candidate preserves source then valid fixture restores")
|
||||
var task_result: CommandResult=runtime.staff_service.create_task(&"maintenance",10,clock.absolute_minute,{&"target_entity_id":id,&"target_cell":Vector3i(-7,3,1)},&"legacy_dorm_task")
|
||||
expect(task_result.is_success() and runtime.restore_snapshot(runtime.create_snapshot()),"pending old-entry task is a valid Runtime source")
|
||||
var task_source: Dictionary=runtime.create_snapshot()
|
||||
rejected=runtime.prepare_facility_dimension_snapshot(id)
|
||||
expect(not rejected[&"ok"] and rejected.get(&"routes",{}).get(&"errors",[]).any(func(error: Variant): return error is Dictionary and error[&"code"]==&"TASK_DESTINATION_CHANGED"),"old-entry task requires coordinated retargeting rather than silently surviving resize")
|
||||
expect(runtime.create_snapshot()==task_source and runtime.restore_snapshot(before),"task rejection preserves source state")
|
||||
task_result=runtime.staff_service.create_task(&"maintenance",10,clock.absolute_minute,{&"target_entity_id":id,&"target_cell":Vector3i(-7,2,1)},&"retained_dorm_task")
|
||||
expect(runtime.submit_command(&"register_staff",{&"staff_id":&"dorm_maintainer",&"role_id":&"porter",&"options":{&"current_cell":Vector3i(-7,1,1),&"state":StaffRuntime.State.AVAILABLE}}).is_success(),"register worker for retained task")
|
||||
expect(runtime.staff_service.assign_task_to_staff(&"retained_dorm_task",&"dorm_maintainer",clock.absolute_minute).is_success(),"assign retained task through normal Staff service")
|
||||
var valid_task: Dictionary=runtime.staff_service.get_task(&"retained_dorm_task").create_snapshot()
|
||||
var with_task: Dictionary=runtime.prepare_facility_dimension_snapshot(id)
|
||||
expect(task_result.is_success() and with_task[&"ok"],"task at retained entrance permits migration")
|
||||
if with_task[&"ok"]:
|
||||
expect(runtime.restore_snapshot(with_task[&"snapshot"]) and runtime.staff_service.get_task(&"retained_dorm_task").create_snapshot()==valid_task,"accepted task retains exact ownership progress and destination")
|
||||
expect(runtime.restore_snapshot(before),"restore original geometry before successful rest migration replay")
|
||||
var prepared: Dictionary=runtime.prepare_facility_dimension_snapshot(id)
|
||||
expect(prepared[&"ok"] and prepared.get(&"routes",{}).get(&"checked_routes",0)==2,"migration validates off-duty rest access independently of work assignment")
|
||||
expect(runtime.create_snapshot()==before,"preparing candidate preserves original worker and all live state")
|
||||
if not prepared[&"ok"]: print(prepared);finish();return
|
||||
expect(runtime.restore_snapshot(prepared[&"snapshot"]),"full candidate with resting worker restores")
|
||||
var worker: StaffRuntime=runtime.staff_service.get_staff(&"legacy_sleeper")
|
||||
expect(worker.current_cell==Vector3i(-7,3,1) and not runtime.get_staff_rest_report(worker.staff_id)[&"resting"],"migration preserves position and requires real movement to resized dormitory")
|
||||
clock.advance_minutes(2)
|
||||
expect(worker.current_cell==Vector3i(-7,2,1) and runtime.get_staff_rest_report(worker.staff_id)[&"resting"],"rest driver physically descends to new access after migration")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"post-migration rest travel remains saveable")
|
||||
finish()
|
||||
func finish() -> void:
|
||||
runtime.free();clock.free();state.free();print("Dormitory dimension migration: %d checks, %d failures" % [checks,failures]);quit(failures)
|
||||
@@ -0,0 +1 @@
|
||||
uid://chcs0l4hqkjkv
|
||||
@@ -0,0 +1,54 @@
|
||||
extends SceneTree
|
||||
var checks := 0
|
||||
var failures := 0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
func _initialize() -> void: call_deferred("run")
|
||||
func expect(ok: bool, message: String) -> void:
|
||||
checks += 1
|
||||
if not ok: failures += 1; push_error(message)
|
||||
func command(kind: StringName, payload: Dictionary) -> bool:
|
||||
var result: CommandResult = runtime.submit_command(kind, payload)
|
||||
expect(result.is_success(), "%s: %s" % [kind, result.message])
|
||||
return result.is_success()
|
||||
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,42505);clock.set_paused(true)
|
||||
expect(runtime.enable_production_operations()[&"ok"], "enable production operations")
|
||||
for row: Array in [[&"warehouse",Vector3i(-6,0,1)],[&"staff_dormitory",Vector3i(-6,2,1)],[&"service_stairs",Vector3i(-7,1,1)],[&"service_stairs",Vector3i(-7,2,1)]]:
|
||||
if not command(&"build_facility",{&"definition_id":row[0],&"origin":row[1]}): finish();return
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(row[0]).build_minutes)
|
||||
var warehouse_id: StringName = &""
|
||||
for facility: FacilityInstance in runtime.facility_service.get_instances():
|
||||
if facility.definition_id == &"warehouse": warehouse_id = facility.instance_id
|
||||
if not command(&"register_staff",{&"staff_id":&"dorm_night_worker",&"role_id":&"porter",&"options":{&"current_cell":Vector3i(5,0,0),&"role_tags":[&"porter"]}}): finish();return
|
||||
if not command(&"set_staff_work_assignment",{&"staff_id":&"dorm_night_worker",&"facility_id":warehouse_id,&"template_id":&"NIGHT"}): finish();return
|
||||
clock.advance_minutes(1110-clock.absolute_minute)
|
||||
var worker: StaffRuntime = runtime.staff_service.get_staff(&"dorm_night_worker")
|
||||
var shift: ShiftInstance = runtime.staff_service.get_shift(worker.shift_id)
|
||||
expect(worker.state == StaffRuntime.State.AVAILABLE and shift != null and shift.actual_started_at >= 1080, "night worker reaches warehouse for normal shift")
|
||||
clock.advance_minutes(1799-clock.absolute_minute)
|
||||
expect(worker.state == StaffRuntime.State.AVAILABLE and worker.assigned_facility_id == warehouse_id, "worker remains on assigned shift until its final minute")
|
||||
clock.advance_minutes(1)
|
||||
expect(worker.state == StaffRuntime.State.OFF_DUTY, "06:00 naturally ends night shift")
|
||||
var before_rest: Dictionary = runtime.create_snapshot()
|
||||
clock.advance_minutes(60)
|
||||
var rest_report: Dictionary = runtime.get_staff_rest_report(worker.staff_id)
|
||||
expect(rest_report.get(&"resting",false) and rest_report.get(&"label","") == "宿舎で休憩中" and worker.current_cell == Vector3i(-7,2,1), "shift-ended worker physically reaches dormitory through service stairs")
|
||||
var after_rest: Dictionary = runtime.create_snapshot()
|
||||
expect(runtime.restore_snapshot(before_rest), "restore shift-end movement checkpoint")
|
||||
clock.advance_minutes(60)
|
||||
expect(runtime.create_snapshot() == after_rest, "shift-end commute and rest replay exactly")
|
||||
clock.advance_minutes(2550-clock.absolute_minute)
|
||||
worker=runtime.staff_service.get_staff(&"dorm_night_worker")
|
||||
shift=runtime.staff_service.get_shift(worker.shift_id)
|
||||
expect(worker.state == StaffRuntime.State.AVAILABLE and worker.assigned_facility_id == warehouse_id and shift != null and shift.start_at == 2520, "next repeating night shift returns rested worker to workplace")
|
||||
expect(not runtime.get_staff_rest_report(worker.staff_id).get(&"resting",false), "working employee is no longer reported as resting")
|
||||
expect(runtime.staff_service.validate_invariants()[&"ok"], "full shift-rest-shift preserves staff invariants")
|
||||
finish()
|
||||
func finish() -> void:
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Dormitory shift cycle: %d checks, %d failures" % [checks,failures]);quit(failures)
|
||||
@@ -0,0 +1 @@
|
||||
uid://nmcyjwou0ic4
|
||||
@@ -0,0 +1,87 @@
|
||||
extends SceneTree
|
||||
var checks := 0
|
||||
var failures := 0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
func _initialize() -> void: call_deferred("run")
|
||||
func expect(ok: bool, text: String) -> void:
|
||||
checks += 1
|
||||
if not ok: failures += 1; push_error(text)
|
||||
else: print("PASS: ", text)
|
||||
func run() -> void:
|
||||
clock = load("res://autoload/game_clock.gd").new()
|
||||
state = load("res://autoload/game_state.gd").new()
|
||||
runtime = load("res://autoload/simulation_runtime.gd").new()
|
||||
clock.reset(1,6,0); state.reset(); runtime.initialize(clock,state,712); clock.set_paused(true)
|
||||
for spec: Array in [[&"infirmary",Vector3i(-6,0,1)],[&"service_elevator",Vector3i(0,0,1)]]:
|
||||
expect(runtime.submit_command(&"build_facility",{&"definition_id":spec[0],&"origin":spec[1]},&"player").is_success(), "ordinary construction: " + String(spec[0]))
|
||||
clock.advance_minutes(400)
|
||||
for id: StringName in [&"patient",&"medic"]:
|
||||
expect(runtime.submit_command(&"register_staff",{&"staff_id":id,&"role_id":&"medic",&"options":{&"current_cell":Vector3i(0,1,1) if id == &"patient" else Vector3i(5,0,1),&"health":0 if id == &"patient" else 100,&"state":StaffRuntime.State.AVAILABLE,&"role_tags":[&"medic"],&"permitted_task_tags":[&"rescue"]}},&"player").is_success(), "register " + String(id))
|
||||
var checkpoint := {}
|
||||
for tick: int in 130:
|
||||
clock.advance_minutes(1)
|
||||
var patient_trip: Dictionary = runtime.elevators.get_actor_trip(&"staff:patient")
|
||||
if patient_trip.get(&"state",&"") == PathService.ELEVATOR_REQUEST_BOARDED:
|
||||
checkpoint = runtime.create_snapshot(); break
|
||||
expect(not checkpoint.is_empty(), "rescuer reaches the upper floor and boards with the patient")
|
||||
if checkpoint.is_empty():
|
||||
print(runtime.get_staff_rescue_report(),runtime.elevators.get_report())
|
||||
finish(); return
|
||||
var medic_trip: Dictionary = runtime.elevators.get_actor_trip(&"staff:medic")
|
||||
expect(medic_trip.get(&"companion_id") == &"staff:patient", "real medic trip links to patient seat")
|
||||
expect(runtime.restore_snapshot(checkpoint), "boarded rescue snapshot has valid crosslinks")
|
||||
var slot := "user://tests/rescue_elevator_%d" % OS.get_process_id()
|
||||
expect(runtime.save_to_path(slot)[&"ok"] and runtime.load_from_path(slot)[&"ok"], "boarded pair survives real disk save and load")
|
||||
SaveService.delete_save(slot)
|
||||
checkpoint = runtime.create_snapshot()
|
||||
clock.advance_minutes(100)
|
||||
expect(runtime.staff_service.get_staff(&"patient").health == 100, "upper-floor patient arrives and completes treatment")
|
||||
var finished: Dictionary = runtime.create_snapshot()
|
||||
expect(runtime.restore_snapshot(checkpoint), "rewind paired ride")
|
||||
clock.advance_minutes(100)
|
||||
expect(runtime.create_snapshot() == finished, "paired elevator rescue replays identical state and events")
|
||||
expect(runtime.restore_snapshot(checkpoint), "restore for emergency")
|
||||
var shaft_id: StringName = runtime.elevators.get_report()[&"shafts"][0][&"shaft_id"]
|
||||
expect(runtime.submit_command(&"set_elevator_operation",{&"shaft_id":shaft_id,&"operator_open":false},&"player").is_success(), "player can stop the occupied elevator safely")
|
||||
var patient: StaffRuntime = runtime.staff_service.get_staff(&"patient")
|
||||
var medic: StaffRuntime = runtime.staff_service.get_staff(&"medic")
|
||||
expect(patient.current_cell == medic.current_cell and patient.health == 0 and runtime.elevators.get_report()[&"trips"].is_empty(), "emergency unloads both at the same floor without healing")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()), "emergency pair release remains saveable")
|
||||
expect(runtime.restore_snapshot(checkpoint), "restore boarded rescue pair for tower-wide depletion")
|
||||
state.set_resource(&"mana", 0)
|
||||
clock.advance_minutes(1)
|
||||
patient = runtime.staff_service.get_staff(&"patient"); medic = runtime.staff_service.get_staff(&"medic")
|
||||
expect(patient.current_cell == medic.current_cell and patient.health == 0 and runtime.elevators.get_report()[&"trips"].is_empty(), "reserve depletion lands both rescue passengers together without healing")
|
||||
var landing := patient.current_cell
|
||||
expect(landing in runtime.elevators.get_report()[&"shafts"][0][&"stops"], "depleted rescue pair uses an actual elevator landing")
|
||||
clock.advance_minutes(20)
|
||||
expect(runtime.staff_service.get_staff(&"patient").health == 0 and runtime.staff_service.get_staff(&"patient").current_cell == landing, "stopped clinic cannot heal or teleport the landed patient")
|
||||
var outage: Dictionary = runtime.create_snapshot()
|
||||
expect(runtime.staff_service.validate_invariants()[&"ok"] and runtime.restore_snapshot(outage) and runtime.create_snapshot() == outage, "depleted rescue ownership survives exact complete save restoration")
|
||||
state.set_resource(&"mana", 100)
|
||||
clock.advance_minutes(100)
|
||||
expect(runtime.staff_service.get_staff(&"patient").health == 100, "restored power resumes rescue and treatment for the same patient")
|
||||
expect(runtime.staff_service.validate_invariants()[&"ok"] and runtime.restore_snapshot(runtime.create_snapshot()), "recovered rescue has no orphan ownership and remains saveable")
|
||||
expect(runtime.restore_snapshot(checkpoint), "restore for clinic outage midride")
|
||||
for facility: FacilityInstance in runtime.facility_service.get_instances():
|
||||
if facility.definition_id == &"infirmary": runtime.facility_service.set_operational_status(facility.instance_id,{&"operator_open":false},clock.absolute_minute)
|
||||
clock.advance_minutes(1)
|
||||
expect(runtime.elevators.get_report()[&"trips"].size() == 2, "clinic outage holds onboard pair until a landing")
|
||||
clock.advance_minutes(40)
|
||||
patient = runtime.staff_service.get_staff(&"patient"); medic = runtime.staff_service.get_staff(&"medic")
|
||||
expect(patient.health == 0 and patient.current_cell.y == 0 and runtime.elevators.get_report()[&"trips"].is_empty(), "clinic outage does not teleport the pair back to pickup floor")
|
||||
expect(runtime.staff_service.validate_invariants()[&"ok"] and runtime.restore_snapshot(runtime.create_snapshot()), "interrupted elevator rescue preserves ownership and saves")
|
||||
expect(runtime.restore_snapshot(checkpoint), "restore for rescuer collapse midride")
|
||||
runtime.staff_service.get_staff(&"medic").health = 0
|
||||
clock.advance_minutes(1)
|
||||
expect(runtime.elevators.get_report()[&"trips"].size() == 2, "rescuer collapse never ejects either passenger between floors")
|
||||
clock.advance_minutes(40)
|
||||
patient = runtime.staff_service.get_staff(&"patient"); medic = runtime.staff_service.get_staff(&"medic")
|
||||
expect(patient.current_cell == medic.current_cell and patient.current_cell.y == 0 and patient.health == 0 and medic.health == 0, "two incapacitated passengers reach a real landing together")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()), "both incapacitated passengers remain saveable")
|
||||
finish()
|
||||
func finish() -> void:
|
||||
runtime.free(); clock.free(); state.free()
|
||||
print("Elevator rescue: %d checks, %d failures" % [checks, failures]); quit(failures)
|
||||
@@ -0,0 +1 @@
|
||||
uid://delft8b4w0alb
|
||||
@@ -0,0 +1,55 @@
|
||||
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)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dukb72njvfdj7
|
||||
@@ -0,0 +1,56 @@
|
||||
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)
|
||||
@@ -0,0 +1 @@
|
||||
uid://c571oqltvsnjr
|
||||
@@ -0,0 +1,154 @@
|
||||
extends SceneTree
|
||||
var checks := 0
|
||||
var failures := 0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
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(" ✓ ",message)
|
||||
func _run() -> void:
|
||||
_test_paths()
|
||||
_test_incapacitated_shift()
|
||||
_test_task_compatibility()
|
||||
clock = load("res://autoload/game_clock.gd").new()
|
||||
state = load("res://autoload/game_state.gd").new()
|
||||
runtime = load("res://autoload/simulation_runtime.gd").new()
|
||||
clock.reset(1,6,0); state.reset()
|
||||
expect(runtime.initialize(clock,state,711)[&"valid"], "rescue runtime initializes")
|
||||
clock.set_paused(true)
|
||||
expect(runtime.submit_command(&"build_facility", {&"definition_id": &"infirmary", &"origin": Vector3i(-6,0,1)}, &"player").is_success(), "medical facility builds through public command")
|
||||
clock.advance_minutes(80)
|
||||
expect(runtime.facility_service.get_instances().size() == 1, "medical facility construction completes")
|
||||
var clinic: FacilityInstance = runtime.facility_service.get_instances()[0]
|
||||
for id in [&"patient", &"porter"]:
|
||||
var options := {&"current_cell": Vector3i(3,0,1) if id == &"patient" else Vector3i(5,0,1), &"health": 0 if id == &"patient" else 100, &"state": StaffRuntime.State.AVAILABLE, &"role_tags": [&"medic"], &"permitted_task_tags": [&"rescue"]}
|
||||
expect(runtime.submit_command(&"register_staff", {&"staff_id": id, &"role_id": &"porter", &"options": options}, &"player").is_success(), "rescue actor registers: " + String(id))
|
||||
var patient: StaffRuntime = runtime.staff_service.get_staff(&"patient")
|
||||
expect(patient.state == StaffRuntime.State.INCAPACITATED, "zero health means incapacitated")
|
||||
runtime.facility_service.set_operational_status(clinic.instance_id, {&"operator_open": false}, clock.absolute_minute)
|
||||
clock.advance_minutes(3)
|
||||
expect(patient.current_cell == Vector3i(3,0,1) and runtime.staff_service.get_tasks().is_empty(), "closed clinic leaves patient in place without a rescue task")
|
||||
runtime.facility_service.set_operational_status(clinic.instance_id, {&"operator_open": true}, clock.absolute_minute)
|
||||
var carrying := false
|
||||
for minute in range(30):
|
||||
clock.advance_minutes(1)
|
||||
for task: StaffTask in runtime.staff_service.get_tasks():
|
||||
if task.task_type == &"rescue_transport" and task.state == StaffTask.State.MOVING:
|
||||
carrying = true
|
||||
if carrying: break
|
||||
expect(carrying, "medic reaches patient before transport begins")
|
||||
var carrier: StaffRuntime = runtime.staff_service.get_staff(&"porter")
|
||||
expect(patient.current_cell == carrier.current_cell and patient.health == 0, "pickup does not heal or teleport patient to clinic")
|
||||
expect(runtime.staff_service.get_tasks().size() == 1, "one patient has one active rescue")
|
||||
var midpoint: Dictionary = runtime.create_snapshot()
|
||||
expect(runtime.save_to_path("user://saves/rescue_regression")[&"ok"], "mid-transport state writes to an isolated save package")
|
||||
clock.advance_minutes(5)
|
||||
expect(runtime.load_from_path("user://saves/rescue_regression")[&"ok"], "mid-transport disk save loads")
|
||||
expect(runtime.latest_digest == SimulationDigest.compute(midpoint), "disk load restores the exact persisted rescue digest")
|
||||
SaveService.delete_save("user://saves/rescue_regression")
|
||||
# Manual save/load publish lifecycle events; compare replay from the loaded state.
|
||||
midpoint = runtime.create_snapshot()
|
||||
patient = runtime.staff_service.get_staff(&"patient")
|
||||
clock.advance_minutes(70)
|
||||
expect(patient.health == 100 and patient.state == StaffRuntime.State.OFF_DUTY, "transport and treatment restore patient at medical facility")
|
||||
expect(patient.current_cell.x < 0 and patient.current_cell.z == 1, "patient actually travelled through the backyard")
|
||||
var finished: Dictionary = runtime.create_snapshot()
|
||||
expect(runtime.restore_snapshot(midpoint), "mid-transport memory snapshot restores")
|
||||
clock.advance_minutes(70)
|
||||
expect(runtime.create_snapshot() == finished, "snapshot replay reproduces exact typed state and events")
|
||||
expect(runtime.restore_snapshot(midpoint), "carrier failure fixture restores")
|
||||
patient = runtime.staff_service.get_staff(&"patient")
|
||||
carrier = runtime.staff_service.get_staff(&"porter")
|
||||
var stranded_at := patient.current_cell
|
||||
carrier.health = 0
|
||||
clock.advance_minutes(4)
|
||||
expect(patient.health == 0 and patient.current_cell == stranded_at, "collapsed medic cannot move or heal their patient")
|
||||
expect(runtime.staff_service.validate_invariants()[&"ok"], "carrier collapse preserves task ownership")
|
||||
expect(runtime.restore_snapshot(midpoint), "interruption fixture restores")
|
||||
patient = runtime.staff_service.get_staff(&"patient")
|
||||
var stopped_at := patient.current_cell
|
||||
runtime.facility_service.set_operational_status(clinic.instance_id, {&"operator_open": false}, clock.absolute_minute)
|
||||
clock.advance_minutes(4)
|
||||
expect(patient.health == 0 and patient.current_cell == stopped_at, "clinic outage cancels transport without moving or healing patient")
|
||||
expect(runtime.staff_service.validate_invariants()[&"ok"], "interruption preserves staff/task invariants")
|
||||
runtime.facility_service.set_operational_status(clinic.instance_id, {&"operator_open": true}, clock.absolute_minute)
|
||||
clock.advance_minutes(80)
|
||||
expect(patient.health == 100, "clinic reopening allows a new rescue from the last position")
|
||||
runtime.facility_service.set_operational_status(clinic.instance_id, {&"operator_open": false}, clock.absolute_minute)
|
||||
runtime.progression_service.update_metrics({&"reputation": 10})
|
||||
expect(runtime.submit_command(&"register_staff", {&"staff_id": &"visible_patient", &"role_id": &"porter", &"options": {&"health": 0, &"current_cell": Vector3i.ZERO}}, &"player").is_success(), "front-layer collapse fixture registers")
|
||||
expect(runtime.submit_command(&"spawn_guest", {&"guest_id": &"witness", &"guest_type_id": &"noble_human", &"gold": 10}, &"player").is_success(), "witness enters the same front cell")
|
||||
clock.advance_minutes(1)
|
||||
expect(runtime.progression_service.metrics[&"reputation"] == 9, "visible collapse decreases reputation")
|
||||
clock.advance_minutes(3)
|
||||
expect(runtime.progression_service.metrics[&"reputation"] == 9, "one collapse cannot repeatedly reduce reputation")
|
||||
expect(not runtime._authority_line_of_sight(Vector3i(0,0,1), Vector3i.ZERO, {}), "back-layer guest cannot witness a front-layer collapse")
|
||||
expect(runtime.get_staff_rescue_report()[&"waiting"] == 1, "rescue report exposes the patient waiting for an operational clinic")
|
||||
runtime.free();clock.free();state.free()
|
||||
_test_work_collapse()
|
||||
print("%s: %d checks" % ["PASS" if failures == 0 else "FAIL", checks]);quit(failures)
|
||||
func _test_paths() -> void:
|
||||
var path := PathService.new()
|
||||
path.rebuild_graph([Vector3i(0,0,0),Vector3i(1,0,0),Vector3i(0,0,1),Vector3i(1,0,1)])
|
||||
expect(path.find_backyard_path(Vector3i(0,0,0),Vector3i(1,0,0)).is_empty(), "front corridor alone cannot be used for rescue")
|
||||
path.configure_connector(&"door_a",Vector3i(0,0,0),Vector3i(0,0,1),100,true,&"staff")
|
||||
path.configure_connector(&"door_b",Vector3i(1,0,1),Vector3i(1,0,0),100,true,&"staff")
|
||||
var route := path.find_backyard_path(Vector3i(0,0,0),Vector3i(1,0,0))
|
||||
expect(route.size() == 4 and route[1].z == 1 and route[2].z == 1, "rescue uses real doors and backyard even with a shorter front path")
|
||||
var lift := PathService.new()
|
||||
lift.rebuild_graph([Vector3i(0,0,1), Vector3i(0,1,1)])
|
||||
lift.set_vertical_walk_requires_connector(true)
|
||||
lift.configure_elevator(&"infra.connector:rescue",Vector3i(0,0,1),Vector3i(0,1,1),{&"cabin_capacity": 1})
|
||||
expect(lift.find_backyard_path(Vector3i(0,0,1),Vector3i(0,1,1)).is_empty(), "one-person lift cannot transport a rescuer and patient")
|
||||
lift.configure_elevator(&"infra.connector:rescue",Vector3i(0,0,1),Vector3i(0,1,1),{&"cabin_capacity": 2})
|
||||
expect(lift.find_backyard_path(Vector3i(0,0,1),Vector3i(0,1,1)).is_empty(), "paired rescue does not use a lift without atomic group boarding")
|
||||
lift.configure_elevator(&"transport.pair",Vector3i(0,0,1),Vector3i(0,1,1),{&"cabin_capacity": 1})
|
||||
expect(lift.find_backyard_path(Vector3i(0,0,1),Vector3i(0,1,1),true).is_empty(), "managed one-seat cabin cannot serve rescue")
|
||||
lift.configure_elevator(&"transport.pair",Vector3i(0,0,1),Vector3i(0,1,1),{&"cabin_capacity": 2})
|
||||
expect(lift.find_backyard_path(Vector3i(0,0,1),Vector3i(0,1,1),true).size() == 2, "managed two-seat BACK cabin serves rescue")
|
||||
var front := PathService.new()
|
||||
front.rebuild_graph([Vector3i(0,0,0),Vector3i(0,1,0),Vector3i(0,1,1)])
|
||||
front.set_vertical_walk_requires_connector(true)
|
||||
front.configure_elevator(&"transport.front",Vector3i(0,0,0),Vector3i(0,1,0),{&"cabin_capacity": 4})
|
||||
front.configure_connector(&"upper_door",Vector3i(0,1,0),Vector3i(0,1,1),100,true,&"staff")
|
||||
expect(front.find_backyard_path(Vector3i(0,0,0),Vector3i(0,1,1),true).is_empty(), "rescue cannot substitute a FRONT passenger lift for the BACK route")
|
||||
lift.configure_connector(&"rescue_stairs",Vector3i(0,0,1),Vector3i(0,1,1),100,true,&"staff")
|
||||
expect(lift.find_backyard_path(Vector3i(0,0,1),Vector3i(0,1,1)).size() == 2, "real backyard stairs carry the rescue pair")
|
||||
path.set_connector_enabled(&"door_a",false)
|
||||
path.set_connector_enabled(&"door_b",false)
|
||||
expect(path.find_backyard_path(Vector3i(0,0,0),Vector3i(1,0,0)).is_empty(), "blocked backyard entry cannot be bypassed")
|
||||
|
||||
func _test_incapacitated_shift() -> void:
|
||||
var service := StaffService.new()
|
||||
var member := StaffRuntime.new().configure(&"worker", &"porter", {&"state": StaffRuntime.State.AVAILABLE})
|
||||
service.register_staff(member)
|
||||
service.create_flex_shift(&"worker",0,0,1)
|
||||
member.health = 0
|
||||
member.transition_to(StaffRuntime.State.INCAPACITATED,&"STAFF_COLLAPSED",0)
|
||||
service.advance_one_minute(2)
|
||||
expect(member.state == StaffRuntime.State.INCAPACITATED, "shift ending cannot wake an incapacitated staff member")
|
||||
|
||||
func _test_work_collapse() -> void:
|
||||
clock = load("res://autoload/game_clock.gd").new()
|
||||
state = load("res://autoload/game_state.gd").new()
|
||||
runtime = load("res://autoload/simulation_runtime.gd").new()
|
||||
clock.reset(1,6,0);state.reset();runtime.initialize(clock,state,812);clock.set_paused(true)
|
||||
expect(runtime.enable_production_operations()[&"ok"], "work-health fixture enables production")
|
||||
expect(runtime.submit_command(&"register_staff", {&"staff_id": &"tired", &"role_id": &"porter", &"options": {&"health": 1, &"state": StaffRuntime.State.AVAILABLE, &"current_cell": Vector3i(0,0,1)}}, &"player").is_success(), "working staff starts with one health")
|
||||
runtime.staff_service.create_task(&"work",50,360,{&"target_cell": Vector3i(0,0,1), &"estimated_minutes": 90})
|
||||
clock.advance_minutes(30)
|
||||
var tired: StaffRuntime = runtime.staff_service.get_staff(&"tired")
|
||||
expect(tired.health == 0 and tired.state == StaffRuntime.State.INCAPACITATED and tired.current_task_id.is_empty(), "real work drains health and cancels the collapsed worker's task")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()), "work-collapse state and cancelled task save together")
|
||||
runtime.free();clock.free();state.free()
|
||||
|
||||
func _test_task_compatibility() -> void:
|
||||
var task := StaffTask.new().configure(&"legacy", &"work", 1, 0, {})
|
||||
var saved := task.create_snapshot()
|
||||
saved.erase("rescue_facility_id")
|
||||
expect(StaffTask.from_snapshot(saved) != null, "legacy task without rescue metadata loads")
|
||||
saved["rescue_facility_id"] = 12
|
||||
expect(StaffTask.from_snapshot(saved) == null, "malformed rescue metadata is rejected")
|
||||
@@ -0,0 +1 @@
|
||||
uid://b745cjukv2trj
|
||||
@@ -0,0 +1,50 @@
|
||||
extends SceneTree
|
||||
var checks := 0
|
||||
var failures := 0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
func _initialize() -> void: call_deferred("run")
|
||||
func expect(ok: bool, text: String) -> void:
|
||||
checks += 1
|
||||
if not ok: failures += 1; push_error(text)
|
||||
else: print("PASS: ",text)
|
||||
func command(type: StringName, payload: Dictionary) -> bool:
|
||||
var r: CommandResult = runtime.submit_command(type,payload,&"player")
|
||||
expect(r.is_success(), "%s: %s" % [type,r.message]);return r.is_success()
|
||||
func run() -> void:
|
||||
clock = load("res://autoload/game_clock.gd").new();state = load("res://autoload/game_state.gd").new();runtime = load("res://autoload/simulation_runtime.gd").new()
|
||||
clock.reset(1,6,0);state.reset();runtime.initialize(clock,state,714);clock.set_paused(true)
|
||||
expect(runtime.enable_production_operations()[&"ok"], "normal operations enable staff rest")
|
||||
command(&"register_staff",{&"staff_id":&"resting",&"role_id":&"porter",&"options":{&"health":20,&"fatigue":20,&"current_cell":Vector3i(5,0,0),&"state":StaffRuntime.State.OFF_DUTY}})
|
||||
clock.advance_minutes(30)
|
||||
var worker: StaffRuntime = runtime.staff_service.get_staff(&"resting")
|
||||
expect(worker.health == 20 and worker.current_cell == Vector3i(5,0,0), "off-duty worker cannot heal in the public corridor without a rest room")
|
||||
expect(runtime.get_staff_rest_report(&"resting")[&"label"].contains("休憩先なし"), "missing rest room has an actionable status")
|
||||
runtime.path_service.set_connector_enabled(&"starter.staff_door",false)
|
||||
command(&"build_facility",{&"definition_id":&"staff_waiting_room",&"origin":Vector3i(-6,0,1)})
|
||||
clock.advance_minutes(120)
|
||||
expect(worker.current_cell == Vector3i(5,0,0) and worker.health == 20, "rest room behind a blocked door cannot teleport or heal the worker")
|
||||
command(&"build_facility",{&"definition_id":&"staff_door",&"origin":Vector3i(0,0,1)})
|
||||
clock.advance_minutes(30)
|
||||
var midpoint: Dictionary = runtime.create_snapshot()
|
||||
clock.advance_minutes(60)
|
||||
expect(runtime.get_staff_rest_report(&"resting").get(&"resting",false) and worker.current_cell.z == 1, "off-duty worker physically reaches the back-layer rest room")
|
||||
expect(worker.health > 20 and worker.fatigue < 20, "health and fatigue recover only after arrival")
|
||||
var final_state: Dictionary = runtime.create_snapshot()
|
||||
expect(runtime.restore_snapshot(midpoint), "rest movement snapshot restores")
|
||||
clock.advance_minutes(60)
|
||||
expect(runtime.create_snapshot() == final_state, "rest movement and recovery replay identically")
|
||||
worker = runtime.staff_service.get_staff(&"resting")
|
||||
var room_id: StringName = runtime.get_staff_rest_report(&"resting")[&"facility_id"]
|
||||
runtime.facility_service.set_operational_status(room_id,{&"operator_open":false},clock.absolute_minute)
|
||||
var health := worker.health
|
||||
clock.advance_minutes(30)
|
||||
expect(worker.health == health and not runtime.get_staff_rest_report(&"resting").get(&"resting",false), "closed waiting room cannot recover health")
|
||||
runtime.facility_service.set_operational_status(room_id,{&"operator_open":true},clock.absolute_minute)
|
||||
worker.health = 0
|
||||
clock.advance_minutes(30)
|
||||
expect(worker.health == 0 and worker.state == StaffRuntime.State.INCAPACITATED, "rest cannot replace rescue for an incapacitated worker")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()), "closed-room and collapse state remain saveable")
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Staff rest: %d checks, %d failures" % [checks,failures]);quit(failures)
|
||||
@@ -0,0 +1 @@
|
||||
uid://cmd8yjfi614y6
|
||||
@@ -0,0 +1,31 @@
|
||||
extends SceneTree
|
||||
var checks := 0
|
||||
var failures := 0
|
||||
func expect(ok: bool, label: String) -> void:
|
||||
checks += 1
|
||||
if not ok: failures += 1; push_error(label)
|
||||
func _initialize() -> void: call_deferred("run")
|
||||
func run() -> void:
|
||||
var runtime: Variant=load("res://autoload/simulation_runtime.gd").new()
|
||||
var clock: Variant=load("res://autoload/game_clock.gd").new()
|
||||
var state: Variant=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();runtime.initialize(clock,state,42640);clock.set_paused(true)
|
||||
expect(runtime.submit_command(&"register_staff",{&"staff_id":&"worker", &"role_id":&"porter", &"options":{&"current_cell":Vector3i(-8,0,0), &"state":StaffRuntime.State.AVAILABLE}}).is_success(), "register worker")
|
||||
expect(runtime.submit_command(&"create_staff_task",{&"task_id":&"timed_work", &"task_type":&"inspection", &"priority":50, &"options":{&"target_cell":Vector3i(-8,0,0), &"estimated_minutes":8}}).is_success(), "create eight-minute task")
|
||||
var task: StaffTask=runtime.staff_service.get_task(&"timed_work")
|
||||
for minute in 10:
|
||||
clock.advance_one_minute()
|
||||
if task.state==StaffTask.State.WORKING: break
|
||||
expect(task.state==StaffTask.State.WORKING and task.progress_minutes==0, "arrival begins work without consuming a minute")
|
||||
var start: Dictionary=runtime.create_snapshot()
|
||||
for elapsed in range(1,8):
|
||||
clock.advance_one_minute()
|
||||
expect(task.state==StaffTask.State.WORKING and task.progress_minutes==elapsed, "one tick advances exactly one work minute: %d" % elapsed)
|
||||
clock.advance_one_minute()
|
||||
expect(task.state==StaffTask.State.COMPLETED and task.progress_minutes==8, "completes at exactly eight elapsed work minutes")
|
||||
var finished: Dictionary=runtime.create_snapshot()
|
||||
expect(runtime.restore_snapshot(start), "restore active work")
|
||||
clock.advance_minutes(8)
|
||||
expect(runtime.create_snapshot()==finished, "restored work reproduces exact completion state")
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Staff task clock: %d checks, %d failures" % [checks,failures]);quit(failures)
|
||||
@@ -0,0 +1 @@
|
||||
uid://b22ii8yoikb78
|
||||
Reference in New Issue
Block a user