Fix facility discovery in exported builds and verify first construction
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
extends SceneTree
|
||||
|
||||
## Run against the distributed pack, not the source checkout:
|
||||
## godot --headless --main-pack /absolute/TheTree.pck --script /absolute/this_script.gd
|
||||
var _failures := 0
|
||||
var _checks := 0
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
func _run() -> void:
|
||||
var runtime: Variant = root.get_node("SimulationRuntime")
|
||||
var clock: Variant = root.get_node("GameClock")
|
||||
clock.set_paused(true)
|
||||
runtime.configure_save_policy({&"enabled": false, &"daily_checkpoint_enabled": false})
|
||||
if OS.get_environment("THE_TREE_REQUIRE_EXPORTED") == "1":
|
||||
_expect(not FileAccess.file_exists("res://project.godot") and not FileAccess.file_exists("res://data/facilities/reception.tres"), "release regression has no source checkout fallback")
|
||||
print("RECEPTION_RESOURCE file=%s resource=%s" % [FileAccess.file_exists("res://data/facilities/reception.tres"), ResourceLoader.exists("res://data/facilities/reception.tres")])
|
||||
_expect(runtime.definition_registry.is_valid(), "exported facility definitions validate: %s" % runtime.definition_registry.get_report())
|
||||
_expect(runtime.definition_registry.facility_count() == 18, "all 18 buildable definitions are present in the shipped pack")
|
||||
var main: Control = load("res://scenes/main/main.tscn").instantiate()
|
||||
root.add_child(main)
|
||||
runtime.configure_save_policy({&"enabled": false, &"daily_checkpoint_enabled": false})
|
||||
await process_frame
|
||||
await process_frame
|
||||
var buttons: Dictionary = main.get("build_buttons")
|
||||
_expect(buttons.size() == 18, "the actual build palette exposes all 18 facilities")
|
||||
_expect(buttons.has(&"reception"), "reception is selectable in the actual build palette")
|
||||
if not buttons.has(&"reception"):
|
||||
_finish()
|
||||
return
|
||||
_expect("受付" in buttons[&"reception"].text and not buttons[&"reception"].disabled, "reception button is labeled and enabled")
|
||||
var guide: Variant = main.find_child("InnOpeningGuide", true, false)
|
||||
_expect(guide != null and guide.get_progress().get(&"action") == &"build_reception", "new-game guide offers reception construction")
|
||||
if guide != null:
|
||||
(guide.get("_action") as Button).pressed.emit()
|
||||
await process_frame
|
||||
_expect(main.get("palette_scroll").visible and buttons[&"reception"].is_visible_in_tree(), "guide action opens the palette with a visible reception button")
|
||||
buttons[&"reception"].button_pressed = false
|
||||
buttons[&"reception"].button_pressed = true
|
||||
_expect(main.get("_selected_definition_id") == &"reception", "the reception button selects the real construction tool")
|
||||
main.call("_on_map_cell_clicked", Vector3i(-8, 0, 0))
|
||||
_expect(runtime.construction_service.get_jobs().size() == 1, "map placement starts one real reception construction job")
|
||||
_expect(runtime.economy_service.get_balance(&"PLAYER_CASH") == 4500, "reception construction charges the actual 500 G cost")
|
||||
clock.advance_minutes(120)
|
||||
var reception: Variant = null
|
||||
for facility: Variant in runtime.facility_service.get_instances():
|
||||
if facility.definition_id == &"reception":
|
||||
reception = facility
|
||||
_expect(reception != null, "the reception completes from the exported game data")
|
||||
_expect(guide != null and guide.get_progress().get(&"stage") == &"room", "opening guide advances to building a room")
|
||||
if OS.get_environment("THE_TREE_EXPORT_CAPTURE") == "1":
|
||||
main.call("_refresh_dashboard")
|
||||
await process_frame
|
||||
await RenderingServer.frame_post_draw
|
||||
root.get_texture().get_image().save_png(OS.get_environment("THE_TREE_EXPORT_CAPTURE_PATH"))
|
||||
_finish()
|
||||
|
||||
func _expect(ok: bool, label: String) -> void:
|
||||
_checks += 1
|
||||
if not ok:
|
||||
_failures += 1
|
||||
print("%s: %s" % ["PASS" if ok else "FAIL", label])
|
||||
|
||||
func _finish() -> void:
|
||||
print("Exported opening: %d checks, %d failures" % [_checks, _failures])
|
||||
quit(1 if _failures else 0)
|
||||
Reference in New Issue
Block a user