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:
@@ -97,7 +97,7 @@
|
|||||||
(!)
|
(!)
|
||||||
<i18n-t keypath="stocklist.warning-too-heavy">
|
<i18n-t keypath="stocklist.warning-too-heavy">
|
||||||
<template #href>
|
<template #href>
|
||||||
<a target="_blank" href="https://docs.google.com/spreadsheets/d/1bFXUsHsAu4youmNz-46Q1HslZaaoklvfoBDS553TnNk/edit">
|
<a target="_blank" href="https://docs.google.com/spreadsheets/d/1KVa5vn2d8XGkXQFwbavVudwKqUQxbLOucHWs2VYqAUE">
|
||||||
{{ $t('stocklist.acceptable-mass-docs') }}
|
{{ $t('stocklist.acceptable-mass-docs') }}
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"EU06": [650, 2000],
|
||||||
|
"EU07": [650, 2000],
|
||||||
|
"EU07E": [650, 2000],
|
||||||
|
"EP07": [650, 650],
|
||||||
|
"EP08": [650, 650],
|
||||||
|
"EP09": [800, 800],
|
||||||
|
"ET41": [700, 4000],
|
||||||
|
"SM42": [2400, 2400]
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
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 (const mass in speedTable)
|
|
||||||
if (stockMass > Number(mass)) speedLimit = (speedTable as any)[mass];
|
|
||||||
|
|
||||||
return speedLimit;
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import speedLimits from '../constants/speedLimits.json';
|
||||||
|
import massLimits from '../constants/massLimits.json';
|
||||||
|
|
||||||
|
export type SpeedLimitLocoType = keyof typeof speedLimits;
|
||||||
|
export type MassLimitLocoType = keyof typeof massLimits;
|
||||||
|
|
||||||
|
export function calculateSpeedLimit(locoType: SpeedLimitLocoType, stockMass: number, isTrainPassenger: boolean) {
|
||||||
|
const speedTable = speedLimits[locoType][isTrainPassenger ? 'passenger' : 'cargo'];
|
||||||
|
|
||||||
|
if (!speedTable) return undefined;
|
||||||
|
|
||||||
|
let speedLimit = 0;
|
||||||
|
for (const mass in speedTable) if (stockMass > Number(mass)) speedLimit = (speedTable as any)[mass];
|
||||||
|
|
||||||
|
return speedLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function calculateMassLimit(locoType: MassLimitLocoType, isTrainPassenger: boolean) {
|
||||||
|
return massLimits[locoType][isTrainPassenger ? 0 : 1] || 0;
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { EVehicleUseType } from '../enums/EVehicleUseType';
|
import { EVehicleUseType } from '../enums/EVehicleUseType';
|
||||||
import { ICarWagon, ILocomotive, IStore, TCarWagonGroup, TLocoGroup } from '../types';
|
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 {
|
export function isLocomotive(vehicle: ILocomotive | ICarWagon): vehicle is ILocomotive {
|
||||||
return (vehicle as ILocomotive).power !== undefined;
|
return (vehicle as ILocomotive).power !== undefined;
|
||||||
@@ -106,33 +106,19 @@ export function maxStockSpeed(state: IStore) {
|
|||||||
|
|
||||||
const stockMass = totalMass(state);
|
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;
|
return speedLimitByMass ? Math.min(stockSpeedLimit, speedLimitByMass) : stockSpeedLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function acceptableMass(state: IStore) {
|
export function acceptableMass(state: IStore) {
|
||||||
if (state.stockList.length == 0 || !state.stockList[0].isLoco) return 0;
|
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.
|
return locoMassLimit;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isTrainPassenger(state: IStore) {
|
export function isTrainPassenger(state: IStore) {
|
||||||
|
|||||||
Reference in New Issue
Block a user