P08-03-RTPREVIEW: P08-03を閉じるための共有配置プレビュー判定
This commit is contained in:
@@ -58,12 +58,21 @@ func _facility_definition_is_unsupported_vertical_proxy(definition: Variant) ->
|
||||
_failure_case(&"guest_stairs", cell, 999, "STAIR_LANDING_MISSING", "先に階段の一つ下の階に通路を作ってください。")
|
||||
_failure_case(&"guest_corridor", cell, 999, "INVALID_PAYLOAD", "The selected rotation is not allowed.")
|
||||
# origin INVALID_PAYLOAD cannot be reached through preview's Vector3i API.
|
||||
# Diagnostic landing path from the seed; existing reception provides support.
|
||||
var walkable: Array[Vector3i] = _runtime.world_service.get_walkable_cells()
|
||||
walkable.append(Vector3i(-8, 1, 0))
|
||||
check(_runtime.path_service.rebuild_graph(walkable), "diagnostic landing path")
|
||||
var report := _pure_preview(&"guest_stairs", cell, 0)
|
||||
var accepted: Variant = _command(&"guest_stairs", cell, 0)
|
||||
_reset()
|
||||
var lower_stairs := _command(&"guest_stairs", Vector3i(4, 1, 0), 0)
|
||||
check(lower_stairs.is_success(), "build real lower stairs: %s" % lower_stairs.message)
|
||||
_clock.advance_minutes(_runtime.definition_registry.get_facility(&"guest_stairs").build_minutes)
|
||||
var lower_exists := false
|
||||
for facility: Dictionary in _runtime.construction_service.get_facilities():
|
||||
if facility[&"origin"] == Vector3i(4, 1, 0):
|
||||
lower_exists = true
|
||||
check(lower_exists, "real lower stairs construction completes")
|
||||
var report := _pure_preview(&"guest_stairs", Vector3i(4, 2, 0), 0)
|
||||
var accepted: Variant = _command(&"guest_stairs", Vector3i(4, 2, 0), 0)
|
||||
if not (report[&"can_build"] and accepted.is_success()):
|
||||
var first_reason: Dictionary = report[&"reasons"][0] if not report[&"reasons"].is_empty() else {}
|
||||
var command_code := String(accepted.details.get(&"reason", CommandResult.Code.keys()[accepted.code]))
|
||||
print("Runtime preview positive: can_build=%s error_codes=%s first_code=%s first_message=%s command_code=%s command_message=%s" % [report[&"can_build"], JSON.stringify(report[&"error_codes"]).left(256), JSON.stringify(first_reason.get(&"code", "none")).left(256), JSON.stringify(first_reason.get(&"message", "none")).left(512), JSON.stringify(command_code).left(256), JSON.stringify(accepted.message).left(512)])
|
||||
check(report[&"can_build"] and accepted.is_success(), "positive landing preview and command agree")
|
||||
_reset()
|
||||
check(_command(&"guest_elevator", Vector3i.ZERO, 0).is_success(), "build real elevator")
|
||||
@@ -96,12 +105,24 @@ func _pure_preview(id: StringName, cell: Vector3i, rotation: int) -> Dictionary:
|
||||
var processed_before: int = _runtime.command_queue.processed_count()
|
||||
var events_before: int = _runtime.domain_events.recent_events().size()
|
||||
var report: Dictionary = _runtime.preview_build_facility(id, cell, rotation)
|
||||
check(before == var_to_bytes(_runtime.create_snapshot()), "preview preserves typed snapshot bytes")
|
||||
check(log_before == var_to_bytes(_runtime.command_queue.create_snapshot()), "preview preserves command log bytes")
|
||||
check(commands_before == _runtime.command_queue.get_accepted_command_metadata().size() and processed_before == _runtime.command_queue.processed_count(), "preview preserves command counts")
|
||||
check(events_before == _runtime.domain_events.recent_events().size(), "preview preserves event count")
|
||||
var after := var_to_bytes(_runtime.create_snapshot())
|
||||
var log_after := var_to_bytes(_runtime.command_queue.create_snapshot())
|
||||
var commands_after: int = _runtime.command_queue.get_accepted_command_metadata().size()
|
||||
var processed_after: int = _runtime.command_queue.processed_count()
|
||||
var events_after: int = _runtime.domain_events.recent_events().size()
|
||||
print("Runtime preview proof: case=%s cell=%s rotation=%d snapshot_before=%s snapshot_after=%s queue_before=%s queue_after=%s accepted_before=%d accepted_after=%d processed_before=%d processed_after=%d events_before=%d events_after=%d can_build=%s error_codes=%s" % [JSON.stringify(String(id)).left(256), cell, rotation, _sha256(before), _sha256(after), _sha256(log_before), _sha256(log_after), commands_before, commands_after, processed_before, processed_after, events_before, events_after, report[&"can_build"], JSON.stringify(report[&"error_codes"]).left(256)])
|
||||
check(before == after, "preview preserves typed snapshot bytes")
|
||||
check(log_before == log_after, "preview preserves command log bytes")
|
||||
check(commands_before == commands_after and processed_before == processed_after, "preview preserves command counts")
|
||||
check(events_before == events_after, "preview preserves event count")
|
||||
return report
|
||||
|
||||
func _sha256(bytes: PackedByteArray) -> String:
|
||||
var context := HashingContext.new()
|
||||
context.start(HashingContext.HASH_SHA256)
|
||||
context.update(bytes)
|
||||
return context.finish().hex_encode()
|
||||
|
||||
func _failure_case(id: StringName, cell: Vector3i, rotation: int, code: String, message: String) -> void:
|
||||
var report := _pure_preview(id, cell, rotation)
|
||||
check(not report[&"can_build"] and report[&"error_codes"][0] == code, "preview first code: " + code)
|
||||
|
||||
Reference in New Issue
Block a user