mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 07:40:43 +00:00
742a544a69
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>
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import { Execution, Game, Player, Unit } from "../game/Game";
|
|
|
|
export class UpgradeStructureExecution implements Execution {
|
|
private structure: Unit | undefined;
|
|
private cost: bigint;
|
|
|
|
constructor(
|
|
private player: Player,
|
|
private unitId: number,
|
|
) {}
|
|
|
|
init(mg: Game, ticks: number): void {
|
|
this.structure = mg.unit(this.unitId);
|
|
if (this.structure && this.structure.owner() !== this.player) {
|
|
console.warn(`structure not owned by player`);
|
|
this.structure = undefined;
|
|
}
|
|
|
|
if (this.structure === undefined) {
|
|
console.warn(`structure is undefined`);
|
|
return;
|
|
}
|
|
|
|
if (!this.player.canUpgradeUnit(this.structure)) {
|
|
console.warn(
|
|
`[UpgradeStructureExecution] unit type ${this.structure.type()} cannot be upgraded`,
|
|
);
|
|
return;
|
|
}
|
|
this.player.upgradeUnit(this.structure);
|
|
return;
|
|
}
|
|
|
|
tick(ticks: number): void {
|
|
return;
|
|
}
|
|
|
|
isActive(): boolean {
|
|
return false;
|
|
}
|
|
|
|
activeDuringSpawnPhase(): boolean {
|
|
return false;
|
|
}
|
|
}
|