From 4de9bb9e18eb7427566b6f33ce81eb00d01bd70b Mon Sep 17 00:00:00 2001 From: evanpelle Date: Sat, 31 Aug 2024 12:57:44 -0700 Subject: [PATCH] terrain affects attack --- src/client/graphics/TerritoryRenderer.ts | 1 - src/core/configuration/DefaultConfig.ts | 19 +++++++++++-------- src/core/execution/AttackExecution.ts | 7 ++++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/client/graphics/TerritoryRenderer.ts b/src/client/graphics/TerritoryRenderer.ts index b502a2d9c..8a171cd02 100644 --- a/src/client/graphics/TerritoryRenderer.ts +++ b/src/client/graphics/TerritoryRenderer.ts @@ -95,7 +95,6 @@ export class TerritoryRenderer { this.imageData.data[offset + 3] = 0; // Set alpha to 0 (fully transparent) } - tileUpdate(event: TileEvent) { this.tileToRenderQueue.push({tileEvent: event, lastUpdate: this.game.ticks() + this.random.nextFloat(0, .5)}) } diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index 8c76aa96a..bd0834166 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -32,21 +32,24 @@ export class DefaultConfig implements Config { attackLogic(attacker: Player, defender: Player | TerraNullius, tileToConquer: Tile): {attackerTroopLoss: number; defenderTroopLoss: number; tilesPerTickUsed: number} { if (defender.isPlayer()) { return { - attackerTroopLoss: Math.min(defender.troops() / 1000, 10), - defenderTroopLoss: Math.min(attacker.troops() / 2000, 5), - tilesPerTickUsed: 1 + attackerTroopLoss: Math.min(defender.troops() / 2000, 10) + tileToConquer.magnitude(), + defenderTroopLoss: Math.min(attacker.troops() / 3000, 5), + tilesPerTickUsed: tileToConquer.magnitude() + 1 } } else { - return {attackerTroopLoss: 1, defenderTroopLoss: 0, tilesPerTickUsed: 1} + return { + attackerTroopLoss: tileToConquer.magnitude(), + defenderTroopLoss: 0, + tilesPerTickUsed: tileToConquer.magnitude() + 1 + } } - } attackTilesPerTick(attacker: Player, defender: Player | TerraNullius, numAdjacentTilesWithEnemy: number): number { if (defender.isPlayer()) { - return within(attacker.numTilesOwned() / defender.numTilesOwned(), .01, .5) * numAdjacentTilesWithEnemy + return within(attacker.numTilesOwned() / defender.numTilesOwned() * 2, .01, .5) * numAdjacentTilesWithEnemy } else { - return numAdjacentTilesWithEnemy / 4 + return numAdjacentTilesWithEnemy } } @@ -70,7 +73,7 @@ export class DefaultConfig implements Config { } troopAdditionRate(player: Player): number { - let max = Math.sqrt(player.numTilesOwned()) * 1000 + 10000 + let max = Math.sqrt(player.numTilesOwned()) * 1000 + 10000 + 100000 max = Math.min(max, 1_000_000) let toAdd = 10 + (player.troops() + Math.sqrt(player.troops() * player.numTilesOwned())) / 250 diff --git a/src/core/execution/AttackExecution.ts b/src/core/execution/AttackExecution.ts index 49ad6827e..37726193b 100644 --- a/src/core/execution/AttackExecution.ts +++ b/src/core/execution/AttackExecution.ts @@ -89,7 +89,7 @@ export class AttackExecution implements Execution { return } - if (this.toConquer.size() < this.numTilesWithEnemy / 2) { + if (this.toConquer.size() < this.numTilesWithEnemy / 1.2) { this.calculateToConquer() } if (badTiles > 1000) { @@ -145,7 +145,8 @@ export class AttackExecution implements Execution { this.toConquer.clear() const newBorder: Set = new Set() - let existingBorder: ReadonlySet = this.borderTiles + // TODO: figure out existing border + let existingBorder: ReadonlySet = new Set() if (existingBorder.size == 0) { existingBorder = this._owner.borderTiles() } @@ -167,7 +168,7 @@ export class AttackExecution implements Execution { if (numOwnedByMe > 2) { numOwnedByMe = 1000 } - this.toConquer.enqueue(new TileContainer(neighbor, dist + -numOwnedByMe)) + this.toConquer.enqueue(new TileContainer(neighbor, -numOwnedByMe + tile.magnitude())) } } this.borderTiles = newBorder