BreakAllianceExecution

This commit is contained in:
Scott Anderson
2025-04-14 21:13:05 -04:00
parent 01ed6e70bc
commit 6298b28a3f
@@ -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);
}
}