mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-03 19:48:11 +00:00
chore(stock): added supporting internal cargo for generating 627Z & 412Z mixed containers
This commit is contained in:
+17
-10
@@ -1,7 +1,7 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { useStore } from '../store';
|
||||
import { ICarWagon, ILocomotive, IStock, ICargo, IVehicle } from '../types/common.types';
|
||||
import { isTractionUnit } from '../utils/vehicleUtils';
|
||||
import { additionalCargoTypes, isTractionUnit } from '../utils/vehicleUtils';
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
@@ -28,11 +28,7 @@ export default defineComponent({
|
||||
|
||||
const stock = this.getStockObject(vehicle, cargo);
|
||||
|
||||
if (
|
||||
isTractionUnit(stock.vehicleRef) &&
|
||||
this.store.stockList.length > 0 &&
|
||||
!isTractionUnit(this.store.stockList[0].vehicleRef)
|
||||
)
|
||||
if (isTractionUnit(stock.vehicleRef) && this.store.stockList.length > 0 && !isTractionUnit(this.store.stockList[0].vehicleRef))
|
||||
this.store.stockList.unshift(stock);
|
||||
else this.store.stockList.push(stock);
|
||||
},
|
||||
@@ -40,8 +36,7 @@ export default defineComponent({
|
||||
addLocomotive(loco: ILocomotive) {
|
||||
const stockObj = this.getStockObject(loco);
|
||||
|
||||
if (this.store.stockList.length > 0 && !isTractionUnit(this.store.stockList[0].vehicleRef))
|
||||
this.store.stockList.unshift(stockObj);
|
||||
if (this.store.stockList.length > 0 && !isTractionUnit(this.store.stockList[0].vehicleRef)) this.store.stockList.unshift(stockObj);
|
||||
else this.store.stockList.push(stockObj);
|
||||
},
|
||||
|
||||
@@ -80,10 +75,22 @@ export default defineComponent({
|
||||
this.store.isDoubleManned = spawnProps.includes('d');
|
||||
}
|
||||
} else {
|
||||
const [carType, cargo] = type.split(':');
|
||||
const [carType, ...cargo] = type.split(':');
|
||||
vehicle = this.store.carDataList.find((car) => car.type == carType) || null;
|
||||
|
||||
if (cargo) vehicleCargo = vehicle?.cargoTypes.find((c) => c.id == cargo) || null;
|
||||
if (vehicle && cargo.length > 0) {
|
||||
if (/412Z|627Z/.test(vehicle.constructionType)) {
|
||||
const additionalCargo = additionalCargoTypes.find(
|
||||
(c) => c.groupType == vehicle!.constructionType && c.cargoStringVariations.includes(cargo.join(':'))
|
||||
);
|
||||
|
||||
if (additionalCargo) {
|
||||
cargo[0] = additionalCargo.id;
|
||||
}
|
||||
}
|
||||
|
||||
vehicleCargo = vehicle?.cargoTypes.find((c) => c.id == cargo[0]) || null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vehicle && type) {
|
||||
|
||||
Reference in New Issue
Block a user