Files
OpenFrontIO/src/core/execution/EmbargoAllExecution.ts
T
Abdallah Bahrawi 380eab5d12 Implement Stop/Start trading with all (#2278)
## 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
2025-10-25 20:59:40 +00:00

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;
}
}