From 23cd55a398e0a16865ea2dcbbef55fee35981bcb Mon Sep 17 00:00:00 2001 From: evanpelle Date: Mon, 2 Sep 2024 11:50:29 -0700 Subject: [PATCH] fixed attackexecution speed bug --- TODO.txt | 2 +- src/core/configuration/DefaultConfig.ts | 4 ++-- src/core/execution/AttackExecution.ts | 9 ++------- src/server/StructuredLog.ts | 4 +++- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/TODO.txt b/TODO.txt index 90983c2bf..32d56bc19 100644 --- a/TODO.txt +++ b/TODO.txt @@ -80,7 +80,7 @@ * remove tiny islands DONE 9/1/2024 * Create exit to menu button DONE 9/2/2024 * show next game in menu DONE 9/2/2024 -* BUG: attacks starts slow but gets faster +* BUG: attacks starts slow but gets faster DONE 9/2/2024 * test & deploy game --- v2 Release diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index a20b5fa18..8df80ef47 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -48,9 +48,9 @@ export class DefaultConfig implements Config { attackTilesPerTick(attacker: Player, defender: Player | TerraNullius, numAdjacentTilesWithEnemy: number): number { if (defender.isPlayer()) { - return within(attacker.numTilesOwned() / defender.numTilesOwned() * 2, .01, .5) * numAdjacentTilesWithEnemy * 2 / 25 + return within(attacker.numTilesOwned() / defender.numTilesOwned() * 2, .01, .5) * numAdjacentTilesWithEnemy * 2 / 10 } else { - return numAdjacentTilesWithEnemy * 2 / 25 + return numAdjacentTilesWithEnemy * 2 / 10 } } diff --git a/src/core/execution/AttackExecution.ts b/src/core/execution/AttackExecution.ts index fab415c5d..8945bd1ef 100644 --- a/src/core/execution/AttackExecution.ts +++ b/src/core/execution/AttackExecution.ts @@ -13,8 +13,6 @@ export class AttackExecution implements Execution { private mg: MutableGame - private numTilesWithEnemy = 0 - constructor( private troops: number, private _ownerID: PlayerID, @@ -31,7 +29,6 @@ export class AttackExecution implements Execution { return } - // TODO: remove this and fix directed expansion. this.targetCell = null @@ -84,9 +81,9 @@ export class AttackExecution implements Execution { return } - let numTilesPerTick = this.mg.config().attackTilesPerTick(this._owner, this.target, this.numTilesWithEnemy + this.random.nextInt(0, 5)) + let numTilesPerTick = this.mg.config().attackTilesPerTick(this._owner, this.target, this.toConquer.size() + this.random.nextInt(0, 5)) + - let tries = 0 while (numTilesPerTick > 0) { if (this.troops < 1) { this.active = false @@ -109,7 +106,6 @@ export class AttackExecution implements Execution { continue } this.addNeighbors(tileToConquer) - const {attackerTroopLoss, defenderTroopLoss, tilesPerTickUsed} = this.mg.config().attackLogic(this._owner, this.target, tileToConquer) numTilesPerTick -= tilesPerTickUsed this.troops -= attackerTroopLoss @@ -126,7 +122,6 @@ export class AttackExecution implements Execution { if (neighbor.isWater() || neighbor.owner() != this.target) { continue } - this.numTilesWithEnemy += 1 let numOwnedByMe = neighbor.neighbors() .filter(t => t.isLand()) .filter(t => t.owner() == this._owner) diff --git a/src/server/StructuredLog.ts b/src/server/StructuredLog.ts index db629f4ef..071e47b23 100644 --- a/src/server/StructuredLog.ts +++ b/src/server/StructuredLog.ts @@ -14,7 +14,9 @@ export function slog(eventType: string, description, data: any, severity = LogSe data: data }; if (process.env.GAME_ENV == 'dev') { - console.log(description) + if (severity != LogSeverity.DEBUG) { + console.log(description) + } } else { console.log(JSON.stringify(logEntry)); }