From b4f287517c5e97cdfe11b02615bdb5ee02bbed1c Mon Sep 17 00:00:00 2001 From: Scott Anderson <662325+scottanderson@users.noreply.github.com> Date: Mon, 14 Apr 2025 19:52:47 -0400 Subject: [PATCH] MoveWarshipExecution --- src/core/execution/MoveWarshipExecution.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/execution/MoveWarshipExecution.ts b/src/core/execution/MoveWarshipExecution.ts index c7b5197a1..415ada80a 100644 --- a/src/core/execution/MoveWarshipExecution.ts +++ b/src/core/execution/MoveWarshipExecution.ts @@ -4,7 +4,7 @@ const cancelDelay = 2; export class MoveWarshipExecution implements Execution { private active = true; - private mg: Game; + private mg: Game | null = null; constructor( public readonly unitId: number, @@ -16,7 +16,10 @@ export class MoveWarshipExecution implements Execution { } tick(ticks: number): void { - const warship = this.mg.units().find((u) => u.id() == this.unitId); + if (this.mg === null) { + throw new Error("Not initialized"); + } + const warship = this.mg.units().find((u) => u.id() === this.unitId); if (!warship) { console.log("MoveWarshipExecution: warship is already dead"); return;