2026-08-17 19:48:55 +02:00
|
|
|
extends SceneTree
|
|
|
|
|
|
|
|
|
|
# Headless gameplay test: run with
|
|
|
|
|
# godot --headless -s res://tests/test_research_lab_extractor_gate.gd
|
|
|
|
|
# Forgejo #75: a research_lab planet yields no resources at all (#63) - an
|
|
|
|
|
# extractor placed there would sit on an empty resource id forever. The
|
|
|
|
|
# build menu must refuse the placement and explain why, the same "explain
|
|
|
|
|
# the refusal" idiom used for every other build gate. Mirrors
|
|
|
|
|
# test_extractor_building.gd's own chunk-discovery/settle/confirm shape.
|
|
|
|
|
|
|
|
|
|
var main_scene: Node
|
|
|
|
|
var fleet: Node
|
|
|
|
|
var game_state: Node
|
|
|
|
|
var controller: Node
|
|
|
|
|
var target_chunk: Vector2i
|
|
|
|
|
var target_planet_id: String
|
|
|
|
|
var stage: int = 0
|
|
|
|
|
var elapsed: float = 0.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _initialize() -> void:
|
|
|
|
|
var found: bool = false
|
|
|
|
|
for x in range(-40, 40):
|
|
|
|
|
for y in range(-40, 40):
|
|
|
|
|
var chunk: Vector2i = Vector2i(x, y)
|
|
|
|
|
if not WorldGen.has_planet_at_chunk(chunk):
|
|
|
|
|
continue
|
|
|
|
|
if WorldGen.planet_data_at_chunk(chunk).definition_id == "research_lab":
|
|
|
|
|
target_chunk = chunk
|
|
|
|
|
found = true
|
|
|
|
|
break
|
|
|
|
|
if found:
|
|
|
|
|
break
|
|
|
|
|
if not found:
|
|
|
|
|
print("TEST_RESEARCH_LAB_EXTRACTOR_GATE: FAIL (no research_lab chunk found to test with)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
game_state = root.get_node("GameState")
|
|
|
|
|
game_state.rocks = 200
|
|
|
|
|
game_state.buildings.clear()
|
|
|
|
|
game_state.extractors.clear()
|
|
|
|
|
game_state.planet_capture.clear()
|
|
|
|
|
target_planet_id = "chunk:%d:%d" % [target_chunk.x, target_chunk.y]
|
|
|
|
|
# This test is about the resource-id gate, not conquest itself (see
|
|
|
|
|
# test_planet_conquest_gate) - pre-conquer the target directly.
|
|
|
|
|
game_state.register_capture_points(target_planet_id, 1, "research_lab")
|
|
|
|
|
game_state.mark_point_captured(target_planet_id, 0)
|
|
|
|
|
game_state.reset_progression()
|
|
|
|
|
for node in GameState.SKILL_TREE:
|
|
|
|
|
game_state.unlocked.append(node.id)
|
|
|
|
|
|
#84: move 215 root files into a folder hierarchy
Everything lived in one flat directory, so a diff gave no clue what area it
touched and finding the file you wanted meant knowing its exact name. Twelve
folders now, grouped by what a thing IS rather than what type it is - a
vessel's definition, its component scenes and its upgrade resources sit
together, because that is the set you read when you change one of them.
buildings core controllers enemies logistics planets
resources shaders surface ui vessels vfx world
332 files moved and every res:// reference rewritten - 306 files touched,
including the autoload and main-scene paths in project.godot. Nothing renamed:
this is purely where files sit, so the diff is a pile of pure moves and no
behaviour is buried in it. ui_theme.tres, icon.svg and web_shell.html stay at
the root, where Godot and the export preset expect them.
Verified three ways, because a suite alone would not have caught all of it:
the full 117 pass, the web export builds clean, and the game renders.
The export is why that matters. The FIRST export after the move failed with
"Attempt to open script 'res://GameState.gd'" - the old path - while
project.godot on disk plainly said res://core/GameState.gd. That is this
project's documented Android FUSE mtime trap: Godot served a cached copy of a
file whose content had changed. A `touch` fixed it. Nothing in the test suite
would have found that, because the suite runs from a copy on a native
filesystem - the one place the bug cannot happen.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 19:44:14 +02:00
|
|
|
main_scene = load("res://world/Main.tscn").instantiate()
|
2026-08-17 19:48:55 +02:00
|
|
|
root.add_child(main_scene)
|
|
|
|
|
fleet = main_scene.get_node("Fleet")
|
|
|
|
|
controller = main_scene.get_node("BuildController")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _process(delta: float) -> bool:
|
|
|
|
|
elapsed += delta
|
|
|
|
|
match stage:
|
|
|
|
|
0:
|
|
|
|
|
main_scene.get_node("AsteroidField").set_process(false)
|
|
|
|
|
main_scene.get_node("EnemySpawner").set_process(false)
|
|
|
|
|
|
|
|
|
|
var near: Vector2 = WorldGen.chunk_origin(target_chunk) + Vector2.ONE * WorldGen.CHUNK_SIZE * 0.5
|
|
|
|
|
for ship in fleet.ships:
|
|
|
|
|
ship.position = near
|
|
|
|
|
fleet.move_to(near)
|
|
|
|
|
elapsed = 0.0
|
|
|
|
|
stage = 1
|
|
|
|
|
return false
|
|
|
|
|
1:
|
|
|
|
|
var planet_field: Node = main_scene.get_node("PlanetField")
|
|
|
|
|
if elapsed < planet_field.check_interval + 0.2:
|
|
|
|
|
return false
|
|
|
|
|
if not planet_field.populated_chunks.has(target_chunk):
|
|
|
|
|
return _fail("the research_lab planet never spawned")
|
|
|
|
|
var planet: Node2D = planet_field.populated_chunks[target_chunk][0]
|
|
|
|
|
if String(planet.resource_type) != "":
|
|
|
|
|
return _fail("test setup error: chosen planet's resource_type is '%s', expected empty" \
|
|
|
|
|
% planet.resource_type)
|
|
|
|
|
for ship in fleet.ships:
|
|
|
|
|
ship.position = planet.position
|
|
|
|
|
fleet.move_to(planet.position)
|
|
|
|
|
elapsed = 0.0
|
|
|
|
|
stage = 2
|
|
|
|
|
return false
|
|
|
|
|
2:
|
|
|
|
|
if elapsed < 0.3:
|
|
|
|
|
return false
|
|
|
|
|
controller._on_build_pressed()
|
|
|
|
|
if not controller.build_menu.visible:
|
|
|
|
|
return _fail("the build menu did not open over the planet")
|
|
|
|
|
|
|
|
|
|
var before: int = game_state.extractors.size()
|
|
|
|
|
controller._show_building_info(GameState.BUILDING_EXTRACTOR)
|
|
|
|
|
controller._confirm_build()
|
|
|
|
|
if game_state.extractors.size() != before:
|
|
|
|
|
return _fail("an extractor was built on a research_lab planet")
|
|
|
|
|
if not ("nothing to extract" in controller.build_status.text):
|
|
|
|
|
return _fail("refusal did not explain itself, status was '%s'" % controller.build_status.text)
|
|
|
|
|
print("extractor refused on a research_lab planet, explained: '%s'" % controller.build_status.text)
|
|
|
|
|
|
|
|
|
|
print("TEST_RESEARCH_LAB_EXTRACTOR_GATE: PASS")
|
|
|
|
|
quit(0)
|
|
|
|
|
return true
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _fail(message: String) -> bool:
|
|
|
|
|
print("TEST_RESEARCH_LAB_EXTRACTOR_GATE: FAIL (%s)" % message)
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|