mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-17 05:34:37 +00:00
Implement Stop/Start trading with all (#2278)
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" /> - [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 regression is found: abodcraft1
This commit is contained in:
committed by
evanpelle
parent
6b696685b5
commit
0a2b6ed9a6
@@ -94,6 +94,7 @@ export class PlayerImpl implements Player {
|
||||
private relations = new Map<Player, number>();
|
||||
|
||||
private lastDeleteUnitTick: Tick = -1;
|
||||
private lastEmbargoAllTick: Tick = -1;
|
||||
|
||||
public _incomingAttacks: Attack[] = [];
|
||||
public _outgoingAttacks: Attack[] = [];
|
||||
@@ -689,6 +690,28 @@ export class PlayerImpl implements Player {
|
||||
this.lastDeleteUnitTick = this.mg.ticks();
|
||||
}
|
||||
|
||||
canEmbargoAll(): boolean {
|
||||
// Cooldown gate
|
||||
if (
|
||||
this.mg.ticks() - this.lastEmbargoAllTick <
|
||||
this.mg.config().embargoAllCooldown()
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
// At least one eligible player exists
|
||||
for (const p of this.mg.players()) {
|
||||
if (p.id() === this.id()) continue;
|
||||
if (p.type() === PlayerType.Bot) continue;
|
||||
if (this.isOnSameTeam(p)) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
recordEmbargoAll(): void {
|
||||
this.lastEmbargoAllTick = this.mg.ticks();
|
||||
}
|
||||
|
||||
hasEmbargoAgainst(other: Player): boolean {
|
||||
return this.embargoes.has(other.id());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user