mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-07 11:15:58 +00:00
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.
This commit is contained in:
@@ -479,6 +479,8 @@ export interface Unit {
|
||||
transportShipState(): TransportShipState;
|
||||
updateTransportShipState(update: Partial<TransportShipState>): void;
|
||||
health(): number;
|
||||
/** Max health from unit info (1 for units without health). */
|
||||
maxHealth(): number;
|
||||
modifyHealth(delta: number, attacker?: Player): void;
|
||||
|
||||
// Troops
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user