mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-26 18:34:39 +00:00
BreakAllianceExecution
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user