mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-26 16:04:35 +00:00
bugfix: ports not spawning on coastline
This commit is contained in:
@@ -40,27 +40,13 @@ export class PortExecution implements Execution {
|
||||
if (this.port == null) {
|
||||
const tile = this.tile;
|
||||
const player = this.mg.player(this._owner);
|
||||
if (!player.canBuild(UnitType.Port, tile)) {
|
||||
const spawn = player.canBuild(UnitType.Port, tile);
|
||||
if (spawn === false) {
|
||||
consolex.warn(`player ${player} cannot build port at ${this.tile}`);
|
||||
this.active = false;
|
||||
return;
|
||||
}
|
||||
const spawns = Array.from(
|
||||
this.mg.bfs(
|
||||
tile,
|
||||
manhattanDistFN(tile, this.mg.config().radiusPortSpawn()),
|
||||
),
|
||||
).sort(
|
||||
(a, b) =>
|
||||
this.mg.manhattanDist(a, tile) - this.mg.manhattanDist(b, tile),
|
||||
);
|
||||
|
||||
if (spawns.length == 0) {
|
||||
consolex.warn(`cannot find spawn for port`);
|
||||
this.active = false;
|
||||
return;
|
||||
}
|
||||
this.port = player.buildUnit(UnitType.Port, 0, spawns[0]);
|
||||
this.port = player.buildUnit(UnitType.Port, 0, spawn);
|
||||
}
|
||||
|
||||
if (!this.port.isActive()) {
|
||||
|
||||
@@ -730,7 +730,12 @@ export class PlayerImpl implements Player {
|
||||
}
|
||||
|
||||
portSpawn(tile: TileRef): TileRef | false {
|
||||
const spawns = Array.from(this.mg.bfs(tile, manhattanDistFN(tile, 20)))
|
||||
const spawns = Array.from(
|
||||
this.mg.bfs(
|
||||
tile,
|
||||
manhattanDistFN(tile, this.mg.config().radiusPortSpawn()),
|
||||
),
|
||||
)
|
||||
.filter((t) => this.mg.owner(t) == this && this.mg.isOceanShore(t))
|
||||
.sort(
|
||||
(a, b) =>
|
||||
|
||||
Reference in New Issue
Block a user