From 53e1a5b03e35c27a3130c1c534f9416b8d6c724f Mon Sep 17 00:00:00 2001 From: evanpelle Date: Fri, 3 Jul 2026 17:13:44 -0700 Subject: [PATCH] fix: add Unit.maxHealth() missing from cherry-picked warship decay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The doomsday-clock warship decay commit (#4499) calls ws.maxHealth(), which was introduced on main by the warship veterancy PR (#4433) — not present on this branch — breaking the build. Add maxHealth() to the Unit interface and UnitImpl, returning the unit-info base (info().maxHealth ?? 1), the same value modifyHealth already caps against. No veterancy bonus here since this branch lacks the veterancy system; merging with main will pick up the adjusted version with only a one-line conflict in the method body. --- src/core/game/Game.ts | 2 ++ src/core/game/UnitImpl.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/core/game/Game.ts b/src/core/game/Game.ts index 4b05feedd..737810795 100644 --- a/src/core/game/Game.ts +++ b/src/core/game/Game.ts @@ -479,6 +479,8 @@ export interface Unit { transportShipState(): TransportShipState; updateTransportShipState(update: Partial): void; health(): number; + /** Max health from unit info (1 for units without health). */ + maxHealth(): number; modifyHealth(delta: number, attacker?: Player): void; // Troops diff --git a/src/core/game/UnitImpl.ts b/src/core/game/UnitImpl.ts index 5071d51f0..26841520c 100644 --- a/src/core/game/UnitImpl.ts +++ b/src/core/game/UnitImpl.ts @@ -185,6 +185,9 @@ export class UnitImpl implements Unit { health(): number { return Number(this._health); } + maxHealth(): number { + return this.info().maxHealth ?? 1; + } hasHealth(): boolean { return this.info().maxHealth !== undefined; }