terrain affects attack

This commit is contained in:
evanpelle
2024-08-31 12:57:44 -07:00
parent 39464f1d05
commit 4de9bb9e18
3 changed files with 15 additions and 12 deletions
-1
View File
@@ -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)})
}
+11 -8
View File
@@ -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
+4 -3
View File
@@ -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<Tile> = new Set()
let existingBorder: ReadonlySet<Tile> = this.borderTiles
// TODO: figure out existing border
let existingBorder: ReadonlySet<Tile> = new Set<Tile>()
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