Implement #77, #78 and #79

#77 - the Distorder becomes the Energy Propulser. Renamed everywhere the
player reads it, reskinned to match: a symmetric hull flaring into an engine
skirt instead of the lopsided warped lump, an engine bell with a thrust plume
instead of the wobbling ring glyph, and energy's own yellow instead of purple,
since energy is what it burns. The internal id stays "distorder" - it is the
capability string, the unlock key and the component scene name, and renaming
the wiring would be a large mechanical change with no player-visible effect.

Its speed ceiling now grows with the LOGARITHM of how many fly. Each one used
to add a flat 1.0, so a fleet that could afford six simply drove at six times
cruise and the vessel stopped being a choice. Base-2 makes the rule one
sentence - every doubling adds another 1.0 - and leaves two propulsers worth
exactly what they were worth before, so nothing already built is devalued.

#78 - a gas burner can be paused. It converts gas the player may want for
bombs into energy they may not need yet, and the only way to stop it was to
demolish it. The action is data-driven like every other: the visual's
ActionProvider lists "pause", and any converter can adopt it. Pause is the
burner's PRIMARY action, so it is one tap rather than a menu; the button shows
what it will DO, bars while running and a play triangle while stopped; and the
building itself goes visibly cold, because a paused building that looked
identical to a running one would be a setting to remember rather than see.
Conversion progress is left where it was rather than reset, so switching off
and on again does not discard a part-finished unit.

#79 - picking something up says so. A "+N" with the resource's own mark rises
and fades where it happened. Built from the SAME glyph the resource tables and
transfer rows use, so a material added to the catalog later cannot end up with
one mark in the HUD and a different one in the world. A pickup a full hold
REFUSES raises nothing.

Two Godot traps cost real time here and are now written down where the next
person will hit them:

  - a `#` comment inside a .tres [resource] block is not a comment. It parses
    as part of the preceding value and silently blanks the property after it.
    One in DistorderVesselDefinition.tres left definition_id empty, which
    surfaced as "<blank> did not resolve its definition" in a test far from
    the edit. The note lives in VesselDefinition.gd now.
  - a global class_name is not reliably resolvable, INCLUDING a script's own
    inside its own static function. ResourcePickupVFX.new() failed to compile
    when reached through a preview scene, taking Rock and the gas vents with
    it. It has no class_name now and constructs itself by path.

Suite 114/114.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Loïc Wisniewski 2026-08-21 17:38:30 +02:00
commit 54287d27ea
14 changed files with 648 additions and 41 deletions

View file

