spaceship/tests/test_gas_bomber_cooldowns.gd
Loïc Wisniewski 2f161621c3 #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

75 lines
2.7 KiB
GDScript

extends SceneTree
var main: Node
var fleet: Node
var skill: Node
var elapsed := 0.0
func _initialize() -> void:
var state: Node = root.get_node("GameState")
state.buildings.clear()
state.extractors.clear()
state.transporters.clear()
state.vessel_levels["unlock_gas_bomber"] = 1
# #60: shots draw from the fleet hold now - stock enough for both fires.
state.fleet_gas_cargo = 20
main = load("res://world/Main.tscn").instantiate()
root.add_child(main)
fleet = main.get_node("Fleet")
skill = main.get_node("GasBombController")
func _process(delta: float) -> bool:
elapsed += delta
if elapsed < 0.2:
return false
main.get_node("EnemySpawner").set_process(false)
main.get_node("AsteroidField").set_process(false)
# Asteroids take damage now, so anything the field already placed
# would soak a bomb meant for the enemies under test.
for hazard in get_nodes_in_group("asteroids"):
if is_instance_valid(hazard):
hazard.free()
fleet.spawn_ships(2, Vector2.ZERO, PackedStringArray([
GameState.VESSEL_GAS_BOMBER, GameState.VESSEL_GAS_BOMBER]))
skill._process(0.0)
var first: Node = fleet.ships[0].get_component("gas_bomber")
var second: Node = fleet.ships[1].get_component("gas_bomber")
if not first.is_ready() or not second.is_ready() or not skill.button.enabled:
return _fail("two fresh bombers did not each begin ready")
skill.aim_target = Vector2(500, 0)
skill._fire()
skill._process(0.0)
if first.is_ready() or not second.is_ready() or not skill.button.enabled:
return _fail("the first shot disabled more than its firing bomber")
if not first._filled_hull(fleet.ships[0].definition.hull_points, 0.0).is_empty() \
or first._filled_hull(fleet.ships[0].definition.hull_points, 0.5).size() < 3:
return _fail("bomber cooldown did not produce an empty-to-filling hull")
if skill.projectiles.size() != 1:
return _fail("the first bomber did not launch exactly one projectile")
skill.aim_target = Vector2(-500, 0)
skill._fire()
skill._process(0.0)
if first.is_ready() or second.is_ready() or skill.button.enabled:
return _fail("the skill stayed available after both bombers fired")
if skill.projectiles.size() != 2:
return _fail("independent bombers could not have shots in flight together")
# Rearming one bomber restores one available shot without touching the
# other bomber's cooldown.
first.tick(5.0) # matches GasBombController.COOLDOWN
skill._process(0.0)
if not first.is_ready() or second.is_ready() or not skill.button.enabled:
return _fail("one completed cooldown did not restore exactly one shot")
print("TEST_GAS_BOMBER_COOLDOWNS: PASS")
quit(0)
return true
func _fail(message: String) -> bool:
print("TEST_GAS_BOMBER_COOLDOWNS: FAIL (%s)" % message)
quit(1)
return true