can attack terra nullius with boats

This commit is contained in:
evanpelle
2024-08-23 20:33:09 -07:00
parent 41d7c77d2d
commit 7bdad3577d
3 changed files with 25 additions and 15 deletions
+10 -7
View File
@@ -190,13 +190,16 @@ export class ClientGame {
const owner = tile.owner()
const targetID = owner.isPlayer() ? owner.id() : null
if (tile.owner() != this.myPlayer && tile.isLand()) {
// const ocean = Array.from(bfs(tile, 4))
// .filter(t => t.isOcean)
// .sort((a, b) => manhattanDist(tile.cell(), a.cell()) - manhattanDist(tile.cell(), b.cell()))
// if (ocean.length > 0) {
// this.sendBoatAttackIntent(targetID, cell, this.config.player().boatAttackAmount(this.myPlayer, owner))
// return
// }
const tn = Array.from(bfs(tile, 6))
.filter(t => t.isOcean())
.filter(t => !t.hasOwner())
.sort((a, b) => manhattanDist(tile.cell(), a.cell()) - manhattanDist(tile.cell(), b.cell()))
.flatMap(t => t.neighbors())
.filter(n => n.isShore())
if (tn.length > 0) {
this.sendBoatAttackIntent(targetID, tn[0].cell(), this.config.player().boatAttackAmount(this.myPlayer, owner))
return
}
if (this.myPlayer.sharesBorderWith(tile.owner())) {
this.sendAttackIntent(targetID, cell, this.config.player().attackAmount(this.myPlayer, owner))