Files
TheTree_mock/tests/special/test_peeping_room_geometry.gd
T

63 lines
4.8 KiB
GDScript

extends "res://tests/special/peeping_room_fixture.gd"
func _run() -> void:
var f := fixture()
var runtime: Variant = f[&"runtime"]
var service: Variant = runtime.peeping_room_service
var origin: Vector3i = f[&"origin"]
var before := var_to_bytes(runtime.create_snapshot())
expect(service.validate_placement(origin)[&"ok"], "public bath entirely behind one completed FRONT target")
expect(service.validate_placement(Vector3i(-6, 1, 0))[&"reason"] == &"WRONG_LAYER", "FRONT room rejected")
expect(service.validate_placement(origin, Vector2i(1, 2))[&"reason"] == &"WRONG_FOOTPRINT", "rotated footprint rejected")
expect(service.validate_placement(origin, Vector2i(2, 1), &"vip_suite")[&"reason"] == &"PENDING_P10_01", "VIP unavailable, never substituted")
expect(service.validate_placement(Vector3i(-1, 1, 1))[&"reason"] == &"PARTIAL_TARGET", "partial target rejected")
expect(service.validate_placement(Vector3i(8, 1, 1))[&"reason"] == &"TARGET_MISSING", "missing target rejected")
expect(service.validate_placement(origin, Vector2i(2, 1), &"missing")[&"reason"] == &"TARGET_MISMATCH", "named reference must match FRONT occupant")
expect(before == var_to_bytes(runtime.create_snapshot()), "geometry validation is pure across whole Runtime")
# Complete real second bath; the 2x1 footprint at the boundary spans targets.
expect(runtime.submit_command(&"build_facility", {&"definition_id": &"public_bath", &"origin": Vector3i(0, 0, 0)}).is_success(), "second paid target starts")
expect(service.validate_placement(Vector3i(0, 1, 1))[&"reason"] == &"TARGET_INCOMPLETE", "construction reservation is not a completed target")
f[&"clock"].advance_minutes(runtime.definition_registry.get_facility(&"public_bath").build_minutes)
expect(service.validate_placement(Vector3i(-1, 1, 1))[&"reason"] == &"MULTIPLE_TARGETS", "multiple FRONT target footprints rejected")
# A real path joining both sides through the proposed footprint must survive.
for x in range(-7, -3): runtime.world_service.set_walkable(Vector3i(x, 1, 1), true)
expect(runtime.rebuild_path_graph_from_world(), "CONTROLLED_FIXTURE corridor graph rebuild")
var path_before: Array = runtime.path_service.find_path(Vector3i(-7, 1, 1), Vector3i(-4, 1, 1))
expect(not path_before.is_empty(), "proposed footprint lies across a connected corridor")
expect(service.validate_placement(origin)[&"reason"] == &"CORRIDOR_CONFLICT", "would disconnect BACK corridor: reject with no bypass")
expect(runtime.path_service.find_path(Vector3i(-7, 1, 1), Vector3i(-4, 1, 1)) == path_before, "rejected cut preserves route")
for x in range(-7, -3): runtime.world_service.set_walkable(Vector3i(x, 1, 1), false)
expect(service.validate_placement(origin)[&"reason"] == &"CORRIDOR_CONFLICT", "stale path authority also rejects conflict")
expect(runtime.rebuild_path_graph_from_world(), "corridor fixture removed explicitly")
var room := place(f)
expect(service.validate_placement(origin)[&"reason"] == &"BACK_OCCUPIED", "dedicated room occupancy blocks overlap")
expect(runtime.world_service.get_entity_kind(room) == Rooms.OCCUPANCY_KIND, "dedicated cross-reference occupancy kind")
_private_geometry()
finish("Peeping room geometry")
func _private_geometry() -> void:
var f := fixture(false)
var runtime: Variant = f[&"runtime"]
# CONTROLLED_FIXTURE underground geometry only: no unlock/normal palette claim.
var bounds: Dictionary = runtime.world_service.get_bounds()
bounds[&"min_y"] = -1
expect(runtime.world_service.expand_bounds(bounds), "CONTROLLED_FIXTURE underground bounds")
var definition: FacilityDefinition = runtime.definition_registry.get_facility(&"adult_private_room")
for x in range(2):
var cell := Vector3i(x, -1, 0)
runtime.world_service.set_excavated(cell, true)
runtime.world_service.set_support(cell, definition.weight_per_cell, true)
var started: CommandResult = runtime.construction_service.start_construction(definition, Vector3i(0, -1, 0))
expect(started.is_success(), "CONTROLLED_FIXTURE paid real adult_private_room definition")
f[&"clock"].advance_minutes(definition.build_minutes)
var service: Variant = runtime.peeping_room_service
expect(service.validate_placement(Vector3i(0, -1, 1))[&"ok"], "adult_private_room valid completed geometry")
var target_id: StringName = runtime.world_service.get_occupant(Vector3i(0, -1, 0))
var target: FacilityInstance = runtime.facility_service.get_instance(target_id)
if target != null:
target.definition_id = &"vip_private_salon"
expect(service.validate_placement(Vector3i(0, -1, 1))[&"reason"] == &"TARGET_NOT_ALLOWED", "salon is not VIP suite substitute")
target.definition_id = &"adult_private_room"
runtime.facility_service.unregister_instance(target_id)
expect(service.validate_placement(Vector3i(0, -1, 1))[&"reason"] == &"TARGET_UNKNOWN", "world occupant without actual FacilityService target rejected")