mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-03 11:45:34 +00:00
chore(stock): added supporting internal cargo for generating 627Z & 412Z mixed containers
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useStore } from '../store';
|
||||
import { additionalCargoTypes } from '../utils/vehicleUtils';
|
||||
|
||||
export function getCurrentStockFileName() {
|
||||
const store = useStore();
|
||||
@@ -23,3 +24,27 @@ export function getCurrentStockFileName() {
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
export function getStockStringOutput() {
|
||||
const store = useStore();
|
||||
|
||||
const stockEntries = store.stockString.split(';');
|
||||
|
||||
const parsedEntries = store.stockList.map((stockVehicle, i) => {
|
||||
if (stockVehicle.cargo && /412Z|627Z/.test(stockVehicle.vehicleRef.constructionType)) {
|
||||
const additionalCargo = additionalCargoTypes.find(
|
||||
(c) => c.groupType == stockVehicle.vehicleRef.constructionType && c.id == stockVehicle.cargo!.id
|
||||
);
|
||||
|
||||
if (additionalCargo) {
|
||||
let cargoString = additionalCargo.cargoStringVariations[Math.floor(Math.random() * additionalCargo.cargoStringVariations.length)];
|
||||
|
||||
return stockEntries[i].replace(stockVehicle.cargo.id, cargoString);
|
||||
}
|
||||
}
|
||||
|
||||
return stockEntries[i];
|
||||
});
|
||||
|
||||
return parsedEntries.join(';');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user