@ -2,13 +2,17 @@ extends SceneTree
# Headless gameplay test: run with
# godot --headless -s res://tests/test_distorder_stacking.gd
# Each space-time distorder vessel PAST THE FIRST raises the fleet's speed
# ceiling by 1.0, so a second one is worth crewing rather than dead weight.
# Energy Propulsers raise the fleet's speed ceiling together, so a second one
# is worth crewing rather than dead weight - but with DIMINISHING returns
# (#77). Each doubling of them adds 1.0, not each vessel: a flat 1.0 apiece
# meant a fleet that could afford six simply drove at six times cruise and the
# vessel stopped being a choice.
#
# Covers:
# A. one vessel gives the original ceiling, so nothing changed for a fleet
# that carries a single distorder
# B. each additional vessel adds exactly 1.0
# that carries a single propulser
# B. the ceiling follows log2 of the count - two vessels are worth exactly
# what they were worth before the change, and the growth tapers after
# C. the fader's full travel reaches the WIDENED ceiling, not the old one
# D. losing a vessel mid-boost pulls the fleet back down to the new
# ceiling rather than leaving it faster than its crew can sustain
@ -53,14 +57,33 @@ func _process(delta: float) -> bool:
% [game_state.max_fleet_speed_multiplier, GameState.MAX_FLEET_SPEED_MULTIPLIER])
print("1 distorder -> ceiling %.1fx" % game_state.max_fleet_speed_multiplier)
# --- B. each additional vessel adds 1.0 ----------------------
# --- B. the ceiling grows with log2 of the count ---------------
var previous_gain: float = 1.0
for extra in range(1, 4):
fleet.add_ship(GameState.VESSEL_DISTORDER)
var expected: float = GameState.MAX_FLEET_SPEED_MULTIPLIER + float(extra)
var count: int = extra + 1
var expected: float = GameState.MAX_FLEET_SPEED_MULTIPLIER \
+ log(float(count)) / log(2.0)
if not is_equal_approx(game_state.max_fleet_speed_multiplier, expected):
return _fail("%d distorders give a ceiling of %.1f, expected %.1f" \
% [extra + 1, game_state.max_fleet_speed_multiplier, expected])
print("%d distorders -> ceiling %.1fx" % [extra + 1, game_state.max_fleet_speed_multiplier])
return _fail("%d propulsers give a ceiling of %.2f, expected %.2f" \
% [count, game_state.max_fleet_speed_multiplier, expected])
# Each vessel must be worth strictly less than the one before
# it. That is the whole point of the change, and asserting the
# formula alone would pass just as happily on a linear one.
var gain: float = game_state.max_fleet_speed_multiplier \
- (GameState.MAX_FLEET_SPEED_MULTIPLIER + log(float(count - 1)) / log(2.0))
if count > 2 and gain >= previous_gain:
return _fail("propulser %d added %.2f, no less than the %.2f the one before it added - the returns are not diminishing" \
% [count, gain, previous_gain])
previous_gain = gain
print("%d propulsers -> ceiling %.2fx (this one added %.2f)" \
% [count, game_state.max_fleet_speed_multiplier, gain])
# Two propulsers must still be worth exactly what they were before
# the change, or an existing fleet was quietly devalued.
if not is_equal_approx(GameState.MAX_FLEET_SPEED_MULTIPLIER + log(2.0) / log(2.0),
GameState.MAX_FLEET_SPEED_MULTIPLIER + 1.0):
return _fail("two propulsers no longer reach the ceiling they used to")
# --- C. the fader reaches the widened ceiling ----------------
# Dragging the track to its top must mean the CURRENT ceiling, or

View file

