mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 17:36:38 +00:00
380eab5d12
## Description: fixes #2275 Added global Start/Stop trading; use your **player panel** to trigger it. <img width="370" height="540" alt="Screenshot 2025-10-23 184447" src="https://github.com/user-attachments/assets/c3b7967e-ffdd-4f37-ba67-b60a602278ce" /> ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: abodcraft1
39 lines
886 B
TypeScript
39 lines
886 B
TypeScript
import { Execution, Game, Player, PlayerType } from "../game/Game";
|
|
|
|
export class EmbargoAllExecution implements Execution {
|
|
constructor(
|
|
private readonly player: Player,
|
|
private readonly action: "start" | "stop",
|
|
) {}
|
|
|
|
init(mg: Game, _: number): void {
|
|
if (!this.player.canEmbargoAll()) {
|
|
return;
|
|
}
|
|
const me = this.player;
|
|
for (const p of mg.players()) {
|
|
if (p.id() === me.id()) continue;
|
|
if (p.type() === PlayerType.Bot) continue;
|
|
if (me.isOnSameTeam(p)) continue;
|
|
|
|
if (this.action === "start") {
|
|
if (!me.hasEmbargoAgainst(p)) me.addEmbargo(p, false);
|
|
} else {
|
|
if (me.hasEmbargoAgainst(p)) me.stopEmbargo(p);
|
|
}
|
|
}
|
|
|
|
this.player.recordEmbargoAll();
|
|
}
|
|
|
|
tick(_: number): void {}
|
|
|
|
isActive(): boolean {
|
|
return false;
|
|
}
|
|
|
|
activeDuringSpawnPhase(): boolean {
|
|
return false;
|
|
}
|
|
}
|