mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 11:50:42 +00:00
remove playerconfig
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
* make bot spawn better DONE 8/28/2024
|
||||
* make UX for attacking TerraNullius by boat better DONE 8/29/2024
|
||||
* make bot territory less funky (more likely attack neighbors with larger border) DONE 8/29/2024
|
||||
* PERF: use hierarchical a* search for boats
|
||||
* give boats limit for how far they can go
|
||||
* PERF: precompute spawns
|
||||
* PERF: load terrain map async
|
||||
* PERF: enable CDN
|
||||
|
||||
@@ -212,10 +212,10 @@ export class ClientGame {
|
||||
// Attack Player
|
||||
if (tile.isLand()) {
|
||||
if (this.myPlayer.sharesBorderWith(tile.owner())) {
|
||||
this.sendAttackIntent(targetID, cell, this.gs.config().player().attackAmount(this.myPlayer, owner))
|
||||
this.sendAttackIntent(targetID, cell, this.gs.config().attackAmount(this.myPlayer, owner))
|
||||
} else if (owner.isPlayer()) {
|
||||
console.log('going to send boat')
|
||||
this.sendBoatAttackIntent(targetID, cell, this.gs.config().player().boatAttackAmount(this.myPlayer, owner))
|
||||
this.sendBoatAttackIntent(targetID, cell, this.gs.config().boatAttackAmount(this.myPlayer, owner))
|
||||
}
|
||||
}
|
||||
return
|
||||
@@ -229,7 +229,7 @@ export class ClientGame {
|
||||
const neighbors = Array.from(bfs(tile, and((r, t) => t.isLand(), dist(100))));
|
||||
for (const n of neighbors) {
|
||||
if (this.myPlayer.borderTiles().has(n)) {
|
||||
this.sendAttackIntent(targetID, cell, this.gs.config().player().attackAmount(this.myPlayer, owner))
|
||||
this.sendAttackIntent(targetID, cell, this.gs.config().attackAmount(this.myPlayer, owner))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -239,9 +239,9 @@ export class ClientGame {
|
||||
.filter(t => !t.hasOwner())
|
||||
.sort((a, b) => manhattanDist(tile.cell(), a.cell()) - manhattanDist(tile.cell(), b.cell()))
|
||||
if (tn.length > 0) {
|
||||
this.sendBoatAttackIntent(targetID, tn[0].cell(), this.gs.config().player().boatAttackAmount(this.myPlayer, owner))
|
||||
this.sendBoatAttackIntent(targetID, tn[0].cell(), this.gs.config().boatAttackAmount(this.myPlayer, owner))
|
||||
} else {
|
||||
this.sendAttackIntent(targetID, cell, this.gs.config().player().attackAmount(this.myPlayer, owner))
|
||||
this.sendAttackIntent(targetID, cell, this.gs.config().attackAmount(this.myPlayer, owner))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ export class ClientGame {
|
||||
.filter(t => !t.hasOwner())
|
||||
.sort((a, b) => manhattanDist(tile.cell(), a.cell()) - manhattanDist(tile.cell(), b.cell()))
|
||||
if (tn.length > 0) {
|
||||
this.sendBoatAttackIntent(targetID, tn[0].cell(), this.gs.config().player().boatAttackAmount(this.myPlayer, owner))
|
||||
this.sendBoatAttackIntent(targetID, tn[0].cell(), this.gs.config().boatAttackAmount(this.myPlayer, owner))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,12 @@ export function getConfig(): Config {
|
||||
|
||||
export interface Config {
|
||||
theme(): Theme;
|
||||
player(): PlayerConfig
|
||||
turnIntervalMs(): number
|
||||
gameCreationRate(): number
|
||||
lobbyLifetime(): number
|
||||
numBots(): number
|
||||
numSpawnPhaseTurns(): number
|
||||
}
|
||||
|
||||
export interface PlayerConfig {
|
||||
startTroops(playerInfo: PlayerInfo): number
|
||||
troopAdditionRate(player: Player): number
|
||||
attackTilesPerTick(attacker: Player, defender: Player | TerraNullius, numAdjacentTilesWithEnemy: number): number
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Player, PlayerInfo, TerraNullius, Tile} from "../Game";
|
||||
import {within} from "../Util";
|
||||
import {Config, PlayerConfig, Theme} from "./Config";
|
||||
import {Config, Theme} from "./Config";
|
||||
import {pastelTheme} from "./PastelTheme";
|
||||
import {vintageTheme} from "./VintageTheme";
|
||||
|
||||
@@ -13,9 +13,6 @@ export class DefaultConfig implements Config {
|
||||
numBots(): number {
|
||||
return 250
|
||||
}
|
||||
player(): PlayerConfig {
|
||||
return defaultPlayerConfig
|
||||
}
|
||||
turnIntervalMs(): number {
|
||||
return 100
|
||||
}
|
||||
@@ -26,9 +23,6 @@ export class DefaultConfig implements Config {
|
||||
return 20 * 1000
|
||||
}
|
||||
theme(): Theme {return pastelTheme;}
|
||||
}
|
||||
|
||||
export class DefaultPlayerConfig implements PlayerConfig {
|
||||
|
||||
attackLogic(attacker: Player, defender: Player | TerraNullius, tileToConquer: Tile): {attackerTroopLoss: number; defenderTroopLoss: number; tilesPerTickUsed: number} {
|
||||
if (defender.isPlayer()) {
|
||||
@@ -78,8 +72,7 @@ export class DefaultPlayerConfig implements PlayerConfig {
|
||||
|
||||
return Math.min(player.troops() + toAdd, max)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const defaultConfig = new DefaultConfig()
|
||||
export const defaultPlayerConfig = new DefaultPlayerConfig()
|
||||
|
||||
export const defaultConfig = new DefaultConfig()
|
||||
@@ -1,6 +1,5 @@
|
||||
import {PlayerInfo} from "../Game";
|
||||
import {PlayerConfig} from "./Config";
|
||||
import {DefaultConfig, DefaultPlayerConfig, defaultPlayerConfig} from "./DefaultConfig";
|
||||
import {DefaultConfig} from "./DefaultConfig";
|
||||
|
||||
export const devConfig = new class extends DefaultConfig {
|
||||
numSpawnPhaseTurns(): number {
|
||||
@@ -15,15 +14,11 @@ export const devConfig = new class extends DefaultConfig {
|
||||
turnIntervalMs(): number {
|
||||
return 100
|
||||
}
|
||||
player(): PlayerConfig {
|
||||
return devPlayerConfig
|
||||
}
|
||||
|
||||
numBots(): number {
|
||||
return 250
|
||||
}
|
||||
}
|
||||
|
||||
export const devPlayerConfig = new class extends DefaultPlayerConfig {
|
||||
startTroops(playerInfo: PlayerInfo): number {
|
||||
if (playerInfo.isBot) {
|
||||
return 5000
|
||||
|
||||
@@ -2,7 +2,6 @@ import {PriorityQueue} from "@datastructures-js/priority-queue";
|
||||
import {Cell, Execution, MutableGame, MutablePlayer, PlayerID, TerraNullius, Tile} from "../Game";
|
||||
import {PseudoRandom} from "../PseudoRandom";
|
||||
import {manhattanDist} from "../Util";
|
||||
import {Config, PlayerConfig} from "../configuration/Config";
|
||||
|
||||
export class AttackExecution implements Execution {
|
||||
private active: boolean = true;
|
||||
@@ -79,7 +78,7 @@ export class AttackExecution implements Execution {
|
||||
return
|
||||
}
|
||||
|
||||
let numTilesPerTick = this.mg.config().player().attackTilesPerTick(this._owner, this.target, this.numTilesWithEnemy)
|
||||
let numTilesPerTick = this.mg.config().attackTilesPerTick(this._owner, this.target, this.numTilesWithEnemy)
|
||||
if (this.targetCell != null) {
|
||||
numTilesPerTick /= 2
|
||||
}
|
||||
@@ -114,7 +113,7 @@ export class AttackExecution implements Execution {
|
||||
badTiles++
|
||||
continue
|
||||
}
|
||||
const {attackerTroopLoss, defenderTroopLoss, tilesPerTickUsed} = this.mg.config().player().attackLogic(this._owner, this.target, tileToConquer)
|
||||
const {attackerTroopLoss, defenderTroopLoss, tilesPerTickUsed} = this.mg.config().attackLogic(this._owner, this.target, tileToConquer)
|
||||
numTilesPerTick -= tilesPerTickUsed
|
||||
this.troops -= attackerTroopLoss
|
||||
if (this.target.isPlayer()) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {Config, PlayerConfig} from "../configuration/Config";
|
||||
import {Cell, Execution, MutableGame, MutablePlayer, Player, PlayerID, PlayerInfo, TerraNullius} from "../Game"
|
||||
import {PseudoRandom} from "../PseudoRandom"
|
||||
import {simpleHash} from "../Util";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Config, PlayerConfig} from "../configuration/Config"
|
||||
import {Config} from "../configuration/Config"
|
||||
import {Execution, MutableGame, MutablePlayer, PlayerID} from "../Game"
|
||||
|
||||
export class PlayerExecution implements Execution {
|
||||
@@ -22,7 +22,7 @@ export class PlayerExecution implements Execution {
|
||||
if (ticks < this.config.numSpawnPhaseTurns()) {
|
||||
return
|
||||
}
|
||||
this.player.setTroops(this.config.player().troopAdditionRate(this.player))
|
||||
this.player.setTroops(this.config.troopAdditionRate(this.player))
|
||||
}
|
||||
|
||||
owner(): MutablePlayer {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {Config, PlayerConfig} from "../configuration/Config"
|
||||
import {Cell, Execution, MutableGame, MutablePlayer, PlayerInfo} from "../Game"
|
||||
import {BotExecution} from "./BotExecution"
|
||||
import {PlayerExecution} from "./PlayerExecution"
|
||||
@@ -37,7 +36,7 @@ export class SpawnExecution implements Execution {
|
||||
return
|
||||
}
|
||||
|
||||
const player = this.mg.addPlayer(this.playerInfo, this.mg.config().player().startTroops(this.playerInfo))
|
||||
const player = this.mg.addPlayer(this.playerInfo, this.mg.config().startTroops(this.playerInfo))
|
||||
getSpawnCells(this.mg, this.cell).forEach(c => {
|
||||
player.conquer(this.mg.tile(c))
|
||||
})
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {Config, PlayerConfig} from "../configuration/Config"
|
||||
import {Execution, MutableGame, MutablePlayer, PlayerID} from "../Game"
|
||||
import {ClientID} from "../Schemas"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user