diff --git a/TODO.txt b/TODO.txt index 6a79b5726..bf3dde511 100644 --- a/TODO.txt +++ b/TODO.txt @@ -122,12 +122,12 @@ * make alliance icon DONE 9/19/2024 * bots attack traitors DONE 9/19/2024 * BUG: alliance should stop attack DONE 9/19/2024 -* create event box -* BUG: bot attacks don't stop when allied ? +* BUG: bot attacks don't stop when allied DONE 9/19/2024 +* click alliance sends alliance request DONE 9/20/2024 +* notification for alliance request DONE 9/20/2024 +* comfirm alliance DONE 9/20/2024 +* create event box DONE 9/20/2024 * make fake humans easier -* click alliance sends alliance request -* notification for alliance request -* comfirm alliance * first place has crown * alliance has icon * BUG: FakeHuman don't be enemy if don't share border diff --git a/src/client/graphics/layers/UILayer.ts b/src/client/graphics/layers/UILayer.ts index 6646b9837..10ff5625e 100644 --- a/src/client/graphics/layers/UILayer.ts +++ b/src/client/graphics/layers/UILayer.ts @@ -28,10 +28,10 @@ export class UILayer implements Layer { constructor( private eventBus: EventBus, - private game: Game, - private clientID: ClientID, - private transformHandler: TransformHandler - ) { + private game: Game, + private clientID: ClientID, + private transformHandler: TransformHandler + ) { } @@ -229,6 +229,9 @@ export class UILayer implements Layer { private onRightClick(e: RightClickEvent) { const cell = this.transformHandler.screenToWorldCoordinates(e.x, e.y) + if (!this.game.isOnMap(cell)) { + return + } const tile = this.game.tile(cell) if (!tile.hasOwner()) { return diff --git a/src/core/execution/PlayerExecution.ts b/src/core/execution/PlayerExecution.ts index c902b6071..91c65d182 100644 --- a/src/core/execution/PlayerExecution.ts +++ b/src/core/execution/PlayerExecution.ts @@ -51,7 +51,8 @@ export class PlayerExecution implements Execution { clusters.sort((a, b) => b.size - a.size); const main = clusters.shift() - if (this.isSurroundedBySamePlayer(main)) { + const surroundedBy = this.surroundedBySamePlayer(main) + if (surroundedBy && !this.player.alliedWith(surroundedBy)) { this.removeCluster(main) } @@ -62,7 +63,7 @@ export class PlayerExecution implements Execution { } } - private isSurroundedBySamePlayer(cluster: Set): boolean { + private surroundedBySamePlayer(cluster: Set): false | Player { const enemies = new Set() for (const tile of cluster) { if (tile.isOceanShore() || tile.neighbors().find(n => !n.hasOwner())) { @@ -75,7 +76,10 @@ export class PlayerExecution implements Execution { return false } } - return true + if (enemies.size != 1) { + return false + } + return Array.from(enemies)[0] } private isSurrounded(cluster: Set): boolean {