diff --git a/src/client/graphics/layers/TerritoryLayer.ts b/src/client/graphics/layers/TerritoryLayer.ts index 852c79ef6..def05456b 100644 --- a/src/client/graphics/layers/TerritoryLayer.ts +++ b/src/client/graphics/layers/TerritoryLayer.ts @@ -149,7 +149,13 @@ export class TerritoryLayer implements Layer { } } - paintTerritory(tile: Tile) { + paintTerritory(tile: Tile, isBorder: boolean = false, parent: Tile = null) { + if (isBorder && !tile.hasOwner()) { + return + } + if (!isBorder) { + tile.neighbors().forEach(t => this.paintTerritory(t, true, tile)) + } if (!tile.hasOwner()) { if (tile.hasFallout()) { this.paintCell(tile.cell(), this.theme.falloutColor(), 150) diff --git a/src/core/GameView.ts b/src/core/GameView.ts index 4bc316b97..4e02dcf48 100644 --- a/src/core/GameView.ts +++ b/src/core/GameView.ts @@ -8,6 +8,8 @@ import { WorkerClient } from './worker/WorkerClient'; export class TileView { + private _neighbors: TileView[] = [] + constructor(private game: GameView, public data: TileUpdate, private _terrain: TerrainTile) { } type(): TerrainType { @@ -23,7 +25,12 @@ export class TileView { return this.data?.ownerID !== undefined && this.data.ownerID !== 0; } isBorder(): boolean { - return this.data?.isBorder + for (const n of this.neighbors()) { + if (n.data?.ownerID != this.data?.ownerID) { + return true + } + } + return false } cell(): Cell { return this._terrain.cell() @@ -35,8 +42,11 @@ export class TileView { return this._terrain } - neighbors(): Tile[] { - return this._terrain.neighbors().map(t => this.game.tile(t.cell())) + neighbors(): TileView[] { + if (this._neighbors.length == 0) { + this._neighbors = this._terrain.neighbors().map(t => this.game.tile(t.cell())) + } + return this._neighbors } hasDefenseBonus(): boolean { @@ -303,7 +313,7 @@ export class GameView { players(): Player[] { return [] } - tile(cell: Cell): Tile { + tile(cell: Cell): TileView { return this.tiles[cell.x][cell.y] } isOnMap(cell: Cell): boolean { diff --git a/src/core/game/GameImpl.ts b/src/core/game/GameImpl.ts index 700cb80a0..d5540d4d2 100644 --- a/src/core/game/GameImpl.ts +++ b/src/core/game/GameImpl.ts @@ -399,7 +399,7 @@ export class GameImpl implements MutableGame { (t.owner() as PlayerImpl)._borderTiles.delete(t); t._isBorder = false } - this.updates.push(t.toUpdate()) + // this.updates.push(t.toUpdate()) } }