defense post

This commit is contained in:
evanpelle
2024-12-03 07:53:18 -08:00
parent 43aa7f8ddd
commit d173e22b6b
3 changed files with 12 additions and 3 deletions
+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[] {