Files
OpenFrontIO/src/core/execution/BoatRetreatExecution.ts
T
Scott Anderson 9163f0d710 Enable the @typescript-eslint/prefer-readonly eslint rule (#1859)
## Description:

Enable the `@typescript-eslint/prefer-readonly` eslint rule.

## 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
2025-08-18 20:09:21 -04:00

42 lines
842 B
TypeScript

import { Execution, Game, Player, UnitType } from "../game/Game";
export class BoatRetreatExecution implements Execution {
private active = true;
constructor(
private readonly player: Player,
private readonly unitID: number,
) {}
init(mg: Game, ticks: number): void {}
tick(ticks: number): void {
const unit = this.player
.units()
.find(
(unit) =>
unit.id() === this.unitID && unit.type() === UnitType.TransportShip,
);
if (!unit) {
console.warn(`Didn't find outgoing boat with id ${this.unitID}`);
this.active = false;
return;
}
unit.orderBoatRetreat();
this.active = false;
}
owner(): Player {
return this.player;
}
isActive(): boolean {
return this.active;
}
activeDuringSpawnPhase(): boolean {
return false;
}
}