Skip to content

Commit 53e1a5b

Browse files
committed
fix: add Unit.maxHealth() missing from cherry-picked warship decay
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.
1 parent 2767929 commit 53e1a5b

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

src/core/game/Game.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,8 @@ export interface Unit {
479479
transportShipState(): TransportShipState;
480480
updateTransportShipState(update: Partial<TransportShipState>): void;
481481
health(): number;
482+
/** Max health from unit info (1 for units without health). */
483+
maxHealth(): number;
482484
modifyHealth(delta: number, attacker?: Player): void;
483485

484486
// Troops

src/core/game/UnitImpl.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ export class UnitImpl implements Unit {
185185
health(): number {
186186
return Number(this._health);
187187
}
188+
maxHealth(): number {
189+
return this.info().maxHealth ?? 1;
190+
}
188191
hasHealth(): boolean {
189192
return this.info().maxHealth !== undefined;
190193
}

0 commit comments

Comments
 (0)