mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-03 05:18:10 +00:00
acceptable masses & speeds update
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { EVehicleUseType } from '../enums/EVehicleUseType';
|
||||
import { ICarWagon, ILocomotive, IStore, TCarWagonGroup, TLocoGroup } from '../types';
|
||||
import { LocoType, calculateSpeedLimit } from './speedLimitUtils';
|
||||
import { MassLimitLocoType, SpeedLimitLocoType, calculateMassLimit, calculateSpeedLimit } from './vehicleLimitsUtils';
|
||||
|
||||
export function isLocomotive(vehicle: ILocomotive | ICarWagon): vehicle is ILocomotive {
|
||||
return (vehicle as ILocomotive).power !== undefined;
|
||||
@@ -106,33 +106,19 @@ export function maxStockSpeed(state: IStore) {
|
||||
|
||||
const stockMass = totalMass(state);
|
||||
|
||||
const speedLimitByMass = calculateSpeedLimit(locoType as LocoType, stockMass, isTrainPassenger(state));
|
||||
const speedLimitByMass = calculateSpeedLimit(locoType as SpeedLimitLocoType, stockMass, isTrainPassenger(state));
|
||||
|
||||
return speedLimitByMass ? Math.min(stockSpeedLimit, speedLimitByMass) : stockSpeedLimit;
|
||||
}
|
||||
|
||||
export function acceptableMass(state: IStore) {
|
||||
if (state.stockList.length == 0 || !state.stockList[0].isLoco) return 0;
|
||||
const activeLocomotiveType = state.stockList[0].type;
|
||||
|
||||
if (/^SM/.test(activeLocomotiveType)) return 2400;
|
||||
const activeLocomotiveType = state.stockList[0].type.split('-')[0];
|
||||
|
||||
// Elektryczne EU07 / EP07 / EP08 / ET41
|
||||
const locoMassLimit = calculateMassLimit(activeLocomotiveType as MassLimitLocoType, isTrainPassenger(state));
|
||||
|
||||
// Pasażerski elektr.
|
||||
if (isTrainPassenger(state)) {
|
||||
if (/^(EU|EP)/.test(activeLocomotiveType)) return 650;
|
||||
if (/^ET/.test(activeLocomotiveType)) return 700;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Towarowy / inny elektr.
|
||||
if (/^EU/.test(activeLocomotiveType)) return 2000;
|
||||
if (/^ET/.test(activeLocomotiveType)) return 4000;
|
||||
if (/^EP/.test(activeLocomotiveType)) return 650;
|
||||
|
||||
return 0;
|
||||
return locoMassLimit;
|
||||
}
|
||||
|
||||
export function isTrainPassenger(state: IStore) {
|
||||
|
||||
Reference in New Issue
Block a user