mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 09:40:44 +00:00
improve boat attack ux
This commit is contained in:
@@ -96,6 +96,7 @@
|
||||
* directed expansion
|
||||
* more random names for game id & client id
|
||||
* Make fake humans
|
||||
* Make three terrain types: Plains, highlands, mountains
|
||||
* UI: win condition & popup
|
||||
* UI: boats
|
||||
* UI: current attacks
|
||||
|
||||
@@ -206,12 +206,18 @@ export class ClientGame {
|
||||
return
|
||||
}
|
||||
|
||||
let bordersOcean = false
|
||||
let bordersEnemy = false
|
||||
if (tile.isLand()) {
|
||||
const bordersWithDists: Tile[] = []
|
||||
for (const border of this.myPlayer.borderTiles()) {
|
||||
if (border.isOceanShore()) {
|
||||
bordersOcean = true
|
||||
}
|
||||
for (const n of border.neighbors()) {
|
||||
if (n.owner() == tile.owner()) {
|
||||
bordersWithDists.push(n)
|
||||
bordersEnemy = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,7 +231,7 @@ export class ClientGame {
|
||||
|
||||
const enemyShoreDists = Array.from(bfs(
|
||||
tile,
|
||||
and((t) => t.isLand() && t.owner() == tile.owner(), dist(tile, 400))
|
||||
and((t) => t.isLand() && t.owner() == tile.owner(), dist(tile, bordersEnemy ? 10 : 500))
|
||||
)).filter(t => t.isOceanShore()).map(t => ({
|
||||
dist: manhattanDist(t.cell(), tile.cell()),
|
||||
tile: t
|
||||
@@ -233,17 +239,16 @@ export class ClientGame {
|
||||
|
||||
|
||||
|
||||
if (bordersWithDists.length == 0 && enemyShoreDists.length == 0) {
|
||||
if (!bordersEnemy && !bordersOcean) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
let borderTileClosest = 10000000
|
||||
let enemyShoreClosest = 10000
|
||||
if (bordersWithDists.length > 0) {
|
||||
borderTileClosest = borderWithDists[0].dist
|
||||
}
|
||||
if (enemyShoreDists.length > 0) {
|
||||
if (enemyShoreDists.length > 0 && bordersOcean) {
|
||||
enemyShoreClosest = enemyShoreDists[0].dist
|
||||
}
|
||||
if (enemyShoreClosest < borderTileClosest) {
|
||||
@@ -260,7 +265,7 @@ export class ClientGame {
|
||||
}
|
||||
const tn = Array.from(bfs(tile, dist(tile, 3)))
|
||||
.filter(t => t.isOceanShore())
|
||||
.filter(t => !t.hasOwner())
|
||||
.filter(t => t.owner() == tile.owner())
|
||||
.sort((a, b) => manhattanDist(tile.cell(), a.cell()) - manhattanDist(tile.cell(), b.cell()))
|
||||
if (tn.length > 0) {
|
||||
this.sendBoatAttackIntent(targetID, tn[0].cell(), this.gs.config().boatAttackAmount(this.myPlayer, owner))
|
||||
|
||||
@@ -28,9 +28,9 @@ export const devConfig = new class extends DefaultConfig {
|
||||
|
||||
troopAdditionRate(player: Player): number {
|
||||
if (player.isBot()) {
|
||||
return 100000
|
||||
return 1000
|
||||
} else {
|
||||
return 100000
|
||||
return 10000
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,6 @@ export class AttackExecution implements Execution {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: remove this and fix directed expansion.
|
||||
this.targetCell = null
|
||||
|
||||
this._owner = mg.player(this._ownerID)
|
||||
@@ -138,7 +137,7 @@ export class AttackExecution implements Execution {
|
||||
}
|
||||
this.toConquer.enqueue(new TileContainer(
|
||||
neighbor,
|
||||
this.random.nextInt(0, 2) - numOwnedByMe + Math.floor(tile.magnitude() / 10),
|
||||
dist / 100 + this.random.nextInt(0, 2) - numOwnedByMe + Math.floor(tile.magnitude() / 10),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user