diff --git a/src/core/configuration/Config.ts b/src/core/configuration/Config.ts index b28f85ba5..41568cddb 100644 --- a/src/core/configuration/Config.ts +++ b/src/core/configuration/Config.ts @@ -132,7 +132,7 @@ export interface Config { tradeShipGold(dist: number, numPorts: number): Gold; tradeShipSpawnRate(numTradeShips: number, numPlayerPorts: number): number; trainGold(isFriendly: boolean): Gold; - trainSpawnRate(numberOfStations: number): number; + trainSpawnRate(numPlayerFactories: number): number; trainStationMinRange(): number; trainStationMaxRange(): number; railroadMaxSize(): number; diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index d8fc9b430..985397d3d 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -328,11 +328,11 @@ export class DefaultConfig implements Config { infiniteTroops(): boolean { return this._gameConfig.infiniteTroops; } - trainSpawnRate(numberOfStations: number): number { - return Math.min(3000, Math.round(80 * Math.pow(numberOfStations, 0.5))); + trainSpawnRate(numPlayerFactories: number): number { + return 200 * numPlayerFactories ** 0.5; } trainGold(isFriendly: boolean): Gold { - return isFriendly ? 50_000n : 10_000n; + return isFriendly ? 250_000n : 50_000n; } trainStationMinRange(): number { diff --git a/src/core/execution/TrainStationExecution.ts b/src/core/execution/TrainStationExecution.ts index ee0174bcc..a257a909b 100644 --- a/src/core/execution/TrainStationExecution.ts +++ b/src/core/execution/TrainStationExecution.ts @@ -1,4 +1,4 @@ -import { Execution, Game, Unit } from "../game/Game"; +import { Execution, Game, Unit, UnitType } from "../game/Game"; import { TrainStation } from "../game/TrainStation"; import { PseudoRandom } from "../PseudoRandom"; import { TrainExecution } from "./TrainExecution"; @@ -48,8 +48,10 @@ export class TrainStationExecution implements Execution { this.spawnTrain(this.station, ticks); } - private shouldSpawnTrain(clusterSize: number): boolean { - const spawnRate = this.mg.config().trainSpawnRate(clusterSize); + private shouldSpawnTrain(): boolean { + const spawnRate = this.mg + .config() + .trainSpawnRate(this.unit.owner().unitCount(UnitType.Factory)); for (let i = 0; i < this.unit!.level(); i++) { if (this.random.chance(spawnRate)) { return true; @@ -73,7 +75,7 @@ export class TrainStationExecution implements Execution { if (availableForTrade.size === 0) { return; } - if (!this.shouldSpawnTrain(availableForTrade.size)) { + if (!this.shouldSpawnTrain()) { return; } diff --git a/src/core/game/TrainStation.ts b/src/core/game/TrainStation.ts index f12125abe..819e8edaa 100644 --- a/src/core/game/TrainStation.ts +++ b/src/core/game/TrainStation.ts @@ -23,13 +23,12 @@ class CityStopHandler implements TrainStopHandler { station: TrainStation, trainExecution: TrainExecution, ): void { - const level = BigInt(station.unit.level() + 1); const stationOwner = station.unit.owner(); const trainOwner = trainExecution.owner(); const isFriendly = stationOwner.isFriendly(trainOwner); - const goldBonus = mg.config().trainGold(isFriendly) * level; + const goldBonus = mg.config().trainGold(isFriendly); // Share revenue with the station owner if it's not the current player - if (isFriendly) { + if (trainOwner !== stationOwner) { stationOwner.addGold(goldBonus, station.tile()); } trainOwner.addGold(goldBonus, station.tile()); @@ -43,7 +42,7 @@ class PortStopHandler implements TrainStopHandler { station: TrainStation, trainExecution: TrainExecution, ): void { - const level = BigInt(station.unit.level() + 1); + const level = BigInt(station.unit.level()); const stationOwner = station.unit.owner(); const trainOwner = trainExecution.owner(); const isFriendly = stationOwner.isFriendly(trainOwner); @@ -61,17 +60,7 @@ class FactoryStopHandler implements TrainStopHandler { mg: Game, station: TrainStation, trainExecution: TrainExecution, - ): void { - const stationOwner = station.unit.owner(); - const trainOwner = trainExecution.owner(); - const isFriendly = stationOwner.isFriendly(trainOwner); - const goldBonus = mg.config().trainGold(isFriendly); - // Share revenue with the station owner if it's not the current player - if (isFriendly) { - stationOwner.addGold(goldBonus, station.tile()); - } - trainOwner.addGold(goldBonus, station.tile()); - } + ): void {} } export function createTrainStopHandlers( @@ -226,7 +215,11 @@ export class Cluster { availableForTrade(player: Player): Set { const tradingStations = new Set(); for (const station of this.stations) { - if (station.tradeAvailable(player)) { + if ( + (station.unit.type() === UnitType.City || + station.unit.type() === UnitType.Port) && + station.tradeAvailable(player) + ) { tradingStations.add(station); } }