Poprawki optymalizacyjne; dodanie ostrzeżeń

This commit is contained in:
2021-11-13 15:27:26 +01:00
parent 8e9da4c498
commit 28c9813133
8 changed files with 414 additions and 253 deletions
+24
View File
@@ -0,0 +1,24 @@
import { EVehicleUseType } from "@/enums/EVehicleUseType";
import { ICarWagon, ILocomotive, IStock } from "@/types";
export const verifyTrainSpec = (stockList: IStock[], vehicleMass: number, vehicleUseType: string) => {
const hasHeadLoco = stockList.length > 0
&& (stockList[0].useType == EVehicleUseType.LOCO_ELECTRICAL
|| stockList[0].useType == EVehicleUseType.LOCO_DIESEL);
if (!hasHeadLoco) return;
const headLoco = stockList[0];
const carList = stockList.filter(stock => !stock.isLoco);
console.log(carList, vehicleUseType);
const isTrainPassenger = carList.length != 0
? carList.every(stock => stock.useType == EVehicleUseType.CAR_PASSENGER)
&& vehicleUseType == EVehicleUseType.CAR_PASSENGER
: false;
console.log("Skład pasażerski: " + isTrainPassenger);
console.log("Skład towarowy: " + !isTrainPassenger);
}