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; }