@ -0,0 +1,159 @@
extends SceneTree
# Headless gameplay test: run with
# godot --headless -s res://tests/test_gas_burner_pause.gd
# Forgejo #78: a gas burner converts gas the player may want for bombs into
# energy they may not need yet, and until now it did that relentlessly - the
# only way to stop it was to demolish it.
#
# Covers:
# A. the burner offers a "pause" action, and it is its PRIMARY one, so a
# single tap on the context button toggles it rather than opening a menu
# B. a running burner converts gas into energy
# C. a paused one converts nothing, and keeps its gas
# D. resuming converts again, and the fraction of a unit already worked
# through is not thrown away
# E. the button shows what it will DO - pause bars while running, a play
# triangle while stopped
var game_state: Node
var main: Node
var controller: Node
var burner_id: int = 0
var stage: int = 0
var elapsed: float = 0.0
var gas_at_pause: int = 0
var energy_at_pause: int = 0
func _initialize() -> void:
game_state = root.get_node("GameState")
game_state.buildings.clear()
game_state.extractors.clear()
game_state.transporters.clear()
game_state.reset_progression()
main = load("res://Main.tscn").instantiate()
root.add_child(main)
current_scene = main
controller = main.get_node("BuildController")
func _burner() -> Dictionary:
return game_state.find_building(burner_id)
func _stock(resource_type: String) -> int:
return game_state.building_resource(burner_id, resource_type)
func _process(delta: float) -> bool:
elapsed += delta
match stage:
0:
if elapsed < 0.3:
return false
main.get_node("EnemySpawner").set_process(false)
main.get_node("AsteroidField").set_process(false)
# Through the FIELD, not GameState directly: place() both records
# the building and spawns its node, and part E needs the node.
main.get_node("BuildingField").place(GameState.BUILDING_GAS_BURNER,
Vector2(600.0, 0.0))
burner_id = int(game_state.buildings[0].id)
game_state.building_inventory(burner_id).deposit(GameState.RESOURCE_GAS, 30)
if _stock(GameState.RESOURCE_GAS) <= 0:
return _fail("could not stock the burner with gas")
# --- A. it offers pause, as its primary action ----------------
var definition: Resource = load("res://BuildingDefinitions.gd") \
.get_definition(GameState.BUILDING_GAS_BURNER)
var visual: Node = definition.visual_scene.instantiate()
var provider: Node = visual.get_node_or_null("ActionProvider")
if provider == null:
visual.free()
return _fail("the gas burner visual has no ActionProvider")
var actions: PackedStringArray = provider.actions
visual.free()
if not Array(actions).has("pause"):
return _fail("the gas burner does not offer a pause action: %s" % str(actions))
if String(actions[0]) != "pause":
return _fail("pause is not the burner's primary action (%s comes first), so it would need a menu rather than one tap" % actions[0])
print("gas burner offers pause as its primary action")
stage = 1
elapsed = 0.0
return false
1:
# --- B. running, it converts ----------------------------------
if elapsed < 1.5:
return false
if _stock(GameState.RESOURCE_ENERGY) <= 0:
return _fail("a running burner made no energy in %.1fs" % elapsed)
print("running: %d gas left, %d energy made" \
% [_stock(GameState.RESOURCE_GAS), _stock(GameState.RESOURCE_ENERGY)])
if game_state.is_building_paused(burner_id):
return _fail("the burner started out paused")
if not game_state.toggle_building_paused(burner_id):
return _fail("toggling did not pause the burner")
gas_at_pause = _stock(GameState.RESOURCE_GAS)
energy_at_pause = _stock(GameState.RESOURCE_ENERGY)
stage = 2
elapsed = 0.0
return false
2:
# --- C. paused, it does nothing -------------------------------
if elapsed < 1.5:
return false
if _stock(GameState.RESOURCE_ENERGY) != energy_at_pause:
return _fail("a paused burner made %d more energy" \
% (_stock(GameState.RESOURCE_ENERGY) - energy_at_pause))
if _stock(GameState.RESOURCE_GAS) != gas_at_pause:
return _fail("a paused burner consumed %d gas" \
% (gas_at_pause - _stock(GameState.RESOURCE_GAS)))
print("paused for %.1fs: no gas burned, no energy made" % elapsed)
# --- D. resuming works again ----------------------------------
if game_state.toggle_building_paused(burner_id):
return _fail("toggling a paused burner did not resume it")
stage = 3
elapsed = 0.0
return false
3:
if elapsed < 1.5:
return false
if _stock(GameState.RESOURCE_ENERGY) <= energy_at_pause:
return _fail("a resumed burner made no further energy")
print("resumed: energy %d -> %d" \
% [energy_at_pause, _stock(GameState.RESOURCE_ENERGY)])
# --- E. the icon reports the action, not the state ------------
var building: Node = _find_building_node()
if building == null:
return _fail("no Building node was spawned for the burner")
var running_icon: int = controller._building_action_icon(building)
game_state.set_building_paused(burner_id, true)
var paused_icon: int = controller._building_action_icon(building)
game_state.set_building_paused(burner_id, false)
if running_icon != IconButton.Icon.PAUSE:
return _fail("a running burner's button does not show the pause glyph")
if paused_icon != IconButton.Icon.RESUME:
return _fail("a paused burner's button does not show the resume glyph")
print("button shows pause while running and resume while stopped")
print("TEST_GAS_BURNER_PAUSE: PASS")
quit(0)
return true
return false
func _find_building_node() -> Node:
for node in get_nodes_in_group("buildings"):
if is_instance_valid(node) and int(node.building_id) == burner_id:
return node
return null
func _fail(message: String) -> bool:
print("TEST_GAS_BURNER_PAUSE: FAIL (%s)" % message)
quit(1)
return true

View file

