mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-07 11:15:58 +00:00
reimplement defense posts
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { consolex } from "../Consolex";
|
||||
import {
|
||||
Cell,
|
||||
DefenseBonus,
|
||||
Execution,
|
||||
Game,
|
||||
Player,
|
||||
@@ -17,12 +16,7 @@ export class DefensePostExecution implements Execution {
|
||||
private post: Unit;
|
||||
private active: boolean = true;
|
||||
|
||||
private defenseBonuses: DefenseBonus[] = [];
|
||||
|
||||
constructor(
|
||||
private ownerId: PlayerID,
|
||||
private tile: TileRef,
|
||||
) {}
|
||||
constructor(private ownerId: PlayerID, private tile: TileRef) {}
|
||||
|
||||
init(mg: Game, ticks: number): void {
|
||||
this.mg = mg;
|
||||
@@ -38,25 +32,8 @@ export class DefensePostExecution implements Execution {
|
||||
return;
|
||||
}
|
||||
this.post = this.player.buildUnit(UnitType.DefensePost, 0, spawnTile);
|
||||
this.mg
|
||||
.bfs(
|
||||
spawnTile,
|
||||
manhattanDistFN(spawnTile, this.mg.config().defensePostRange()),
|
||||
)
|
||||
.forEach((t) => {
|
||||
if (this.mg.isLake(t)) {
|
||||
this.defenseBonuses.push(
|
||||
this.mg.addTileDefenseBonus(
|
||||
t,
|
||||
this.post,
|
||||
this.mg.config().defensePostDefenseBonus(),
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!this.post.isActive()) {
|
||||
this.defenseBonuses.forEach((df) => this.mg.removeTileDefenseBonus(df));
|
||||
this.active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user