mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 12:51:30 +00:00
fixed attack speed up bug
This commit is contained in:
@@ -95,6 +95,7 @@
|
||||
* when attacking by boat, attack execution only starts from boat pixel DONE 9/4/2024
|
||||
* Make three terrain types: Plains, highlands, mountains DONE 9/5/2024
|
||||
* more random names for game id & client id DONE 9/5/2024
|
||||
* BUG: attacks speed up DONE 9/6/2024
|
||||
* Make fake humans
|
||||
* directed expansion
|
||||
* UI: win condition & popup
|
||||
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 823 KiB After Width: | Height: | Size: 823 KiB |
@@ -228,7 +228,6 @@ export class ClientGame {
|
||||
tile: t
|
||||
})).sort((a, b) => a.dist - b.dist);
|
||||
|
||||
|
||||
const enemyShoreDists = Array.from(bfs(
|
||||
tile,
|
||||
and((t) => t.isLand() && t.owner() == tile.owner(), dist(tile, bordersEnemy ? 10 : 500))
|
||||
@@ -237,8 +236,6 @@ export class ClientGame {
|
||||
tile: t
|
||||
})).sort((a, b) => a.dist - b.dist);
|
||||
|
||||
|
||||
|
||||
if (!bordersEnemy && !bordersOcean) {
|
||||
return
|
||||
}
|
||||
@@ -251,7 +248,7 @@ export class ClientGame {
|
||||
if (enemyShoreDists.length > 0 && bordersOcean) {
|
||||
enemyShoreClosest = enemyShoreDists[0].dist
|
||||
}
|
||||
if (enemyShoreClosest < borderTileClosest / 2) {
|
||||
if (enemyShoreClosest < borderTileClosest / 4) {
|
||||
this.sendBoatAttackIntent(targetID, enemyShoreDists[0].tile.cell(), this.gs.config().boatAttackAmount(this.myPlayer, owner))
|
||||
} else {
|
||||
this.sendAttackIntent(targetID, cell, this.gs.config().attackAmount(this.myPlayer, owner))
|
||||
|
||||
@@ -41,8 +41,8 @@ export class DefaultConfig implements Config {
|
||||
}
|
||||
if (defender.isPlayer()) {
|
||||
return {
|
||||
attackerTroopLoss: within(defender.troops() / 2000 + mag, 1, 10),
|
||||
defenderTroopLoss: Math.min(attacker.troops() / 3000, 5),
|
||||
attackerTroopLoss: within(defender.troops() / attacker.troops() / 10 * mag, 1, 100),
|
||||
defenderTroopLoss: within(attacker.troops() / defender.troops() / 10, 1, 100),
|
||||
tilesPerTickUsed: mag + 1
|
||||
}
|
||||
} else {
|
||||
@@ -56,9 +56,9 @@ export class DefaultConfig implements Config {
|
||||
|
||||
attackTilesPerTick(attacker: Player, defender: Player | TerraNullius, numAdjacentTilesWithEnemy: number): number {
|
||||
if (defender.isPlayer()) {
|
||||
return within(attacker.troops() / defender.troops() * 2, .01, .5) * numAdjacentTilesWithEnemy * 2 / 5
|
||||
return within(attacker.troops() / defender.troops() * 2, .01, .5) * numAdjacentTilesWithEnemy * 3
|
||||
} else {
|
||||
return numAdjacentTilesWithEnemy * 2 / 5
|
||||
return numAdjacentTilesWithEnemy * 2
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ export const devConfig = new class extends DefaultConfig {
|
||||
// if (player.isBot()) {
|
||||
// return 1000
|
||||
// } else {
|
||||
// return 10000
|
||||
// return 1000000
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -14,6 +14,8 @@ export class AttackExecution implements Execution {
|
||||
|
||||
private mg: MutableGame
|
||||
|
||||
private border = new Set<Tile>()
|
||||
|
||||
constructor(
|
||||
private troops: number,
|
||||
private _ownerID: PlayerID,
|
||||
@@ -71,6 +73,7 @@ export class AttackExecution implements Execution {
|
||||
|
||||
private refreshToConquer() {
|
||||
this.toConquer.clear()
|
||||
this.border.clear()
|
||||
for (const tile of this._owner.borderTiles()) {
|
||||
this.addNeighbors(tile)
|
||||
}
|
||||
@@ -84,7 +87,9 @@ export class AttackExecution implements Execution {
|
||||
return
|
||||
}
|
||||
|
||||
let numTilesPerTick = this.mg.config().attackTilesPerTick(this._owner, this.target, this.toConquer.size() + this.random.nextInt(0, 5))
|
||||
let numTilesPerTick = this.mg.config().attackTilesPerTick(this._owner, this.target, this.border.size + this.random.nextInt(0, 5))
|
||||
// console.log(`num tiles per tick: ${numTilesPerTick}`)
|
||||
// console.log(`num execs: ${this.mg.executions().length}`)
|
||||
|
||||
|
||||
while (numTilesPerTick > 0) {
|
||||
@@ -95,14 +100,13 @@ export class AttackExecution implements Execution {
|
||||
|
||||
if (this.toConquer.size() == 0) {
|
||||
this.refreshToConquer()
|
||||
if (this.toConquer.size() == 0) {
|
||||
this.active = false
|
||||
this._owner.addTroops(this.troops)
|
||||
return
|
||||
}
|
||||
this.active = false
|
||||
this._owner.addTroops(this.troops)
|
||||
return
|
||||
}
|
||||
|
||||
const tileToConquer = this.toConquer.dequeue().tile
|
||||
this.border.delete(tileToConquer)
|
||||
|
||||
const onBorder = tileToConquer.neighbors().filter(t => t.owner() == this._owner).length > 0
|
||||
if (tileToConquer.owner() != this.target || !onBorder) {
|
||||
@@ -125,6 +129,7 @@ export class AttackExecution implements Execution {
|
||||
if (neighbor.isWater() || neighbor.owner() != this.target) {
|
||||
continue
|
||||
}
|
||||
this.border.add(neighbor)
|
||||
let numOwnedByMe = neighbor.neighbors()
|
||||
.filter(t => t.isLand())
|
||||
.filter(t => t.owner() == this._owner)
|
||||
@@ -133,6 +138,9 @@ export class AttackExecution implements Execution {
|
||||
if (this.targetCell != null) {
|
||||
dist = manhattanDist(tile.cell(), this.targetCell)
|
||||
}
|
||||
// if() {
|
||||
|
||||
// }
|
||||
if (numOwnedByMe > 2) {
|
||||
numOwnedByMe = 10
|
||||
}
|
||||
@@ -140,14 +148,17 @@ export class AttackExecution implements Execution {
|
||||
switch (tile.terrain()) {
|
||||
case TerrainType.Plains:
|
||||
mag = 1
|
||||
break
|
||||
case TerrainType.Highland:
|
||||
mag = 2
|
||||
break
|
||||
case TerrainType.Mountain:
|
||||
mag = 5
|
||||
mag = 3
|
||||
break
|
||||
}
|
||||
this.toConquer.enqueue(new TileContainer(
|
||||
neighbor,
|
||||
dist / 100 + this.random.nextInt(0, 2) - numOwnedByMe + Math.floor(tile.magnitude() / 10),
|
||||
dist / 100 + this.random.nextInt(0, 3) - numOwnedByMe * 2 + mag,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user