2661 PR 3/3 Warship Manual Override, Aggro Override, and Heal-at-Port Command (#3501)

Part of [#2661](https://github.com/openfrontio/OpenFrontIO/issues/2661)
(split into 3 PRs so they are not too large..)

## Description:

Part 3/3 of
[#2661](https://github.com/openfrontio/OpenFrontIO/issues/2661).

This PR adds the retreat control and override behavior for warships:

- Manual override: moving a warship manually cancels retreat and
suppresses auto-retreat for 5 seconds
- Aggro override: a retreating warship will aggro a nearby enemy
transport or warship before continuing retreat
- Heal-at-port command for sending a warship to a friendly port manually
- Friendly-port validation for HealAtPortExecution
- Regression tests for manual override, aggro override, and heal-at-port
behavior



## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

zixer._

---------

Co-authored-by: iamlewis <lewismmmm@gmail.com>
Co-authored-by: evanpelle <evanpelle@gmail.com>
This commit is contained in:
Zixer1
2026-04-30 13:54:28 -06:00
committed by GitHub
co-authored by iamlewis evanpelle
parent f1d0136a06
commit 742a544a69
20 changed files with 781 additions and 246 deletions
+23 -7
View File
@@ -24,8 +24,10 @@ import {
TerraNullius,
Tick,
TrainType,
TransportShipState,
UnitInfo,
UnitType,
WarshipState,
} from "./Game";
import { GameMap, TileRef } from "./GameMap";
import {
@@ -115,14 +117,28 @@ export class UnitView {
troops(): number {
return this.data.troops;
}
retreating(): boolean {
if (
this.type() !== UnitType.TransportShip &&
this.type() !== UnitType.Warship
) {
throw Error("Must be a transport ship or warship");
warshipState(): WarshipState {
if (this.data.warshipState === undefined) {
throw new Error("warshipState called on non-warship unit");
}
return this.data.retreating;
return this.data.warshipState;
}
updateWarshipState(_update: Partial<WarshipState>): void {
throw new Error("updateWarshipState is not supported on UnitView");
}
isInCombat(): boolean {
return this.data.warshipState?.isInCombat ?? false;
}
touch(): void {
throw new Error("touch is not supported on UnitView");
}
transportShipState(): TransportShipState {
return this.data.transportShipState ?? { isRetreating: false, troops: 0 };
}
updateTransportShipState(
_update: Pick<TransportShipState, "isRetreating">,
): void {
throw new Error("updateTransportShipState is not supported on UnitView");
}
tile(): TileRef {
return this.data.pos;