mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-03 05:18:10 +00:00
eslint & prettier update; api fetching from static server
This commit is contained in:
@@ -4,7 +4,12 @@ import massLimits from '../constants/massLimits.json';
|
||||
export type SpeedLimitLocoType = keyof typeof speedLimits;
|
||||
export type MassLimitLocoType = keyof typeof massLimits;
|
||||
|
||||
export function calculateSpeedLimit(locoType: SpeedLimitLocoType, stockTotalWeight: number, stockCount: number, isTrainPassenger: boolean) {
|
||||
export function calculateSpeedLimit(
|
||||
locoType: SpeedLimitLocoType,
|
||||
stockTotalWeight: number,
|
||||
stockCount: number,
|
||||
isTrainPassenger: boolean
|
||||
) {
|
||||
if (speedLimits[locoType] === undefined) return 0;
|
||||
|
||||
if (stockCount == 1) return speedLimits[locoType]['none'];
|
||||
@@ -15,7 +20,8 @@ export function calculateSpeedLimit(locoType: SpeedLimitLocoType, stockTotalWeig
|
||||
if (!speedTable) return undefined;
|
||||
|
||||
let speedLimit = 0;
|
||||
for (const mass in speedTable) if (stockTotalWeight > Number(mass)) speedLimit = (speedTable as any)[mass];
|
||||
for (const mass in speedTable)
|
||||
if (stockTotalWeight > Number(mass)) speedLimit = (speedTable as any)[mass];
|
||||
|
||||
return speedLimit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user