diff --git a/TODO.txt b/TODO.txt index eb8ec8bc5..b09db5ee1 100644 --- a/TODO.txt +++ b/TODO.txt @@ -39,7 +39,8 @@ * make coasts look better DONE 8/22/2024 * only put imageDataOnce, draw territories on top DONE 8/23/2024 * have boats not get close to shore DONE 8/23/2024 -* improve terrain colors +* improve terrain colors DONE 8/23/2024 +* BUG: boat doesn't work if on lake if other player not on same lake * try vintage theme * BUG: boat doesn't work if on lake if other player not on same lake * Allow boats to attack TerraNullius diff --git a/src/client/graphics/GameRenderer.ts b/src/client/graphics/GameRenderer.ts index 3613a929b..bd7792f75 100644 --- a/src/client/graphics/GameRenderer.ts +++ b/src/client/graphics/GameRenderer.ts @@ -147,9 +147,11 @@ export class GameRenderer { boatEvent(event: BoatEvent) { this.bfs(event.oldTile, 2).forEach(t => this.paintTerritory(t)) + if (event.boat.isActive()) { + this.bfs(event.boat.tile(), 2).forEach(t => this.paintCell(t.cell(), this.theme.borderColor(event.boat.owner().id()))) + this.bfs(event.boat.tile(), 1).forEach(t => this.paintCell(t.cell(), this.theme.territoryColor(event.boat.owner().id()))) - this.bfs(event.boat.tile(), 2).forEach(t => this.paintCell(t.cell(), this.theme.borderColor(event.boat.owner().id()))) - this.bfs(event.boat.tile(), 1).forEach(t => this.paintCell(t.cell(), this.theme.territoryColor(event.boat.owner().id()))) + } } private bfs(tile: Tile, dist: number): Set { diff --git a/src/client/graphics/NameRenderer.ts b/src/client/graphics/NameRenderer.ts index b8f52355b..7b1f5cc6f 100644 --- a/src/client/graphics/NameRenderer.ts +++ b/src/client/graphics/NameRenderer.ts @@ -93,7 +93,7 @@ export class NameRenderer { return false } } - if (render.boundingBox.max.x < min.x || render.boundingBox.max.y < min.y || render.boundingBox.min.x > max.x || render.boundingBox.max.y > max.y) { + if (render.boundingBox.max.x < min.x || render.boundingBox.max.y < min.y || render.boundingBox.min.x > max.x || render.boundingBox.min.y > max.y) { return false } return true diff --git a/src/core/Game.ts b/src/core/Game.ts index 0221b50b9..d124680fd 100644 --- a/src/core/Game.ts +++ b/src/core/Game.ts @@ -59,6 +59,7 @@ export interface Boat { tile(): Tile owner(): Player target(): Player | TerraNullius + isActive(): boolean } export interface MutableBoat extends Boat { @@ -66,6 +67,7 @@ export interface MutableBoat extends Boat { owner(): MutablePlayer target(): MutablePlayer | TerraNullius setTroops(troops: number): void + delete(): void } export interface TerraNullius { diff --git a/src/core/GameImpl.ts b/src/core/GameImpl.ts index 0284698c0..346036541 100644 --- a/src/core/GameImpl.ts +++ b/src/core/GameImpl.ts @@ -67,6 +67,7 @@ class TileImpl implements Tile { } export class BoatImpl implements MutableBoat { + private _active = true constructor( private g: GameImpl, @@ -96,6 +97,14 @@ export class BoatImpl implements MutableBoat { target(): PlayerImpl | TerraNullius { return this._target } + delete(): void { + this._owner._boats = this._owner._boats.filter(b => b != this) + this._active = false + this.g.fireBoatUpdateEvent(this, this._tile) + } + isActive(): boolean { + return this._active + } } export class PlayerImpl implements MutablePlayer { diff --git a/src/core/configuration/PastelTheme.ts b/src/core/configuration/PastelTheme.ts index 4a3dd7bd8..970e76c9e 100644 --- a/src/core/configuration/PastelTheme.ts +++ b/src/core/configuration/PastelTheme.ts @@ -9,7 +9,7 @@ export const pastelTheme = new class implements Theme { private background = colord({r: 100, g: 100, b: 100}); private land = colord({r: 244, g: 243, b: 198}); - private shore = colord({r: 234, g: 343, b: 188}); + private shore = colord({r: 254, g: 253, b: 208}); private water = colord({r: 160, g: 203, b: 231}); private shorelineWater = colord({r: 150, g: 193, b: 221}); diff --git a/src/core/execution/BoatAttackExecution.ts b/src/core/execution/BoatAttackExecution.ts index 9bb0bb2c4..861fc2487 100644 --- a/src/core/execution/BoatAttackExecution.ts +++ b/src/core/execution/BoatAttackExecution.ts @@ -92,11 +92,13 @@ export class BoatAttackExecution implements Execution { } if (this.dst.owner() == this.attacker) { this.attacker.addTroops(this.troops) + this.boat.delete() this.active = false return } this.attacker.conquer(this.dst) this.mg.addExecution(new AttackExecution(this.troops, this.attacker.id(), this.targetID, null, this.config)) + this.boat.delete() this.active = false return }