Gas bombers consume gas from the fleet hold when firing (#60)

Shots cost GAS_PER_SHOT (5) from GameState.fleet_inventory, not the
bank - the fleet has to be carrying its own ammunition. The button's
enabled rule now also requires affordability, and a press on a ready-
but-unaffordable bomber still consumes the touch to explain itself via
a new status label (GasBombStatus, IconButton's own "greyed but still
pressable" convention) rather than either silently doing nothing or
consuming the bomber's cooldown for a shot that never fires.

Also documents a real, reproducible GDScript trap hit while writing
tests/test_gas_bomber_ammo.gd: a bare `ClassName.SOME_CONST` reference
anywhere in a -s entry test script can corrupt method resolution for
the WHOLE script, making an unrelated, earlier `some_node._process()`
call fail with "Nonexistent function '_process' in base 'Nil'" despite
the node being valid and the method existing (confirmed via
has_method()). Root cause unconfirmed; fixed by mirroring the constant
's value into a local const instead of referencing the class directly,
in all three gas-bomber tests.

tests/test_gas_bomber.gd and test_gas_bomber_cooldowns.gd updated to
stock fleet gas first, since shots are no longer free.
This commit is contained in:
Loïc Wisniewski 2026-08-16 18:54:44 +02:00
commit 17d0cf7e66
8 changed files with 230 additions and 9 deletions

View file

@ -3,7 +3,10 @@ extends SceneTree
var game_state: Node
var main: Node
var fleet: Node
var skill: GasBombController
var skill: Node
# Mirrors GasBombController.AOE_RADIUS's value rather than referencing the
# class constant directly - see test_gas_bomber_cooldowns.gd's identical fix.
const AOE_RADIUS_FOR_TEST: float = 180.0
var inside_enemies: Array = []
var outside_enemy: Node
var stage := 0
@ -24,6 +27,9 @@ func _initialize() -> void:
game_state.fleet_cargo = 0
game_state.fleet_gas_cargo = 0
game_state.build_time_scale = 0.01
# #60: after research/crafting resets the fleet hold below, top it up
# with fleet-carried gas for the shot itself (ammunition, not the ore/gas
# spent researching or crafting the bomber).
# Research is gas-only: any amount of ore and 29 gas must still leave it
# waiting, then the thirtieth unit starts and completes the unlock.
@ -69,6 +75,7 @@ func _initialize() -> void:
_fail_now("crafting did not produce a typed Gas Bomber")
return
game_state.fleet_gas_cargo = 20
main = load("res://Main.tscn").instantiate()
root.add_child(main)
fleet = main.get_node("Fleet")
@ -117,7 +124,7 @@ func _process(delta: float) -> bool:
enemy.speed = 0.0
inside_enemies.append(enemy)
outside_enemy = load("res://Enemy.tscn").instantiate()
outside_enemy.position = skill.aim_target + Vector2(GasBombController.AOE_RADIUS + 80.0, 0)
outside_enemy.position = skill.aim_target + Vector2(AOE_RADIUS_FOR_TEST + 80.0, 0)
main.add_child(outside_enemy)
outside_enemy.speed = 0.0