mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-28 02:54:39 +00:00
update train meta
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<TrainStation> {
|
||||
const tradingStations = new Set<TrainStation>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user