Laser shooters consume energy from the fleet hold when firing #61
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Each laser shot costs energy from the fleet hold, the same way gas bomb shots cost gas.
Depends on: #54 (gas burner / energy resource - energy must exist) and #58 (laser shooter vessel - the weapon must exist). Land both first.
Scope
Mirror #60 (gas bomber ammunition) exactly, so the two skill shots behave identically from the player's point of view:
const ENERGY_PER_SHOT: intonLaserController(suggest 8).LaserController's fire path: require and withdrawENERGY_PER_SHOTfromGameState.fleet_inventorybefore consuming the firing ship's cooldown. On failure, fire nothing, consume nothing, cancel the aim.enabledrule requires both a ready laser vessel and affordable energy.Acceptance criteria
ENERGY_PER_SHOTfrom the fleet hold.Tests
tests/test_laser_ammo.gd(bash tests/run_tests.sh laser).Repo notes (read before starting)
/storage/emulated/0/GodotProjects/SpaceshipTest.touchon it. Android FUSE does not bump mtime under~/storage/shared, and Godot's import cache will silently keep serving the old version, making a correct fix look like it did nothing.bash tests/run_tests.sh <substring>; full suite with no argument. Tests areSceneTreescripts printingTEST_NAME: PASS/TEST_NAME: FAIL (reason)and callingquit(0|1)- copy the shape oftests/test_capture_points.gd.bash tests/screenshot.sh <res://Scene.tscn> <out.png> <frames> 720x1280. Use few frames (~15); the software rasterizer is slow.--headlessrenders nothing at all, so it cannot validate visuals.NeonDraw/NeonPiece; do not introduce a different visual idiom.*Definitionresources plus capability component scenes. Do not addif type == "..."branches.FileAccess, nouser://).GameStateis an in-memory autoload. Do not invent a save system.Traps that have already cost hours on this codebase
const X = preload(...)in a test file that is itself the-sentry point. It evaluates during that file's own early compilation, which can run before autoloads are registered; any script it pulls in that referencesGameStateinside a function body then fails to compile withIdentifier not found: GameState. Usevar X: Scriptplusload()inside_initialize()instead. See the header comment intests/test_capture_points.gd.[]to a typedArray[Resource]export from another script fails at runtime - the compiler only sees the target asResourceand cannot confirm the element type. Leave the declared default alone, or build the typed array inside the owning script.Fleet.spawn_ships(0, ...)does not empty the fleet - it falls back to one default interceptor by design. Clearfleet.shipsexplicitly if a test or preview needs genuinely zero ships.ship.positionwithout also settingship.move_targetletsShip._physics_processsteer it straight back toward the stale target within a few frames.SceneTreetest's own_process()clock under device load, even with--fixed-fps 60. Gate waits on the system's own state (a component's timer or flag), not onelapsed >= duration.queue_free()s itself (projectiles, shells) must not be re-read inside a per-frame wait condition - cache the scalar you need before the wait._screenshot_tool.gd's_initialize(), so their_ready()races the game scene's own_ready(). Do setup on the first_process()tick, andget_tree().paused = trueonce everything is placed if the scene must hold still.Implemented and pushed in
facbd83.Mirrors #60's gas bomber ammunition exactly:
ENERGY_PER_SHOT(8) drawn fromGameState.fleet_inventorybefore consuming the firing ship's cooldown, the laser button'senabledrule requires affordability too, and an unaffordable-but-otherwise-ready press still explains itself through a newLaserStatuslabel rather than silently doing nothing.Added two small generic
GameStatehelpers this needed:deposit_fleet_resource()/deposit_bank_resource(), counterparts to #60'swithdraw_fleet_resource()for resources (energy) with no dedicatedfleet_cargo/fleet_gas_cargo-style property of their own.Tests:
tests/test_laser_ammo.gd(bash tests/run_tests.sh laser) - banked energy does not enable firing (only the fleet hold counts), insufficient fleet energy disables the button and explains itself with no cooldown/energy spent, and firing drains exactlyENERGY_PER_SHOTwith the bank left untouched. Full suite passed at the time.