diff --git a/src/core/execution/MissileSiloExecution.ts b/src/core/execution/MissileSiloExecution.ts index 928b8afdf..0133abeb6 100644 --- a/src/core/execution/MissileSiloExecution.ts +++ b/src/core/execution/MissileSiloExecution.ts @@ -11,9 +11,9 @@ import { TileRef } from "../game/GameMap"; export class MissileSiloExecution implements Execution { private active = true; - private mg: Game; - private player: Player; - private silo: Unit; + private mg: Game | null = null; + private player: Player | null = null; + private silo: Unit | null = null; constructor( private _owner: PlayerID, @@ -32,7 +32,11 @@ export class MissileSiloExecution implements Execution { } tick(ticks: number): void { - if (this.silo == null) { + if (this.mg === null || this.player === null) { + throw new Error("Not initialized"); + } + + if (this.silo === null) { if (!this.player.canBuild(UnitType.MissileSilo, this.tile)) { consolex.warn( `player ${this.player} cannot build missile silo at ${this.tile}`, @@ -44,14 +48,14 @@ export class MissileSiloExecution implements Execution { cooldownDuration: this.mg.config().SiloCooldown(), }); - if (this.player != this.silo.owner()) { + if (this.player !== this.silo.owner()) { this.player = this.silo.owner(); } } if ( this.silo.isCooldown() && - this.silo.ticksLeftInCooldown(this.mg.config().SiloCooldown()) == 0 + this.silo.ticksLeftInCooldown(this.mg.config().SiloCooldown()) === 0 ) { this.silo.setCooldown(false); }