mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-05 06:12:00 +00:00
increased game length, balanced attacks
This commit is contained in:
@@ -36,22 +36,28 @@ export class AttackExecution implements Execution {
|
||||
this._owner.setTroops(this._owner.troops() - this.troops)
|
||||
this.mg = mg
|
||||
|
||||
if (this.target.isPlayer()) {
|
||||
for (const exec of mg.executions()) {
|
||||
if (exec instanceof AttackExecution) {
|
||||
const otherAttack = exec as AttackExecution
|
||||
if (otherAttack.target == this._owner && this.target == otherAttack._owner) {
|
||||
if (otherAttack.troops > this.troops) {
|
||||
otherAttack.troops -= this.troops
|
||||
otherAttack.calculateToConquer()
|
||||
this.active = false
|
||||
return
|
||||
} else {
|
||||
this.troops -= otherAttack.troops
|
||||
otherAttack.active = false
|
||||
}
|
||||
for (const exec of mg.executions()) {
|
||||
if (exec.isActive() && exec instanceof AttackExecution) {
|
||||
const otherAttack = exec as AttackExecution
|
||||
// Target has opposing attack, cancel them out
|
||||
if (this.target.isPlayer() && otherAttack.target == this._owner && this.target == otherAttack._owner) {
|
||||
if (otherAttack.troops > this.troops) {
|
||||
otherAttack.troops -= this.troops
|
||||
otherAttack.calculateToConquer()
|
||||
this.active = false
|
||||
return
|
||||
} else {
|
||||
this.troops -= otherAttack.troops
|
||||
otherAttack.active = false
|
||||
}
|
||||
}
|
||||
// Existing attack on same target, add troops
|
||||
if (otherAttack._owner == this._owner && otherAttack.target == this.target) {
|
||||
otherAttack.troops += this.troops
|
||||
otherAttack.calculateToConquer()
|
||||
this.active = false
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +83,15 @@ export class AttackExecution implements Execution {
|
||||
if (this.toConquer.size() < this.numTilesWithEnemy / 2) {
|
||||
this.calculateToConquer()
|
||||
}
|
||||
if (this.toConquer.size() == 0 || badTiles > 100) {
|
||||
if (badTiles > 1000) {
|
||||
console.log('bad tiles')
|
||||
this.borderTiles.clear()
|
||||
this.calculateToConquer()
|
||||
badTiles = 0
|
||||
continue
|
||||
}
|
||||
if (this.toConquer.size() == 0) {
|
||||
badTiles = 0
|
||||
this.active = false
|
||||
this._owner.addTroops(this.troops)
|
||||
return
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {PlayerConfig} from "../configuration/Config";
|
||||
import {Cell, Execution, MutableGame, MutablePlayer, Player, PlayerID, PlayerInfo, TerraNullius} from "../Game"
|
||||
import {Cell, Execution, MutableGame, MutablePlayer, Player, PlayerID, PlayerInfo, TerrainTypes, TerraNullius} from "../Game"
|
||||
import {PseudoRandom} from "../PseudoRandom"
|
||||
import {AttackExecution} from "./AttackExecution";
|
||||
|
||||
@@ -33,7 +33,7 @@ export class BotExecution implements Execution {
|
||||
if (this.neighborsTerra) {
|
||||
for (const b of this.bot.borderTiles()) {
|
||||
for (const n of b.neighbors()) {
|
||||
if (n.owner() == this.gs.terraNullius()) {
|
||||
if (n.owner() == this.gs.terraNullius() && n.terrain() == TerrainTypes.Land) {
|
||||
this.sendAttack(this.gs.terraNullius())
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user