Files
TheTree_mock/tests/mvp/test_upkeep_construction_boundaries.gd
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

47 lines
2.3 KiB
GDScript

extends SceneTree
var checks := 0
var failures := 0
func _initialize() -> void:
call_deferred("_run")
func expect(ok: bool, label: String) -> void:
checks += 1
if not ok:
failures += 1
push_error(label)
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()
expect(runtime.initialize(clock, state, 90416)[&"valid"], "initialize")
clock.set_paused(true)
var definition: FacilityDefinition = runtime.definition_registry.get_facility(&"guest_corridor")
var old_rate := definition.maintenance_gold
definition.maintenance_gold = 1440
expect(runtime.submit_command(&"build_facility", {&"definition_id": &"guest_corridor", &"origin": Vector3i(4, 1, 0)}).is_success(), "public construction starts")
var facility: Dictionary = {}
for minute in 100:
clock.advance_minutes(1)
var instances: Array = runtime.construction_service.get_facilities()
if not instances.is_empty():
facility = instances[0]
break
expect(runtime.facility_upkeep.get_report()[&"pending_facility_units"].is_empty(), "construction time is not billable")
expect(not facility.is_empty(), "construction completes")
if not facility.is_empty():
expect(runtime.facility_upkeep.get_report()[&"pending_facility_units"].is_empty(), "completion instant adds no earlier expense")
clock.advance_minutes(3)
expect(runtime.facility_upkeep.get_report()[&"pending_facility_units"].get(String(facility.instance_id), 0) == 4320, "owned infrastructure accrues exactly three minutes")
var mid: Dictionary = runtime.create_snapshot()
expect(runtime.restore_snapshot(mid) and runtime.create_snapshot() == mid, "real construction ownership saves exactly")
expect(runtime.submit_command(&"demolish_facility", {&"instance_id": facility.instance_id}).is_success(), "public demolition")
clock.advance_minutes(3)
expect(runtime.facility_upkeep.get_report()[&"pending_facility_units"].get(String(facility.instance_id), 0) == 4320, "demolition stops further accrual")
definition.maintenance_gold = old_rate
runtime.free()
clock.free()
state.free()
print("%s: %d checks" % ["PASS" if failures == 0 else "FAIL", checks])
quit(failures)