mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-04 01:50:38 +00:00
fixed bug: cannot request alliance multiple times or if already allied
This commit is contained in:
@@ -114,7 +114,7 @@
|
||||
* front page mobile friendly DONE 9/15/2024
|
||||
* game mobile friendly DONE 9/16/2024
|
||||
* UI: basic win condition & popup DONE 9/16/2024
|
||||
* right click popup alliance option
|
||||
* right click popup alliance option DONE 9/17/2024
|
||||
* BUG: can't ally same person twice
|
||||
* make fake humans easier
|
||||
* click alliance sends alliance request
|
||||
|
||||
@@ -253,6 +253,9 @@ export class UILayer implements Layer {
|
||||
console.warn('my player not found')
|
||||
return
|
||||
}
|
||||
if (myPlayer.alliedWith(owner) || myPlayer.pendingAllianceRequestWith(owner)) {
|
||||
return
|
||||
}
|
||||
|
||||
this.customMenu!.style.display = 'block';
|
||||
this.customMenu!.style.left = `${e.x}px`;
|
||||
|
||||
@@ -139,6 +139,7 @@ export interface Player {
|
||||
outgoingAllianceRequests(): AllianceRequest[]
|
||||
alliances(): Alliance[]
|
||||
alliedWith(other: Player): boolean
|
||||
pendingAllianceRequestWith(other: Player): boolean
|
||||
toString(): string
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +124,12 @@ export class PlayerImpl implements MutablePlayer {
|
||||
return this.alliances().find(a => a.recipient() == other || a.requestor() == other) != null
|
||||
}
|
||||
|
||||
pendingAllianceRequestWith(other: Player): boolean {
|
||||
return this.incomingAllianceRequests().find(ar => ar.requestor() == other) != null
|
||||
|| this.outgoingAllianceRequests().find(ar => ar.recipient() == other) != null
|
||||
|
||||
}
|
||||
|
||||
|
||||
hash(): number {
|
||||
return simpleHash(this.id()) * (this.troops() + this.numTilesOwned());
|
||||
|
||||
Reference in New Issue
Block a user