@ -0,0 +1,140 @@
extends SceneTree
# Headless gameplay test: run with
# godot --headless -s res://tests/test_pickup_feedback.gd
# Forgejo #79: collecting used to be silent - a rock vanished and a number in
# the corner of the screen changed. Which number, and by how much, was left
# for the player to notice. A "+N" in the resource's own colour now rises
# where the pickup happened.
#
# Covers:
# A. collecting ore raises a marker at the pickup point, carrying the right
# resource and amount
# B. it is built from the resource catalog's own glyph, so a material added
# later cannot end up with one mark in the HUD and another in the world
# C. it clears itself up rather than accumulating one node per pickup
# D. a pickup that is REFUSED - a full hold - raises nothing, so the marker
# never claims something the player did not get
var game_state: Node
var main: Node
var fleet: Node
var stage: int = 0
var elapsed: float = 0.0
func _initialize() -> void:
game_state = root.get_node("GameState")
game_state.buildings.clear()
game_state.extractors.clear()
game_state.reset_progression()
main = load("res://Main.tscn").instantiate()
root.add_child(main)
current_scene = main
fleet = main.get_node("Fleet")
const PICKUP_VFX = preload("res://ResourcePickupVFX.gd")
func _markers() -> Array:
var found: Array = []
for node in root.get_children():
if node.get_script() == PICKUP_VFX:
found.append(node)
return found
func _drop_rock_on_fleet() -> Node2D:
var rock: Node2D = load("res://Rock.tscn").instantiate()
rock.build_shape(7)
rock.position = fleet.ships[0].global_position
main.add_child(rock)
return rock
func _process(delta: float) -> bool:
elapsed += delta
match stage:
0:
if elapsed < 0.3:
return false
main.get_node("EnemySpawner").set_process(false)
main.get_node("AsteroidField").set_process(false)
for hazard in get_nodes_in_group("asteroids") + get_nodes_in_group("rocks"):
if is_instance_valid(hazard):
hazard.free()
fleet.spawn_ships(1, Vector2.ZERO, PackedStringArray([GameState.VESSEL_INTERCEPTOR]))
game_state.fleet_inventory.set_amount(GameState.RESOURCE_ORE, 0)
if not _markers().is_empty():
return _fail("a pickup marker existed before anything was collected")
_drop_rock_on_fleet()
stage = 1
elapsed = 0.0
return false
1:
if elapsed < 0.4:
return false
# --- A. one marker, right resource, right amount --------------
var markers: Array = _markers()
if markers.size() != 1:
return _fail("collecting one rock raised %d markers" % markers.size())
var marker: Node2D = markers[0]
if game_state.fleet_resource(GameState.RESOURCE_ORE) <= 0:
return _fail("the rock was not actually collected, so the marker is reporting a pickup that did not happen")
if marker.global_position.distance_to(fleet.ships[0].global_position) > 120.0:
return _fail("the marker appeared %.0f away from where the pickup happened" \
% marker.global_position.distance_to(fleet.ships[0].global_position))
# --- B. built from the catalog's own glyph --------------------
var definitions: Script = load("res://ResourceDefinitions.gd")
var ore: Resource = definitions.get_definition(GameState.RESOURCE_ORE)
if not marker.colour.is_equal_approx(ore.color):
return _fail("the marker is %s, but ore is %s" % [marker.colour, ore.color])
var glyph_scripts: Array = []
for child in marker.get_children():
glyph_scripts.append(child.get_script())
var probe: Node = ore.glyph_scene.instantiate()
var expected: Script = probe.get_script()
probe.free()
if expected not in glyph_scripts:
return _fail("the marker does not use the ore glyph the resource catalog defines")
print("collecting ore raised one marker at the pickup point, in ore's own colour and glyph")
stage = 2
elapsed = 0.0
return false
2:
# --- C. it cleans itself up -----------------------------------
if elapsed < 1.5:
return false
if not _markers().is_empty():
return _fail("%d marker(s) still on screen 1.5s later - they accumulate" % _markers().size())
print("marker cleared itself up")
# --- D. a refused pickup says nothing -------------------------
# Hold filled to capacity, so collect_cargo takes nothing.
var capacity: int = game_state.fleet_inventory.total_capacity
if capacity < 0:
return _fail("the fleet hold has no capacity limit, so a refused pickup cannot be staged")
game_state.fleet_inventory.set_amount(GameState.RESOURCE_ORE, capacity)
_drop_rock_on_fleet()
stage = 3
elapsed = 0.0
return false
3:
if elapsed < 0.4:
return false
if not _markers().is_empty():
return _fail("a full hold refused the rock but a marker claimed it was collected")
print("a pickup refused by a full hold raises no marker")
print("TEST_PICKUP_FEEDBACK: PASS")
quit(0)
return true
return false
func _fail(message: String) -> bool:
print("TEST_PICKUP_FEEDBACK: FAIL (%s)" % message)
quit(1)
return true