fixed attackexecution speed bug

This commit is contained in:
evanpelle
2024-09-02 11:50:29 -07:00
parent adac26a44f
commit 23cd55a398
4 changed files with 8 additions and 11 deletions
+2 -2
View File
@@ -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
}
}
+2 -7
View File
@@ -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)
+3 -1
View File
@@ -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));
}