fixed bug: cannot request alliance multiple times or if already allied

This commit is contained in:
evanpelle
2024-09-18 17:34:31 -07:00
parent 4bab6a5271
commit bdbe1b759c
4 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -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
+3
View File
@@ -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`;
+1
View File
@@ -139,6 +139,7 @@ export interface Player {
outgoingAllianceRequests(): AllianceRequest[]
alliances(): Alliance[]
alliedWith(other: Player): boolean
pendingAllianceRequestWith(other: Player): boolean
toString(): string
}
+6
View File
@@ -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());