From 727588199aedbb9c27661fba1fc7683354fd8576 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Wed, 4 Sep 2024 20:50:42 -0700 Subject: [PATCH] improve boat attack ux --- TODO.txt | 1 + src/client/ClientGame.ts | 15 ++++++++++----- src/core/configuration/DevConfig.ts | 4 ++-- src/core/execution/AttackExecution.ts | 3 +-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/TODO.txt b/TODO.txt index be56734d8..c735a10a0 100644 --- a/TODO.txt +++ b/TODO.txt @@ -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 diff --git a/src/client/ClientGame.ts b/src/client/ClientGame.ts index 86571536a..83f31993e 100644 --- a/src/client/ClientGame.ts +++ b/src/client/ClientGame.ts @@ -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)) diff --git a/src/core/configuration/DevConfig.ts b/src/core/configuration/DevConfig.ts index f46b925f4..7585634c9 100644 --- a/src/core/configuration/DevConfig.ts +++ b/src/core/configuration/DevConfig.ts @@ -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 } } } \ No newline at end of file diff --git a/src/core/execution/AttackExecution.ts b/src/core/execution/AttackExecution.ts index 6545e4050..88d62b5d1 100644 --- a/src/core/execution/AttackExecution.ts +++ b/src/core/execution/AttackExecution.ts @@ -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), )) } }