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:
@@ -5,6 +5,8 @@ const ServiceInstanceType = preload("res://scripts/facility/service_instance.gd"
|
||||
const FacilityPricingType = preload("res://scripts/facility/facility_pricing.gd")
|
||||
|
||||
## Values are deliberately ordered by operational priority.
|
||||
enum OperationState { INACTIVE, OPERATING, SUSPENDED }
|
||||
|
||||
enum State {
|
||||
BROKEN,
|
||||
NO_ACCESS,
|
||||
@@ -42,6 +44,13 @@ var statistics_today: Dictionary = {}
|
||||
var lifetime_statistics: Dictionary = {}
|
||||
var created_at := 0
|
||||
|
||||
var customer_capacity := -1 # Unspecified; never inferred from storage/production capacity.
|
||||
var service_attribute: StringName = &""
|
||||
var related_facility_id: StringName = &""
|
||||
var related_facility_operating := true
|
||||
var suspension_reason: StringName = &""
|
||||
var operation_state: OperationState = OperationState.INACTIVE
|
||||
|
||||
var capacity := 1
|
||||
var queue_capacity := 0
|
||||
var base_service_minutes := 1
|
||||
@@ -70,6 +79,11 @@ func configure(
|
||||
durability = clampi(int(_value(options, &"durability", DEFAULT_DURABILITY)), 0, DEFAULT_DURABILITY)
|
||||
local_inventory_id = StringName(_value(options, &"local_inventory_id", &""))
|
||||
capacity = maxi(int(_value(options, &"capacity", 1)), 1)
|
||||
customer_capacity = int(_value(options, &"customer_capacity", -1))
|
||||
service_attribute = StringName(_value(options, &"service_attribute", &""))
|
||||
related_facility_id = StringName(_value(options, &"related_facility_id", &""))
|
||||
related_facility_operating = related_facility_id.is_empty()
|
||||
suspension_reason = StringName(_value(options, &"suspension_reason", &""))
|
||||
queue_capacity = maxi(int(_value(options, &"queue_capacity", 0)), 0)
|
||||
base_service_minutes = maxi(int(_value(options, &"base_service_minutes", 1)), 1)
|
||||
base_quality = int(_value(options, &"base_quality", 0))
|
||||
@@ -97,6 +111,9 @@ func is_valid() -> bool:
|
||||
return not instance_id.is_empty() \
|
||||
and not definition_id.is_empty() \
|
||||
and capacity > 0 \
|
||||
and customer_capacity >= -1 \
|
||||
and service_attribute in [&"", &"appetite", &"relaxation", &"sexual", &"gambling"] \
|
||||
and suspension_reason in [&"", &"DESTROYED", &"RAIDED"] \
|
||||
and queue_capacity >= 0 \
|
||||
and base_service_minutes > 0 \
|
||||
and staff_min >= 0 \
|
||||
@@ -140,6 +157,11 @@ func is_within_opening_hours(absolute_minute: int) -> bool:
|
||||
|
||||
|
||||
func set_operational_conditions(conditions: Dictionary, absolute_minute: int) -> bool:
|
||||
if _has_value(conditions, &"related_facility_id"):
|
||||
related_facility_id = StringName(_value(conditions, &"related_facility_id", &""))
|
||||
related_facility_operating = related_facility_id.is_empty()
|
||||
if StringName(_value(conditions, &"suspension_reason", &"")) in [&"DESTROYED", &"RAIDED"]:
|
||||
suspension_reason = StringName(_value(conditions, &"suspension_reason", &""))
|
||||
if _has_value(conditions, &"durability"):
|
||||
durability = clampi(int(_value(conditions, &"durability", durability)), 0, DEFAULT_DURABILITY)
|
||||
if _has_value(conditions, &"access_available"):
|
||||
@@ -158,6 +180,8 @@ func set_operational_conditions(conditions: Dictionary, absolute_minute: int) ->
|
||||
|
||||
|
||||
func evaluate_state(absolute_minute: int) -> bool:
|
||||
if durability <= 0:
|
||||
suspension_reason = &"DESTROYED"
|
||||
var next_reasons: Array[StringName] = []
|
||||
var next_state := State.OPEN
|
||||
if durability <= 0:
|
||||
@@ -192,7 +216,19 @@ func evaluate_state(absolute_minute: int) -> bool:
|
||||
next_reasons.append(reason)
|
||||
if next_state > State.DEGRADED:
|
||||
next_state = State.DEGRADED
|
||||
var changed := state != next_state
|
||||
if not related_facility_operating:
|
||||
next_reasons.append(&"RELATED_FACILITY_INACTIVE")
|
||||
next_state = mini(next_state, State.CLOSED) as State
|
||||
if not suspension_reason.is_empty():
|
||||
next_reasons.append(suspension_reason)
|
||||
next_state = State.BROKEN
|
||||
var next_operation := OperationState.INACTIVE
|
||||
if not suspension_reason.is_empty():
|
||||
next_operation = OperationState.SUSPENDED
|
||||
elif next_state in [State.OPEN, State.DEGRADED]:
|
||||
next_operation = OperationState.OPERATING
|
||||
var changed := state != next_state or operation_state != next_operation
|
||||
operation_state = next_operation
|
||||
state = next_state
|
||||
state_reasons = next_reasons
|
||||
return changed
|
||||
@@ -203,8 +239,35 @@ func can_start_service(absolute_minute: int) -> bool:
|
||||
return state in [State.OPEN, State.DEGRADED] and available_slots() > 0
|
||||
|
||||
|
||||
func allows_logistics() -> bool:
|
||||
return operator_open and power_available and durability > 0 and suspension_reason.is_empty() and related_facility_operating
|
||||
|
||||
|
||||
func available_slots() -> int:
|
||||
return maxi(capacity - active_services.size(), 0)
|
||||
var slots := maxi(capacity - active_services.size(), 0)
|
||||
if customer_capacity >= 0:
|
||||
slots = mini(slots, maxi(customer_capacity - customer_count(), 0))
|
||||
return slots
|
||||
|
||||
|
||||
func customer_count() -> int:
|
||||
var customers: Dictionary = {}
|
||||
for service: ServiceInstance in active_services.values():
|
||||
for guest_id: StringName in service.guest_ids:
|
||||
customers[guest_id] = true
|
||||
return customers.size()
|
||||
|
||||
|
||||
func can_accept_customers(guest_ids: Array[StringName]) -> bool:
|
||||
if customer_capacity < 0:
|
||||
return true
|
||||
var customers: Dictionary = {}
|
||||
for service: ServiceInstance in active_services.values():
|
||||
for guest_id: StringName in service.guest_ids:
|
||||
customers[guest_id] = true
|
||||
for guest_id: StringName in guest_ids:
|
||||
customers[guest_id] = true
|
||||
return customers.size() <= customer_capacity
|
||||
|
||||
|
||||
func has_queue_space() -> bool:
|
||||
@@ -281,6 +344,10 @@ func create_snapshot() -> Dictionary:
|
||||
&"statistics_today": statistics_today.duplicate(true),
|
||||
&"lifetime_statistics": lifetime_statistics.duplicate(true),
|
||||
&"created_at": created_at,
|
||||
&"customer_capacity": customer_capacity,
|
||||
&"service_attribute": service_attribute,
|
||||
&"related_facility_id": related_facility_id,
|
||||
&"suspension_reason": suspension_reason,
|
||||
&"capacity": capacity,
|
||||
&"queue_capacity": queue_capacity,
|
||||
&"base_service_minutes": base_service_minutes,
|
||||
@@ -309,6 +376,10 @@ static func from_snapshot(snapshot: Dictionary) -> FacilityInstance:
|
||||
&"level": snapshot.get(&"level", 1),
|
||||
&"durability": snapshot.get(&"durability", DEFAULT_DURABILITY),
|
||||
&"local_inventory_id": snapshot.get(&"local_inventory_id", ""),
|
||||
&"customer_capacity": snapshot.get(&"customer_capacity", -1),
|
||||
&"service_attribute": snapshot.get(&"service_attribute", ""),
|
||||
&"related_facility_id": snapshot.get(&"related_facility_id", ""),
|
||||
&"suspension_reason": snapshot.get(&"suspension_reason", ""),
|
||||
&"capacity": snapshot.get(&"capacity", 1),
|
||||
&"queue_capacity": snapshot.get(&"queue_capacity", 0),
|
||||
&"base_service_minutes": snapshot.get(&"base_service_minutes", 1),
|
||||
@@ -350,10 +421,17 @@ static func from_snapshot(snapshot: Dictionary) -> FacilityInstance:
|
||||
instance.active_services[service.service_id] = service
|
||||
if not instance.is_valid() or instance.active_services.size() > instance.capacity:
|
||||
return null
|
||||
if instance.customer_capacity >= 0 and instance.customer_count() > instance.customer_capacity:
|
||||
return null
|
||||
return instance
|
||||
|
||||
|
||||
static func _snapshot_shapes_are_valid(snapshot: Dictionary) -> bool:
|
||||
if snapshot.has(&"customer_capacity") and (typeof(snapshot[&"customer_capacity"]) != TYPE_INT or int(snapshot[&"customer_capacity"]) < -1):
|
||||
return false
|
||||
for field: StringName in [&"service_attribute", &"related_facility_id", &"suspension_reason"]:
|
||||
if snapshot.has(field) and typeof(snapshot[field]) not in [TYPE_STRING, TYPE_STRING_NAME]:
|
||||
return false
|
||||
var array_fields := [
|
||||
&"origin", &"occupied_cells", &"state_reasons", &"active_staff_ids",
|
||||
&"queue_entries", &"active_services", &"opening_intervals", &"degraded_reasons",
|
||||
|
||||
Reference in New Issue
Block a user