finish defense post

This commit is contained in:
evanpelle
2024-12-03 07:53:18 -08:00
parent d173e22b6b
commit 330b6b93cb
10 changed files with 31 additions and 10 deletions
+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[] {
+4
View File
@@ -20,6 +20,10 @@ export class TileImpl implements Tile {
private readonly _terrain: TerrainTileImpl
) { }
terrainType(): TerrainType {
return this._terrain.type
}
defenseBonus(player: Player): number {
if (this.owner() == player) {
throw Error(`cannot get defense bonus of tile already owned by player`)