From ca546919bbc33cb988adb81b67f3a7513e7b4bf4 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Mon, 12 Aug 2024 07:54:42 -0700 Subject: [PATCH] make attack troop lost and speed depend on # of troops --- TODO.txt | 9 ++++++--- src/core/execution/AttackExecution.ts | 14 +++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/TODO.txt b/TODO.txt index 72661e48a..04beeddf7 100644 --- a/TODO.txt +++ b/TODO.txt @@ -5,13 +5,16 @@ * better troop addition logic DONE 8/11/2024 * better expansion, add back directed expansion DONE 8/11/2024 * use pastel theme for territories DONE 8/11/2024 -* cache border in AttackExecution for perf -* harder to expand on other players (defense) -* lose troops when attacked +* cache border in AttackExecution for perf DONE 8/11/2024 +* harder to expand on other players (defense) DONE 8/12/2024 +* lose troops when attacked DONE 8/12/2024 +* slower to attack stronger players DONE 8/12/2024 +* move all attack related config to Settings * fix boat bugs * add username in front page * improve front page * upload and start server +* fix enemy islands when attacking * make boats larger * have boats not get close to shore * better algorithm for name render placement diff --git a/src/core/execution/AttackExecution.ts b/src/core/execution/AttackExecution.ts index cb0f390ef..41618be98 100644 --- a/src/core/execution/AttackExecution.ts +++ b/src/core/execution/AttackExecution.ts @@ -48,7 +48,7 @@ export class AttackExecution implements Execution { return } - if (this.toConquer.size() < this.numTilesWithEnemy / 1.5) { + if (this.toConquer.size() < this.numTilesWithEnemy / 2) { this.calculateToConquer() } if (this.toConquer.size() == 0 || badTiles > 100) { @@ -65,8 +65,13 @@ export class AttackExecution implements Execution { continue } this._owner.conquer(tileToConquer) - this.troops -= 1 - numTilesPerTick -= 1 + if (this.target.isPlayer()) { + this.troops -= Math.max(this.target.troops() / this._owner.troops(), 1) + numTilesPerTick -= Math.max(this.target.troops() / this._owner.troops(), .25) + } else { + this.troops -= 1 + numTilesPerTick -= 1 + } } } @@ -94,6 +99,9 @@ export class AttackExecution implements Execution { if (this.targetCell != null) { dist = manhattanDist(tile.cell(), this.targetCell) } + if (numOwnedByMe > 2) { + numOwnedByMe = 1000 + } this.toConquer.add(new TileContainer(neighbor, dist + -numOwnedByMe + (tile.cell().x * tile.cell().y) % 2)) } }