mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 10:18:11 +00:00
make hard & impossible more difficult
This commit is contained in:
@@ -288,6 +288,19 @@ export class DefaultConfig implements Config {
|
||||
if (player.type() == PlayerType.Bot) {
|
||||
toAdd *= .7
|
||||
}
|
||||
let difficultyMultiplier = 1
|
||||
switch (this._gameConfig.difficulty) {
|
||||
case Difficulty.Easy:
|
||||
case Difficulty.Medium:
|
||||
difficultyMultiplier = 1
|
||||
case Difficulty.Hard:
|
||||
difficultyMultiplier = 1.2
|
||||
case Difficulty.Impossible:
|
||||
difficultyMultiplier = 1.5
|
||||
}
|
||||
if (player.type() == PlayerType.FakeHuman) {
|
||||
toAdd *= difficultyMultiplier
|
||||
}
|
||||
|
||||
return Math.min(player.population() + toAdd, max) - player.population()
|
||||
}
|
||||
|
||||
@@ -23,16 +23,13 @@ export class DevConfig extends DefaultConfig {
|
||||
// return 100
|
||||
}
|
||||
|
||||
unitInfo(type: UnitType): UnitInfo {
|
||||
const info = super.unitInfo(type)
|
||||
const oldCost = info.cost
|
||||
info.cost = (p: Player) => oldCost(p) / 10000
|
||||
return info
|
||||
}
|
||||
// unitInfo(type: UnitType): UnitInfo {
|
||||
// const info = super.unitInfo(type)
|
||||
// const oldCost = info.cost
|
||||
// info.cost = (p: Player) => oldCost(p) / 10000
|
||||
// return info
|
||||
// }
|
||||
|
||||
percentageTilesOwnedToWin(): number {
|
||||
return 95
|
||||
}
|
||||
// tradeShipSpawnRate(): number {
|
||||
// return 10
|
||||
// }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AllianceRequest, Cell, Execution, MutableGame, MutablePlayer, Player, PlayerInfo, PlayerType, Relation, TerrainType, TerraNullius, Tile, UnitType } from "../game/Game"
|
||||
import { AllianceRequest, Cell, Difficulty, Execution, MutableGame, MutablePlayer, Player, PlayerInfo, PlayerType, Relation, TerrainType, TerraNullius, Tile, UnitType } from "../game/Game"
|
||||
import { PseudoRandom } from "../PseudoRandom"
|
||||
import { and, bfs, calculateBoundingBox, dist, euclDist, manhattanDist, simpleHash } from "../Util";
|
||||
import { AttackExecution } from "./AttackExecution";
|
||||
@@ -118,26 +118,42 @@ export class FakeHumanExecution implements Execution {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.random.chance(2)) {
|
||||
const weakest = enemies[0]
|
||||
if (!this.player.isAlliedWith(weakest)) {
|
||||
if (weakest.info().playerType != PlayerType.Human || weakest.isTraitor()) {
|
||||
this.sendAttack(weakest)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const toAttack = this.random.randElement(enemies)
|
||||
if (!this.player.isAlliedWith(toAttack)) {
|
||||
if (toAttack.info().playerType != PlayerType.Human || toAttack.isTraitor()) {
|
||||
this.sendAttack(toAttack)
|
||||
} else if (this.random.chance(4)) {
|
||||
// Less likely to attack players who are not traitors.
|
||||
this.sendAttack(toAttack)
|
||||
}
|
||||
}
|
||||
// 50-50 attack weakest player vs random player
|
||||
const toAttack = this.random.chance(2) ? enemies[0] : this.random.randElement(enemies)
|
||||
if (this.shouldAttack(toAttack)) {
|
||||
this.sendAttack(toAttack)
|
||||
}
|
||||
}
|
||||
|
||||
private shouldAttack(other: Player): boolean {
|
||||
if (this.player.isAlliedWith(other)) {
|
||||
if (this.shouldDiscourageAttack(other)) {
|
||||
return this.random.chance(100)
|
||||
}
|
||||
return this.random.chance(20)
|
||||
} else {
|
||||
if (this.shouldDiscourageAttack(other)) {
|
||||
return this.random.chance(4)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
shouldDiscourageAttack(other: Player) {
|
||||
if (other.isTraitor) {
|
||||
return false
|
||||
}
|
||||
const difficulty = this.mg.config().gameConfig().difficulty
|
||||
if (difficulty == Difficulty.Hard || difficulty == Difficulty.Impossible) {
|
||||
return false
|
||||
}
|
||||
if (other.type() != PlayerType.Human) {
|
||||
return false
|
||||
}
|
||||
// Only discourage attacks on Humans who are not traitors on easy or medium difficulty.
|
||||
return true
|
||||
}
|
||||
|
||||
handleEnemies() {
|
||||
if (this.mg.ticks() - this.lastEnemyUpdateTick > 100) {
|
||||
this.enemy = null
|
||||
|
||||
Reference in New Issue
Block a user