mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 09:50:43 +00:00
fix boat distance wrapping bug
This commit is contained in:
@@ -180,9 +180,6 @@ export class ClientGame {
|
||||
}
|
||||
|
||||
private inputEvent(event: MouseDownEvent) {
|
||||
// if (this.turns.length < this.config.turnsUntilGameStart()) {
|
||||
// return
|
||||
// }
|
||||
if (!this.isActive) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -138,14 +138,14 @@ export class BoatAttackExecution implements Execution {
|
||||
}
|
||||
|
||||
private closestShoreTileToTarget(player: Player, target: Cell): Tile | null {
|
||||
const shoreTiles = Array.from(player.borderTiles()).filter(t => t.onShore() && t.neighbors().filter(n => n.isOcean()).length > 0)
|
||||
const shoreTiles = Array.from(player.borderTiles()).filter(t => t.isOceanShore())
|
||||
if (shoreTiles.length == 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
return shoreTiles.reduce((closest, current) => {
|
||||
const closestDistance = manhattanDist(target, closest.cell());
|
||||
const currentDistance = manhattanDist(target, current.cell());
|
||||
const closestDistance = manhattanDistWrapped(target, closest.cell(), this.mg.width());
|
||||
const currentDistance = manhattanDistWrapped(target, current.cell(), this.mg.width());
|
||||
return currentDistance < closestDistance ? current : closest;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user