mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-04 03:58:11 +00:00
feature: generator nr pociągi
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user