mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 10:00:44 +00:00
terrain affects attack
This commit is contained in:
@@ -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)})
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user