mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 09:50:43 +00:00
fixed attackexecution speed bug
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user