feature: generator nr pociągi

This commit is contained in:
2023-02-08 00:30:18 +01:00
parent 9893353daf
commit bf00533458
15 changed files with 487 additions and 300 deletions
+3 -31
View File
@@ -41,18 +41,18 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { Vehicle, IStock, IReadyStockList } from '../../types';
import { Vehicle, IReadyStockList } from '../../types';
import { useStore } from '../../store';
import { isLocomotive } from '../../utils/vehicleUtils';
import imageMixin from '../../mixins/imageMixin';
import stockMixin from '../../mixins/stockMixin';
interface ResponseJSONData {
[key: string]: string;
}
export default defineComponent({
mixins: [imageMixin],
mixins: [imageMixin, stockMixin],
setup() {
return {
@@ -109,34 +109,6 @@ export default defineComponent({
this.store.isRealStockListCardOpen = false;
},
addVehicle(vehicle: Vehicle | null) {
if (!vehicle) return;
const stockObj: IStock = {
id: `${Date.now() + this.store.stockList.length}`,
type: vehicle.type,
length: vehicle.length,
mass: vehicle.mass,
maxSpeed: vehicle.maxSpeed,
isLoco: isLocomotive(vehicle),
cargo: undefined,
count: 1,
imgSrc: vehicle.imageSrc,
useType: isLocomotive(vehicle) ? vehicle.power : vehicle.useType,
supportersOnly: vehicle.supportersOnly,
};
const previousStock =
this.store.stockList.length > 0 ? this.store.stockList[this.store.stockList.length - 1] : null;
if (previousStock && previousStock.type == vehicle.type) {
this.store.stockList[this.store.stockList.length - 1].count++;
return;
}
this.store.stockList.push(stockObj);
},
},
async mounted() {