diff --git a/src/core/execution/alliance/BreakAllianceExecution.ts b/src/core/execution/alliance/BreakAllianceExecution.ts index 848d5ec63..65e2ebc16 100644 --- a/src/core/execution/alliance/BreakAllianceExecution.ts +++ b/src/core/execution/alliance/BreakAllianceExecution.ts @@ -3,9 +3,9 @@ import { Execution, Game, Player, PlayerID } from "../../game/Game"; export class BreakAllianceExecution implements Execution { private active = true; - private requestor: Player; - private recipient: Player; - private mg: Game; + private requestor: Player | null = null; + private recipient: Player | null = null; + private mg: Game | null = null; constructor( private requestorID: PlayerID, @@ -33,14 +33,21 @@ export class BreakAllianceExecution implements Execution { } tick(ticks: number): void { + if ( + this.mg === null || + this.requestor === null || + this.recipient === null + ) { + throw new Error("Not initialized"); + } const alliance = this.requestor.allianceWith(this.recipient); - if (alliance == null) { + if (alliance === null) { consolex.warn("cant break alliance, not allied"); } else { this.requestor.breakAlliance(alliance); this.recipient.updateRelation(this.requestor, -200); for (const player of this.mg.players()) { - if (player != this.requestor) { + if (player !== this.requestor) { player.updateRelation(this.requestor, -40); } }