created path finding web worker

This commit is contained in:
Evan
2024-11-28 12:25:34 -08:00
parent 2216c34c41
commit 3e4f4e42cf
24 changed files with 643 additions and 306 deletions
+3 -2
View File
@@ -5,6 +5,7 @@ import { AttackExecution } from "./AttackExecution";
import { TransportShipExecution } from "./TransportShipExecution";
import { SpawnExecution } from "./SpawnExecution";
import { PortExecution } from "./PortExecution";
import { AsyncPathFinder, AsyncPathFinderCreator } from "../pathfinding/AsyncPathFinding";
export class FakeHumanExecution implements Execution {
@@ -21,7 +22,7 @@ export class FakeHumanExecution implements Execution {
private relations = new Map<Player, number>()
constructor(private playerInfo: PlayerInfo, private cell: Cell, private strength: number) {
constructor(private asyncPathFinder: AsyncPathFinderCreator, private playerInfo: PlayerInfo, private cell: Cell, private strength: number) {
this.random = new PseudoRandom(simpleHash(playerInfo.id))
}
@@ -151,7 +152,7 @@ export class FakeHumanExecution implements Execution {
const oceanTiles = Array.from(this.player.borderTiles()).filter(t => t.isOceanShore())
if (oceanTiles.length > 0) {
const buildTile = this.random.randElement(oceanTiles)
this.mg.addExecution(new PortExecution(this.player.id(), buildTile.cell()))
this.mg.addExecution(new PortExecution(this.player.id(), buildTile.cell(), this.asyncPathFinder))
}
}
}