format codebase with prettier

This commit is contained in:
Evan
2025-02-01 12:05:11 -08:00
parent cd121a5cd4
commit 4ee37323f9
98 changed files with 12190 additions and 10233 deletions
+63 -44
View File
@@ -1,57 +1,76 @@
import { consolex } from "../Consolex";
import { Cell, DefenseBonus, Execution, Game, Player, Unit, PlayerID, UnitType } from "../game/Game";
import {
Cell,
DefenseBonus,
Execution,
Game,
Player,
Unit,
PlayerID,
UnitType,
} from "../game/Game";
import { manhattanDistFN, TileRef } from "../game/GameMap";
export class DefensePostExecution implements Execution {
private player: Player;
private mg: Game;
private post: Unit;
private active: boolean = true;
private player: Player
private mg: Game
private post: Unit
private active: boolean = true
private defenseBonuses: DefenseBonus[] = [];
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;
this.player = mg.player(this.ownerId);
}
init(mg: Game, ticks: number): void {
this.mg = mg
this.player = mg.player(this.ownerId)
tick(ticks: number): void {
if (this.post == null) {
const spawnTile = this.player.canBuild(UnitType.DefensePost, this.tile);
if (spawnTile == false) {
consolex.warn("cannot build Defense Post");
this.active = false;
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(),
),
);
}
});
}
tick(ticks: number): void {
if (this.post == null) {
const spawnTile = this.player.canBuild(UnitType.DefensePost, this.tile)
if (spawnTile == false) {
consolex.warn('cannot build Defense Post')
this.active = false
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
}
if (!this.post.isActive()) {
this.defenseBonuses.forEach((df) => this.mg.removeTileDefenseBonus(df));
this.active = false;
return;
}
}
owner(): Player {
return null
}
owner(): Player {
return null;
}
isActive(): boolean {
return this.active
}
isActive(): boolean {
return this.active;
}
activeDuringSpawnPhase(): boolean {
return false
}
}
activeDuringSpawnPhase(): boolean {
return false;
}
}