defense post

This commit is contained in:
evanpelle
2024-12-01 21:31:01 -08:00
parent 43aa7f8ddd
commit d173e22b6b
3 changed files with 12 additions and 3 deletions
+2
View File
@@ -202,6 +202,8 @@
* add info view on top right DONE 11/30/2024
* add info view for units DONE 11/30/2024
* add defense post
* bugfix: destroyers can't find path to dest and freeze
* bugfix: when trade ships captured don't render
* use mini A* for all pathfinding
* record single player game stats
* add radiation from nuke
+8 -1
View File
@@ -120,7 +120,14 @@ export class TerritoryLayer implements Layer {
unitEvent(event: UnitEvent) {
if (event.unit.type() == UnitType.DefensePost) {
bfs(event.unit.tile(), dist(event.unit.tile(), this.game.config().defensePostRange())).forEach(t => this.enqueue(t))
bfs(
event.unit.tile(),
dist(event.unit.tile(), this.game.config().defensePostRange())
).forEach(t => {
if (t.isBorder()) {
this.enqueue(t)
}
})
}
}
+2 -2
View File
@@ -68,14 +68,14 @@ export class GameImpl implements MutableGame {
addTileDefenseBonus(tile: Tile, unit: Unit, amount: number): DefenseBonus {
const df = { unit: unit, tile: tile, amount: amount };
(tile as TileImpl)._defenseBonuses.push(df)
this.eventBus.emit(new TileEvent(tile))
// this.eventBus.emit(new TileEvent(tile))
return df
}
removeTileDefenseBonus(bonus: DefenseBonus): void {
const t = bonus.tile as TileImpl
t._defenseBonuses = t._defenseBonuses.filter(db => db != bonus)
this.eventBus.emit(new TileEvent(bonus.tile))
// this.eventBus.emit(new TileEvent(bonus.tile))
}
units(...types: UnitType[]): UnitImpl[] {