mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-23 05:05:26 +00:00
fix boat bug
This commit is contained in:
@@ -64,6 +64,7 @@ export class AttackExecution implements Execution {
|
||||
badTiles++
|
||||
continue
|
||||
}
|
||||
// TODO: move this to configs
|
||||
this._owner.conquer(tileToConquer)
|
||||
if (this.target.isPlayer()) {
|
||||
this.troops -= Math.max(this.target.troops() / this._owner.troops(), 1)
|
||||
|
||||
@@ -47,6 +47,12 @@ export class BoatAttackExecution implements Execution {
|
||||
|
||||
this.src = this.closestShoreTileToTarget(this.attacker, this.cell)
|
||||
this.dst = this.closestShoreTileToTarget(this.target, this.cell)
|
||||
|
||||
if(this.src == null || this.dst == null) {
|
||||
this.active = false
|
||||
return
|
||||
}
|
||||
|
||||
this.path = this.computePath(this.src, this.dst)
|
||||
if (this.path != null) {
|
||||
console.log(`got path ${this.path.map(t => t.cell().toString())}`)
|
||||
@@ -91,8 +97,11 @@ export class BoatAttackExecution implements Execution {
|
||||
return this.active
|
||||
}
|
||||
|
||||
private closestShoreTileToTarget(player: Player, target: Cell): Tile {
|
||||
private closestShoreTileToTarget(player: Player, target: Cell): Tile | null {
|
||||
const shoreTiles = Array.from(player.borderTiles()).filter(t => t.onShore())
|
||||
if (shoreTiles.length == 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
return shoreTiles.reduce((closest, current) => {
|
||||
const closestDistance = manhattanDist(target, closest.cell());
|
||||
|
||||
Reference in New Issue
Block a user