From 6298b28a3f0b2cfd1e35077320413a6299e1ead4 Mon Sep 17 00:00:00 2001 From: Scott Anderson <662325+scottanderson@users.noreply.github.com> Date: Mon, 14 Apr 2025 21:13:05 -0400 Subject: [PATCH] BreakAllianceExecution --- .../alliance/BreakAllianceExecution.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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); } }