Step 3: Track hull damage
Some checks failed
Build / build (push) Failing after 19s

Added real-time tracking of cumulative hull damage from collisions.

**Modified: src/ship.ts**
- Subscribe to shipStatus.onStatusChanged in initialize()
- Filter for hull status type with negative delta (damage, not repair)
- Call gameStats.recordHullDamage() with absolute value of delta
- Accumulates all damage over time (e.g., 15 hits at 0.01 each = 0.15 total)

The Hull Damage Taken statistic now updates in real-time on the status screen, showing cumulative damage as a percentage.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Michael Mainguy 2025-11-08 03:58:11 -06:00
parent e4fbbce2c7
commit 8fc956f112

View File

@ -215,6 +215,14 @@ export class Ship {
this._gameStats.recordAsteroidDestroyed();
});
// Subscribe to ship status changes to track hull damage
this._scoreboard.shipStatus.onStatusChanged.add((event) => {
if (event.statusType === "hull" && event.delta < 0) {
// Hull damage (delta is negative)
this._gameStats.recordHullDamage(Math.abs(event.delta));
}
});
// Initialize status screen
this._statusScreen = new StatusScreen(DefaultScene.MainScene, this._gameStats);
this._statusScreen.initialize(this._camera);