mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-04 12:08:12 +00:00
feature: generator nr pociągi
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import speedLimitTable from '../constants/speedLimits.json';
|
||||
export type LocoType = keyof typeof speedLimitTable;
|
||||
|
||||
export const calculateSpeedLimit = (locoType: LocoType, stockMass: number, isTrainPassenger: boolean) => {
|
||||
const speedTable = speedLimitTable[locoType][isTrainPassenger ? 'passenger' : 'cargo'];
|
||||
|
||||
if (!speedTable) return undefined;
|
||||
|
||||
let speedLimit = 0;
|
||||
for (let mass in speedTable) if (stockMass > Number(mass)) speedLimit = (speedTable as any)[mass];
|
||||
|
||||
return speedLimit;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user