mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 00:21:55 +00:00
4d3fa6425b
## Description: The MoveWarshipExecution now verifies that the player who requested to move owns the warship. This prevents players from moving other players' warships. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
37 lines
896 B
TypeScript
37 lines
896 B
TypeScript
import { Execution, Game, Player, UnitType } from "../game/Game";
|
|
import { TileRef } from "../game/GameMap";
|
|
|
|
export class MoveWarshipExecution implements Execution {
|
|
constructor(
|
|
private readonly owner: Player,
|
|
private readonly unitId: number,
|
|
private readonly position: TileRef,
|
|
) {}
|
|
|
|
init(mg: Game, ticks: number): void {
|
|
const warship = this.owner
|
|
.units(UnitType.Warship)
|
|
.find((u) => u.id() === this.unitId);
|
|
if (!warship) {
|
|
console.warn("MoveWarshipExecution: warship not found");
|
|
return;
|
|
}
|
|
if (!warship.isActive()) {
|
|
console.warn("MoveWarshipExecution: warship is not active");
|
|
return;
|
|
}
|
|
warship.setPatrolTile(this.position);
|
|
warship.setTargetTile(undefined);
|
|
}
|
|
|
|
tick(ticks: number): void {}
|
|
|
|
isActive(): boolean {
|
|
return false;
|
|
}
|
|
|
|
activeDuringSpawnPhase(): boolean {
|
|
return false;
|
|
}
|
|
}
|