diff --git a/TODO.txt b/TODO.txt index e35e227bb..dda24999a 100644 --- a/TODO.txt +++ b/TODO.txt @@ -55,7 +55,8 @@ * 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 -* give boats limit for how far they can go +* REFACTOR: remove player config DONE 8/29/2024 +* give boats limit for how far they can go DONE 8/29/2024 * PERF: precompute spawns * PERF: load terrain map async * PERF: enable CDN @@ -66,5 +67,4 @@ * use better favicon * REFACTOR: give terranullius an ID, game.player() returns terranullius * REFACTOR: ocean is considered TerraNullius ? -* REFACTOR: remove player config? * Make fake humans diff --git a/src/client/ClientGame.ts b/src/client/ClientGame.ts index 44c04b742..50091443b 100644 --- a/src/client/ClientGame.ts +++ b/src/client/ClientGame.ts @@ -39,7 +39,6 @@ export class ClientGame { private currTurn = 0 - private spawned = false private intervalID: NodeJS.Timeout @@ -191,7 +190,6 @@ export class ClientGame { const tile = this.gs.tile(cell) if (tile.isLand() && !tile.hasOwner() && this.gs.inSpawnPhase()) { this.sendSpawnIntent(cell) - this.spawned = true return } if (this.gs.inSpawnPhase()) { diff --git a/src/core/configuration/Config.ts b/src/core/configuration/Config.ts index 8bab76f23..f3579bc78 100644 --- a/src/core/configuration/Config.ts +++ b/src/core/configuration/Config.ts @@ -32,6 +32,7 @@ export interface Config { } attackAmount(attacker: Player, defender: Player | TerraNullius): number boatAttackAmount(attacker: Player, defender: Player | TerraNullius): number + boatMaxDistance(): number } export interface Theme { diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index bb94c361a..585258e12 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -2,11 +2,13 @@ import {Player, PlayerInfo, TerraNullius, Tile} from "../Game"; import {within} from "../Util"; import {Config, Theme} from "./Config"; import {pastelTheme} from "./PastelTheme"; -import {vintageTheme} from "./VintageTheme"; export class DefaultConfig implements Config { + boatMaxDistance(): number { + return 500 + } numSpawnPhaseTurns(): number { return 100 } diff --git a/src/core/execution/BoatAttackExecution.ts b/src/core/execution/BoatAttackExecution.ts index 9f748522a..37b10b9de 100644 --- a/src/core/execution/BoatAttackExecution.ts +++ b/src/core/execution/BoatAttackExecution.ts @@ -2,6 +2,7 @@ import {PriorityQueue} from "@datastructures-js/priority-queue"; import {Boat, Cell, Execution, MutableBoat, MutableGame, MutablePlayer, Player, PlayerID, TerraNullius, Tile, TileEvent} from "../Game"; import {manhattanDist} from "../Util"; import {AttackExecution} from "./AttackExecution"; +import {Config} from "../configuration/Config"; export class BoatAttackExecution implements Execution { @@ -66,8 +67,14 @@ export class BoatAttackExecution implements Execution { this.active = false return } + if (manhattanDist(this.src.cell(), this.dst.cell()) > mg.config().boatMaxDistance()) { + console.log(`boat attack distance too large, dist ${manhattanDist(this.src.cell(), this.dst.cell())} max: ${mg.config().boatMaxDistance()}`) + this.active = false + return + } + this.aStarPre = new AStar(this.src, this.dst) - this.aStarPre.compute(30) + this.aStarPre.compute(5) this.path = this.aStarPre.reconstructPath() if (this.path != null) { console.log(`got path ${this.path.map(t => t.cell().toString())}`)