extends Node const SCREEN := preload("res://scripts/planets/surface_screen.gd") func _ready() -> void: if not InputMap.has_action("ship_mini_boost"): InputMap.add_action("ship_mini_boost") GameState.start_new_run() GameState.system_level = 7 var captain := GameState.captain for gear in captain.gear_items: gear.level = 12 var progress: Resource = captain.expedition var profile := {"id":"single-visit-ui","name":"Asteria","seed":8428159,"difficulty":0.4,"landing_damage":5,"oxygen":55,"temperature":55,"flora":10,"easy":false,"system_level":7} assert(progress.begin_visit(profile)) var layer := CanvasLayer.new() add_child(layer) var surface := Control.new() surface.set_script(SCREEN) surface.captain = captain surface.progress = progress layer.add_child(surface) surface.set_process(false) surface.set_physics_process(false) # Keep optional encounter popups away from the ordinary POI fixture. for event in surface.world.data.events: event.position = Vector2(10000,10000) var poi: Dictionary = surface.world.data.pois[0] assert(poi.kind == "warehouse") surface.lander.position = poi.position surface._previous_position = poi.position surface.camera.position = poi.position surface.camera.reset_smoothing() surface.world.refresh_pois(poi.position) assert(surface.world._poi_labels[poi.id].text.contains("[E]")) var key := InputEventKey.new() key.pressed = true key.keycode = KEY_E var permanent := captain.minerals.duplicate() surface._input(key) assert(surface._dialog.visible and poi.complete and not progress.cargo.is_empty()) assert(captain.minerals == permanent,"Loot waits in expedition cargo until safe return") var labels := "" for label in surface._choices.find_children("*","Label",true,false): labels += label.text+"\n" assert(labels.contains("ZDOBYTO") and not labels.contains("ETAP") and not labels.contains("Powodzenie")) var snapshot: Dictionary = progress.cargo.duplicate() if not DisplayServer.get_name() == "headless": for frame in 12: await get_tree().process_frame await RenderingServer.frame_post_draw assert(get_viewport().get_texture().get_image().save_png("res://artifacts/single_visit_planet_poi.png") == OK) surface._input(key) assert(not surface._dialog.visible and progress.cargo == snapshot) surface._input(key) assert(not surface._dialog.visible and progress.cargo == snapshot,"Repeated E cannot reclaim visited POIs") # Services keep their own interfaces and do not become auto-collected loot. for kind in ["time_engineer","hermit","crew","deep_deposit"]: var special := {"kind":kind,"complete":false} surface._poi = special surface._show_poi() assert(surface._dialog.visible and not special.complete) assert(progress.cargo == snapshot) surface._dialog.hide() var encounter := {"kind":"trader","seed":42,"complete":false} surface._show_event(encounter) assert(surface._dialog.visible and not encounter.complete) assert(surface._poi.is_empty(),"Previous result must not hijack event interaction") surface._input(key) assert(surface._dialog.visible) print("SINGLE_VISIT_SURFACE_TEST: PASS (E immediately grants loot and opens results, no stages, close/repeat safety, pending cargo, engineers/cartographer/crew/deposit and question-mark events retained)") get_tree().quit()