feature: ładowanie składów z pliku

This commit is contained in:
2023-02-09 19:18:15 +01:00
parent 3aa0e7ee4f
commit ea07f054b2
4 changed files with 68 additions and 20 deletions
+21
View File
@@ -70,6 +70,27 @@ export default defineComponent({
this.store.stockList.push(stockObj);
},
loadStockFromString(stockString: string) {
const stockArray = stockString.split(';');
this.store.stockList.length = 0;
this.store.chosenVehicle = null;
this.store.chosenCar = null;
this.store.chosenCargo = null;
this.store.chosenLoco = null;
this.store.chosenStockListIndex = -1;
this.store.swapVehicles = false;
stockArray.forEach((type, i) => {
let vehicle: Vehicle | null = null;
if (i == 0) vehicle = this.store.locoDataList.find((loco) => loco.type == stockArray[0]) || null;
else vehicle = this.store.carDataList.find((car) => car.type == type) || null;
this.addVehicle(vehicle);
});
},
},
});