diff --git a/src/core/configuration/Config.ts b/src/core/configuration/Config.ts index f0ad2ec2f..5b6599563 100644 --- a/src/core/configuration/Config.ts +++ b/src/core/configuration/Config.ts @@ -130,7 +130,7 @@ export interface Config { unitInfo(type: UnitType): UnitInfo; tradeShipGold(dist: number, numPorts: number): Gold; tradeShipSpawnRate(numTradeShips: number, numPlayerPorts: number): number; - trainGold(isFriendly: boolean): Gold; + trainGold(rel: "self" | "friendly" | "other"): Gold; trainSpawnRate(numPlayerFactories: number): number; trainStationMinRange(): number; trainStationMaxRange(): number; diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index 099e3b441..6da4a9753 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -333,8 +333,15 @@ export class DefaultConfig implements Config { // expected number of trains = numPlayerFactories / trainSpawnRate(numPlayerFactories) return (numPlayerFactories + 5) * 50; } - trainGold(isFriendly: boolean): Gold { - return isFriendly ? 50_000n : 10_000n; + trainGold(rel: "self" | "friendly" | "other"): Gold { + switch (rel) { + case "friendly": + return 50_000n; + case "other": + return 10_000n; + case "self": + return 5_000n; + } } trainStationMinRange(): number { @@ -363,7 +370,7 @@ export class DefaultConfig implements Config { this.tradeShipPortMultiplier(numPlayerPorts), ); - return Math.floor(10 / combined); + return Math.floor(20 / combined); } private tradeShipBaseSpawn(numTradeShips: number): number { diff --git a/src/core/game/TrainStation.ts b/src/core/game/TrainStation.ts index d9c021f85..b804755c2 100644 --- a/src/core/game/TrainStation.ts +++ b/src/core/game/TrainStation.ts @@ -25,8 +25,7 @@ class CityStopHandler implements TrainStopHandler { ): void { const stationOwner = station.unit.owner(); const trainOwner = trainExecution.owner(); - const isFriendly = stationOwner.isFriendly(trainOwner); - const goldBonus = mg.config().trainGold(isFriendly); + const goldBonus = mg.config().trainGold(rel(trainOwner, stationOwner)); // Share revenue with the station owner if it's not the current player if (trainOwner !== stationOwner) { stationOwner.addGold(goldBonus, station.tile()); @@ -44,13 +43,13 @@ class PortStopHandler implements TrainStopHandler { ): void { const stationOwner = station.unit.owner(); const trainOwner = trainExecution.owner(); - const isFriendly = stationOwner.isFriendly(trainOwner); - const goldBonus = mg.config().trainGold(isFriendly); + const goldBonus = mg.config().trainGold(rel(trainOwner, stationOwner)); - if (isFriendly) { + trainOwner.addGold(goldBonus, station.tile()); + // Share revenue with the station owner if it's not the current player + if (trainOwner !== stationOwner) { stationOwner.addGold(goldBonus, station.tile()); } - trainOwner.addGold(goldBonus, station.tile()); } } @@ -233,3 +232,13 @@ export class Cluster { this.stations.clear(); } } + +function rel(player: Player, other: Player): "self" | "friendly" | "other" { + if (player === other) { + return "self"; + } + if (player.isFriendly(other)) { + return "friendly"; + } + return "other"; +}