mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-03 11:45:34 +00:00
api & naming changes
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
v-for="locoType in locomotiveTypeList"
|
||||
:key="locoType.id"
|
||||
class="btn btn--choice"
|
||||
:data-selected="locoType.id == store.chosenLocoPower"
|
||||
:data-selected="locoType.id == store.chosenLocoGroup"
|
||||
@click="selectLocoType(locoType.id)"
|
||||
>
|
||||
{{ $t(`inputs.${locoType.id}`) }}
|
||||
@@ -39,7 +39,7 @@
|
||||
v-for="carType in carTypeList"
|
||||
:key="carType.id"
|
||||
class="btn btn--choice"
|
||||
:data-selected="carType.id == store.chosenCarUseType"
|
||||
:data-selected="carType.id == store.chosenCarGroup"
|
||||
@click="selectCarWagonType(carType.id)"
|
||||
>
|
||||
{{ $t(`inputs.${carType.id}`) }}
|
||||
@@ -70,7 +70,7 @@
|
||||
id="cargo-select"
|
||||
:disabled="
|
||||
(store.chosenCar && !store.chosenCar.loadable) ||
|
||||
(store.chosenCar && store.chosenCar.useType == 'car-passenger') ||
|
||||
(store.chosenCar && store.chosenCar.group == 'wagon-passenger') ||
|
||||
!store.chosenCar
|
||||
"
|
||||
data-select="cargo"
|
||||
@@ -123,6 +123,7 @@ import imageMixin from '../../mixins/imageMixin';
|
||||
import { useStore } from '../../store';
|
||||
import stockPreviewMixin from '../../mixins/stockPreviewMixin';
|
||||
import stockMixin from '../../mixins/stockMixin';
|
||||
import { LocoGroupType, WagonGroupType } from '../../types';
|
||||
|
||||
export default defineComponent({
|
||||
mixins: [imageMixin, stockPreviewMixin, stockMixin],
|
||||
@@ -131,33 +132,33 @@ export default defineComponent({
|
||||
store: useStore(),
|
||||
locomotiveTypeList: [
|
||||
{
|
||||
id: 'loco-e',
|
||||
id: 'loco-electric',
|
||||
desc: 'ELEKTRYCZNE',
|
||||
},
|
||||
{
|
||||
id: 'loco-s',
|
||||
id: 'loco-diesel',
|
||||
desc: 'SPALINOWE',
|
||||
},
|
||||
{
|
||||
id: 'loco-ezt',
|
||||
id: 'unit-electric',
|
||||
desc: 'ELEKTR. ZESPOŁY TRAKCYJNE',
|
||||
},
|
||||
{
|
||||
id: 'loco-szt',
|
||||
id: 'unit-diesel',
|
||||
desc: 'SPAL. ZESPOŁY TRAKCYJNE',
|
||||
},
|
||||
],
|
||||
] as { id: LocoGroupType; desc: string }[],
|
||||
|
||||
carTypeList: [
|
||||
{
|
||||
id: 'car-passenger',
|
||||
id: 'wagon-passenger',
|
||||
desc: 'PASAŻERSKIE',
|
||||
},
|
||||
{
|
||||
id: 'car-cargo',
|
||||
id: 'wagon-freight',
|
||||
desc: 'TOWAROWE',
|
||||
},
|
||||
],
|
||||
] as { id: WagonGroupType; desc: string }[],
|
||||
}),
|
||||
|
||||
computed: {
|
||||
@@ -165,14 +166,14 @@ export default defineComponent({
|
||||
return this.store.locoDataList
|
||||
.slice()
|
||||
.sort((a, b) => (a.type > b.type ? 1 : -1))
|
||||
.filter((loco) => loco.power == this.store.chosenLocoPower);
|
||||
.filter((loco) => loco.group == this.store.chosenLocoGroup);
|
||||
},
|
||||
|
||||
carOptions() {
|
||||
return this.store.carDataList
|
||||
.slice()
|
||||
.sort((a, b) => (a.type > b.type ? 1 : -1))
|
||||
.filter((car) => car.useType == this.store.chosenCarUseType);
|
||||
.filter((car) => car.group == this.store.chosenCarGroup);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -209,14 +210,14 @@ export default defineComponent({
|
||||
this.store.stockList[this.store.chosenStockListIndex] = stockObject;
|
||||
},
|
||||
|
||||
selectLocoType(locoTypeId: string) {
|
||||
this.store.chosenLocoPower = locoTypeId;
|
||||
selectLocoType(locoGroupType: LocoGroupType) {
|
||||
this.store.chosenLocoGroup = locoGroupType;
|
||||
this.store.chosenVehicle = this.locoOptions[0];
|
||||
this.store.chosenLoco = this.locoOptions[0];
|
||||
},
|
||||
|
||||
selectCarWagonType(carWagonTypeId: string) {
|
||||
this.store.chosenCarUseType = carWagonTypeId;
|
||||
selectCarWagonType(wagonGroupType: WagonGroupType) {
|
||||
this.store.chosenCarGroup = wagonGroupType;
|
||||
this.store.chosenVehicle = this.carOptions[0];
|
||||
this.store.chosenCar = this.carOptions[0];
|
||||
this.store.chosenCargo = null;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<b style="color: #ccc">
|
||||
{{
|
||||
$t(
|
||||
`preview.${isLocomotive(store.chosenVehicle) ? store.chosenVehicle.power : store.chosenVehicle.useType}`
|
||||
`preview.${isLocomotive(store.chosenVehicle) ? store.chosenVehicle.group : store.chosenVehicle.group}`
|
||||
)
|
||||
}}
|
||||
</b>
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
<div v-else>
|
||||
{{
|
||||
store.chosenVehicle.useType == 'car-cargo'
|
||||
store.chosenVehicle.group == 'wagon-freight'
|
||||
? $t(`usage.${store.chosenVehicle.constructionType}`)
|
||||
: `${$t('preview.construction')} ${store.chosenVehicle.constructionType}`
|
||||
}}
|
||||
@@ -60,7 +60,7 @@
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent } from 'vue';
|
||||
import { useStore } from '../../store';
|
||||
import { isLocomotive } from '../../utils/vehicleUtils';
|
||||
import { isTractionUnit } from '../../utils/vehicleUtils';
|
||||
import { ILocomotive, IVehicle } from '../../types';
|
||||
import imageMixin from '../../mixins/imageMixin';
|
||||
|
||||
@@ -103,7 +103,7 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
isLocomotive(vehicle: IVehicle): vehicle is ILocomotive {
|
||||
return isLocomotive(vehicle);
|
||||
return isTractionUnit(vehicle);
|
||||
},
|
||||
|
||||
onImageClick(e: Event) {
|
||||
|
||||
@@ -290,7 +290,7 @@ export default defineComponent({
|
||||
this.store.chosenLoco = null;
|
||||
this.store.chosenCargo = null;
|
||||
|
||||
if (c) this.store.chosenCarUseType = c?.useType;
|
||||
if (c) this.store.chosenCarGroup = c?.group;
|
||||
},
|
||||
|
||||
toggleCargoChosen(cargoType: string, vehicles: string[]) {
|
||||
|
||||
@@ -474,6 +474,7 @@ export default defineComponent({
|
||||
|
||||
.warning {
|
||||
padding: 0.25em;
|
||||
margin: 0.25em 0;
|
||||
background: $accentColor;
|
||||
color: black;
|
||||
|
||||
|
||||
@@ -67,9 +67,9 @@
|
||||
</td>
|
||||
|
||||
<td v-if="isLocomotive(vehicle)">
|
||||
{{ $t(`wiki.${vehicle.power}`) }}
|
||||
{{ $t(`wiki.${vehicle.group}`) }}
|
||||
</td>
|
||||
<td v-else>{{ $t(`wiki.${vehicle.useType}`) }}</td>
|
||||
<td v-else>{{ $t(`wiki.${vehicle.group}`) }}</td>
|
||||
|
||||
<td>{{ vehicle.constructionType }}</td>
|
||||
<td>{{ vehicle.length }}m</td>
|
||||
@@ -97,7 +97,7 @@ import { defineComponent } from 'vue';
|
||||
import { useStore } from '../../store';
|
||||
import stockPreviewMixin from '../../mixins/stockPreviewMixin';
|
||||
import { IVehicle } from '../../types';
|
||||
import { isLocomotive } from '../../utils/vehicleUtils';
|
||||
import { isTractionUnit } from '../../utils/vehicleUtils';
|
||||
import stockMixin from '../../mixins/stockMixin';
|
||||
import imageMixin from '../../mixins/imageMixin';
|
||||
|
||||
@@ -165,7 +165,7 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
methods: {
|
||||
isLocomotive,
|
||||
isLocomotive: isTractionUnit,
|
||||
|
||||
toggleFilter(name: typeof this.currentFilterMode) {
|
||||
this.currentFilterMode = this.currentFilterMode == name ? 'all' : name;
|
||||
@@ -198,14 +198,16 @@ export default defineComponent({
|
||||
|
||||
case 'cargoCount':
|
||||
return (
|
||||
(!isLocomotive(row1.vehicle) ? Math.sign(row1.vehicle.cargoTypes.length || -1) : -1) -
|
||||
(!isLocomotive(row2.vehicle) ? (row2.vehicle.cargoTypes.length || -1) * direction : -1)
|
||||
(!isTractionUnit(row1.vehicle) ? Math.sign(row1.vehicle.cargoTypes.length || -1) : -1) -
|
||||
(!isTractionUnit(row2.vehicle)
|
||||
? (row2.vehicle.cargoTypes.length || -1) * direction
|
||||
: -1)
|
||||
);
|
||||
|
||||
case 'coldStart':
|
||||
return (
|
||||
((isLocomotive(row1.vehicle) && row1.vehicle.coldStart ? 1 : -1) -
|
||||
(isLocomotive(row2.vehicle) && row2.vehicle.coldStart ? 1 : -1)) *
|
||||
((isTractionUnit(row1.vehicle) && row1.vehicle.coldStart ? 1 : -1) -
|
||||
(isTractionUnit(row2.vehicle) && row2.vehicle.coldStart ? 1 : -1)) *
|
||||
direction
|
||||
);
|
||||
|
||||
@@ -227,8 +229,8 @@ export default defineComponent({
|
||||
show:
|
||||
new RegExp(`${this.searchedVehicleTypeName.trim()}`, 'i').test(vehicle.type) &&
|
||||
(this.currentFilterMode == 'all' ||
|
||||
(this.currentFilterMode == 'tractions' && isLocomotive(vehicle)) ||
|
||||
(this.currentFilterMode == 'carriages' && !isLocomotive(vehicle))),
|
||||
(this.currentFilterMode == 'tractions' && isTractionUnit(vehicle)) ||
|
||||
(this.currentFilterMode == 'carriages' && !isTractionUnit(vehicle))),
|
||||
}))
|
||||
.sort((a, b) => this.sortTableRows(a, b));
|
||||
},
|
||||
|
||||
@@ -43,7 +43,7 @@ const onListItemClick = (index: number) => {
|
||||
};
|
||||
|
||||
const stockImageError = (e: Event, stock: IStock) => {
|
||||
(e.target as HTMLImageElement).src = `images/${stock.useType}-unknown.png`;
|
||||
(e.target as HTMLImageElement).src = `images/${stock.group}-unknown.png`;
|
||||
};
|
||||
|
||||
watch(
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
export const enum EVehicleUseType {
|
||||
LOCO_ELECTRICAL = 'loco-e',
|
||||
LOCO_DIESEL = 'loco-s',
|
||||
EMU = 'loco-ezt',
|
||||
DMU = 'loco-szt',
|
||||
|
||||
CAR_PASSENGER = 'car-passenger',
|
||||
CAR_CARGO = 'car-cargo',
|
||||
}
|
||||
+19
-19
@@ -15,12 +15,12 @@
|
||||
"cargo-title": "Cargo (only selected freight cars)",
|
||||
"no-cargo-available": "no cargo available",
|
||||
"cargo-empty": "empty",
|
||||
"loco-e": "ELECTR.",
|
||||
"loco-s": "DIESEL",
|
||||
"loco-ezt": "EMU",
|
||||
"loco-szt": "DMU",
|
||||
"car-passenger": "PASSENGER",
|
||||
"car-cargo": "FREIGHT",
|
||||
"loco-electric": "ELECTR.",
|
||||
"loco-diesel": "DIESEL",
|
||||
"unit-electric": "EMU",
|
||||
"unit-diesel": "DMU",
|
||||
"wagon-passenger": "PASSENGER",
|
||||
"wagon-freight": "FREIGHT",
|
||||
"action-add": "ADD NEW",
|
||||
"action-swap": "SWAP WITH",
|
||||
"real-stock": "POLISH TRAIN COMPOSITIONS"
|
||||
@@ -30,12 +30,12 @@
|
||||
"loading": "IMAGE LOADING...",
|
||||
"desc": "Choose a railway vehicle above to see its preview",
|
||||
"sponsor-only": "* SPONSORS ONLY UNTIL {0}",
|
||||
"loco-e": "ELECTRIC LOCO",
|
||||
"loco-s": "DIESEL LOCO",
|
||||
"loco-ezt": "ELECTRIC M.U.",
|
||||
"loco-szt": "DIESEL M.U.",
|
||||
"car-passenger": "PASSENGER CARRIAGE",
|
||||
"car-cargo": "FREIGHT CARRIAGE",
|
||||
"loco-electric": "ELECTRIC LOCO",
|
||||
"loco-diesel": "DIESEL LOCO",
|
||||
"unit-electric": "ELECTRIC M.U.",
|
||||
"unit-diesel": "DIESEL M.U.",
|
||||
"wagon-passenger": "PASSENGER CARRIAGE",
|
||||
"wagon-freight": "FREIGHT CARRIAGE",
|
||||
"cabin": "Cabin type:",
|
||||
"construction": "Construction type:"
|
||||
},
|
||||
@@ -68,7 +68,7 @@
|
||||
"coldstart-info": "Locomotive cold start",
|
||||
"doublemanning-info": "Double manning",
|
||||
"list-empty": "Stock list is empty!",
|
||||
"warning-not-suitable": "EP07 & EP08 type locomotives are designed for passenger traffic only!",
|
||||
"warning-not-suitable": "EP series locomotives are designed for passenger traffic only!",
|
||||
"warning-passenger-too-long": "Maximum length of a passenger train may not be greater than 350m!",
|
||||
"warning-freight-too-long": "Maximum length of a freight train may not be greater than 650m!",
|
||||
"warning-too-many-locos": "This train has too many traction units!",
|
||||
@@ -173,12 +173,12 @@
|
||||
"maxSpeed": "Speed",
|
||||
"cargoCount": "Cargo count"
|
||||
},
|
||||
"loco-ezt": "EMU",
|
||||
"loco-szt": "DMU",
|
||||
"loco-s": "Diesel locomotive",
|
||||
"loco-e": "Electric locomotive",
|
||||
"car-passenger": "Passenger carriage",
|
||||
"car-cargo": "Frieght carriage"
|
||||
"unit-electric": "EMU",
|
||||
"unit-diesel": "DMU",
|
||||
"loco-diesel": "Diesel locomotive",
|
||||
"loco-electric": "Electric locomotive",
|
||||
"wagon-passenger": "Passenger carriage",
|
||||
"wagon-freight": "Frieght carriage"
|
||||
},
|
||||
"realstock": {
|
||||
"title": "POLISH TRAIN COMPOSITIONS by",
|
||||
|
||||
+19
-19
@@ -15,12 +15,12 @@
|
||||
"cargo-title": "Ładunek (tylko wybrane towarowe)",
|
||||
"no-cargo-available": "brak dostępnych ładunków",
|
||||
"cargo-empty": "próżny",
|
||||
"loco-e": "ELEKTR.",
|
||||
"loco-s": "SPAL.",
|
||||
"loco-ezt": "EZT",
|
||||
"loco-szt": "SZT",
|
||||
"car-passenger": "PASAŻERSKIE",
|
||||
"car-cargo": "TOWAROWE",
|
||||
"loco-electric": "ELEKTR.",
|
||||
"loco-diesel": "SPAL.",
|
||||
"unit-electric": "EZT",
|
||||
"unit-diesel": "SZT",
|
||||
"wagon-passenger": "PASAŻERSKIE",
|
||||
"wagon-freight": "TOWAROWE",
|
||||
"action-add": "DODAJ NOWY",
|
||||
"action-swap": "ZAMIEŃ ZA",
|
||||
"real-stock": "REALNE ZESTAWIENIA"
|
||||
@@ -30,12 +30,12 @@
|
||||
"loading": "ŁADOWANIE OBRAZU...",
|
||||
"desc": "Wybierz pojazd lub wagon, aby zobaczyć jego podgląd powyżej",
|
||||
"sponsor-only": "* TYLKO DLA SPONSORÓW DO {0}",
|
||||
"loco-e": "ELEKTROWÓZ",
|
||||
"loco-s": "SPALINOWÓZ",
|
||||
"loco-ezt": "EZT",
|
||||
"loco-szt": "SZT",
|
||||
"car-passenger": "WAGON PASAŻERSKI",
|
||||
"car-cargo": "WAGON TOWAROWY",
|
||||
"loco-electric": "ELEKTROWÓZ",
|
||||
"loco-diesel": "SPALINOWÓZ",
|
||||
"unit-electric": "EZT",
|
||||
"unit-diesel": "SZT",
|
||||
"wagon-passenger": "WAGON PASAŻERSKI",
|
||||
"wagon-freight": "WAGON TOWAROWY",
|
||||
"cabin": "Typ kabiny:",
|
||||
"construction": "Typ konstrukcji:"
|
||||
},
|
||||
@@ -68,7 +68,7 @@
|
||||
"coldstart-info": "Zimny start",
|
||||
"doublemanning-info": "Podwójna obsada",
|
||||
"list-empty": "Lista pojazdów jest pusta!",
|
||||
"warning-not-suitable": "Lokomotywy EP07 i EP08 są przeznaczone jedynie do ruchu pasażerskiego!",
|
||||
"warning-not-suitable": "Lokomotywy serii EP są przeznaczone jedynie do ruchu pasażerskiego!",
|
||||
"warning-passenger-too-long": "Maksymalna długość składów pasażerskich nie może przekraczać 350m!",
|
||||
"warning-freight-too-long": "Maksymalna długość składów innych niż pasażerskie nie może przekraczać 650m!",
|
||||
"warning-too-many-locos": "Ten skład posiada za dużo pojazdów trakcyjnych!",
|
||||
@@ -173,12 +173,12 @@
|
||||
"maxSpeed": "Prędkość",
|
||||
"cargoCount": "Ładunki"
|
||||
},
|
||||
"loco-ezt": "EZT",
|
||||
"loco-szt": "SZT",
|
||||
"loco-s": "Spalinowóz",
|
||||
"loco-e": "Elektrowóz",
|
||||
"car-passenger": "Wagon pasażerski",
|
||||
"car-cargo": "Wagon towarowy"
|
||||
"loco-diesel": "Spalinowóz",
|
||||
"loco-electric": "Elektrowóz",
|
||||
"unit-electric": "EZT",
|
||||
"unit-diesel": "SZT",
|
||||
"wagon-passenger": "Wagon pasażerski",
|
||||
"wagon-freight": "Wagon towarowy"
|
||||
},
|
||||
"realstock": {
|
||||
"title": "ZESTAWIENIA REALNE by",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { useStore } from '../store';
|
||||
import { ICarWagon, ILocomotive, IStock, ICargo, IVehicle } from '../types';
|
||||
import { isLocomotive } from '../utils/vehicleUtils';
|
||||
import { isTractionUnit } from '../utils/vehicleUtils';
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
@@ -16,7 +16,7 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
getStockObject(vehicle: IVehicle, cargo?: ICargo | null, count = 1): IStock {
|
||||
const isLoco = isLocomotive(vehicle);
|
||||
const isLoco = isTractionUnit(vehicle);
|
||||
|
||||
return {
|
||||
id: this.getStockId(),
|
||||
@@ -27,8 +27,7 @@ export default defineComponent({
|
||||
isLoco,
|
||||
cargo: !isLoco && vehicle.loadable && cargo ? cargo : undefined,
|
||||
count,
|
||||
imgSrc: vehicle.imageSrc,
|
||||
useType: isLoco ? vehicle.power : vehicle.useType,
|
||||
group: isLoco ? vehicle.group : vehicle.group,
|
||||
isSponsorsOnly: vehicle.isSponsorsOnly,
|
||||
constructionType: vehicle.constructionType,
|
||||
sponsorsOnlyTimestamp: vehicle.sponsorsOnlyTimestamp,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { useStore } from '../store';
|
||||
import { ICarWagon, ILocomotive, IStock, IVehicle } from '../types';
|
||||
import { isLocomotive } from '../utils/vehicleUtils';
|
||||
import { ICarWagon, ILocomotive, IStock, IVehicle, LocoGroupType, WagonGroupType } from '../types';
|
||||
import { isTractionUnit } from '../utils/vehicleUtils';
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
@@ -14,40 +14,40 @@ export default defineComponent({
|
||||
|
||||
methods: {
|
||||
previewStock(stock: IStock) {
|
||||
if (this.store.chosenVehicle?.imageSrc != stock.imgSrc) this.store.imageLoading = true;
|
||||
// if (this.store.chosenVehicle?.imageSrc != stock.imgSrc) this.store.imageLoading = true;
|
||||
|
||||
if (stock.isLoco) {
|
||||
const chosenLoco = this.store.locoDataList.find((v) => v.type == stock.type) || null;
|
||||
this.store.chosenVehicle = chosenLoco;
|
||||
this.store.chosenLoco = chosenLoco;
|
||||
this.store.chosenCargo = null;
|
||||
this.store.chosenLocoPower = stock.useType;
|
||||
this.store.chosenLocoGroup = stock.group as LocoGroupType;
|
||||
} else {
|
||||
const chosenCar = this.store.carDataList.find((v) => v.type == stock.type) || null;
|
||||
this.store.chosenVehicle = chosenCar;
|
||||
this.store.chosenCar = chosenCar;
|
||||
|
||||
this.store.chosenCargo = stock.cargo || null;
|
||||
this.store.chosenCarUseType = stock.useType;
|
||||
this.store.chosenCarGroup = stock.group as WagonGroupType;
|
||||
}
|
||||
},
|
||||
|
||||
previewLocomotive(loco: ILocomotive) {
|
||||
this.store.chosenLoco = loco;
|
||||
this.store.chosenVehicle = loco;
|
||||
this.store.chosenLocoPower = loco.power;
|
||||
this.store.chosenLocoGroup = loco.group;
|
||||
},
|
||||
|
||||
previewCarWagon(carWagon: ICarWagon) {
|
||||
this.store.chosenCar = carWagon;
|
||||
this.store.chosenCarUseType = carWagon.useType;
|
||||
this.store.chosenCarGroup = carWagon.group;
|
||||
this.store.chosenVehicle = carWagon;
|
||||
|
||||
this.store.chosenCargo = null;
|
||||
},
|
||||
|
||||
previewVehicle(vehicle: IVehicle) {
|
||||
if (isLocomotive(vehicle)) this.previewLocomotive(vehicle);
|
||||
if (isTractionUnit(vehicle)) this.previewLocomotive(vehicle);
|
||||
else this.previewCarWagon(vehicle);
|
||||
},
|
||||
|
||||
|
||||
+7
-3
@@ -6,6 +6,8 @@ import {
|
||||
IVehicle,
|
||||
IStock,
|
||||
IRealComposition,
|
||||
LocoGroupType,
|
||||
WagonGroupType,
|
||||
} from './types';
|
||||
import { defineStore } from 'pinia';
|
||||
import {
|
||||
@@ -33,8 +35,8 @@ export const useStore = defineStore({
|
||||
|
||||
imageLoading: false,
|
||||
|
||||
chosenLocoPower: 'loco-e',
|
||||
chosenCarUseType: 'car-passenger',
|
||||
chosenLocoGroup: 'loco-electric' as LocoGroupType,
|
||||
chosenCarGroup: 'wagon-passenger' as WagonGroupType,
|
||||
|
||||
stockList: [] as IStock[],
|
||||
cargoOptions: [] as any[][],
|
||||
@@ -123,8 +125,10 @@ export const useStore = defineStore({
|
||||
actions: {
|
||||
async fetchVehiclesAPI() {
|
||||
try {
|
||||
const vehiclesData = (await http.get<IVehiclesAPI>('/vehicles.json')).data;
|
||||
const vehiclesData = (await http.get<IVehiclesAPI>('/vehiclesData')).data;
|
||||
this.vehiclesAPIData = vehiclesData;
|
||||
|
||||
console.log(vehiclesData);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
+21
-24
@@ -1,18 +1,19 @@
|
||||
export type IVehicle = ILocomotive | ICarWagon;
|
||||
export type StockSectionMode = 'STOCK_LIST' | 'STOCK_GENERATOR';
|
||||
|
||||
export type TLocoGroup = 'loco-e' | 'loco-s' | 'loco-ezt' | 'loco-szt';
|
||||
export type TCarWagonGroup = 'car-passenger' | 'car-cargo';
|
||||
export type LocoGroupType = 'loco-electric' | 'loco-diesel' | 'unit-electric' | 'unit-diesel';
|
||||
export type WagonGroupType = 'wagon-passenger' | 'wagon-freight';
|
||||
export type VehicleGroupType = LocoGroupType & WagonGroupType;
|
||||
|
||||
export interface IStockProps {
|
||||
export interface IVehicleProps {
|
||||
type: string;
|
||||
speed: number;
|
||||
length: number;
|
||||
// mass: number;
|
||||
weight: number;
|
||||
// cargo?: string | null;
|
||||
cargoTypes: ICargo[] | null;
|
||||
cargoTypes?: ICargo[];
|
||||
coldStart?: boolean;
|
||||
doubleManned?: boolean;
|
||||
supporterTimestamp?: number;
|
||||
}
|
||||
|
||||
export interface ICargo {
|
||||
@@ -29,16 +30,18 @@ export interface IVehiclesAPI {
|
||||
};
|
||||
};
|
||||
|
||||
vehicleInfo: {
|
||||
'car-cargo': [string, string, boolean, number | null, string][];
|
||||
'car-passenger': [string, string, boolean, number | null, string][];
|
||||
'loco-e': [string, string, string, string, number | null][];
|
||||
'loco-s': [string, string, string, string, number | null][];
|
||||
'loco-szt': [string, string, string, string, number | null][];
|
||||
'loco-ezt': [string, string, string, string, number | null][];
|
||||
};
|
||||
vehicleList: string[][];
|
||||
|
||||
vehicleProps: IStockProps[];
|
||||
// vehiclesList: {
|
||||
// 'loco-electric': string[][];
|
||||
// 'loco-diesel': string[][];
|
||||
// 'unit-electric': string[][];
|
||||
// 'unit-diesel': string[][];
|
||||
// 'wagon-passenger': string[][];
|
||||
// 'wagon-freight': string[][];
|
||||
// };
|
||||
|
||||
vehicleProps: IVehicleProps[];
|
||||
|
||||
vehicleLocales: {
|
||||
pl: {
|
||||
@@ -56,14 +59,12 @@ export interface IVehiclesAPI {
|
||||
|
||||
export interface ILocomotive {
|
||||
type: string;
|
||||
power: TLocoGroup;
|
||||
group: TLocoGroup;
|
||||
group: LocoGroupType;
|
||||
constructionType: string;
|
||||
cabinType: string;
|
||||
maxSpeed: number;
|
||||
isSponsorsOnly: boolean;
|
||||
sponsorsOnlyTimestamp: number;
|
||||
imageSrc: string;
|
||||
weight: number;
|
||||
length: number;
|
||||
coldStart: boolean;
|
||||
@@ -72,14 +73,12 @@ export interface ILocomotive {
|
||||
|
||||
export interface ICarWagon {
|
||||
type: string;
|
||||
useType: TCarWagonGroup;
|
||||
group: TCarWagonGroup;
|
||||
group: WagonGroupType;
|
||||
constructionType: string;
|
||||
loadable: boolean;
|
||||
isSponsorsOnly: boolean;
|
||||
sponsorsOnlyTimestamp: number;
|
||||
maxSpeed: number;
|
||||
imageSrc: string;
|
||||
weight: number;
|
||||
length: number;
|
||||
cargoTypes: ICargo[];
|
||||
@@ -88,10 +87,9 @@ export interface ICarWagon {
|
||||
export interface IStock {
|
||||
id: string;
|
||||
type: string;
|
||||
useType: string;
|
||||
group: LocoGroupType | WagonGroupType;
|
||||
constructionType: string;
|
||||
length: number;
|
||||
// mass: number;
|
||||
weight: number;
|
||||
maxSpeed: number;
|
||||
cargo?: ICargo;
|
||||
@@ -99,7 +97,6 @@ export interface IStock {
|
||||
isSponsorsOnly: boolean;
|
||||
sponsorsOnlyTimestamp: number;
|
||||
count: number;
|
||||
imgSrc?: string;
|
||||
}
|
||||
|
||||
export interface IRealComposition {
|
||||
|
||||
+53
-55
@@ -1,5 +1,11 @@
|
||||
import { EVehicleUseType } from '../enums/EVehicleUseType';
|
||||
import { ICarWagon, ILocomotive, IStock, IVehiclesAPI, TCarWagonGroup, TLocoGroup } from '../types';
|
||||
import {
|
||||
ICarWagon,
|
||||
ILocomotive,
|
||||
IStock,
|
||||
IVehiclesAPI,
|
||||
LocoGroupType,
|
||||
WagonGroupType,
|
||||
} from '../types';
|
||||
import {
|
||||
MassLimitLocoType,
|
||||
SpeedLimitLocoType,
|
||||
@@ -7,44 +13,41 @@ import {
|
||||
calculateSpeedLimit,
|
||||
} from './vehicleLimitsUtils';
|
||||
|
||||
export function isLocomotive(vehicle: ILocomotive | ICarWagon): vehicle is ILocomotive {
|
||||
return (vehicle as ILocomotive).power !== undefined;
|
||||
export function isTractionUnit(vehicle: ILocomotive | ICarWagon): vehicle is ILocomotive {
|
||||
return (vehicle as ILocomotive).cabinType !== undefined;
|
||||
}
|
||||
|
||||
export function locoDataList(vehiclesData: IVehiclesAPI | undefined) {
|
||||
if (!vehiclesData) return [];
|
||||
|
||||
return Object.keys(vehiclesData.vehicleInfo).reduce((acc, vehiclePower) => {
|
||||
if (!vehiclePower.startsWith('loco')) return acc;
|
||||
return vehiclesData.vehicleList.reduce((acc, vehicleInfoArray) => {
|
||||
// check if data array has 4 elements (locos & units only)
|
||||
if (vehicleInfoArray.length != 4) return acc;
|
||||
|
||||
const locoVehiclesData = vehiclesData.vehicleInfo[vehiclePower as TLocoGroup];
|
||||
const [type, constructionType, cabinType, group] = vehicleInfoArray;
|
||||
const locoProps = vehiclesData.vehicleProps.find((prop) => constructionType == prop.type);
|
||||
|
||||
locoVehiclesData.forEach((loco) => {
|
||||
// if (!loco[4]) return;
|
||||
if (!locoProps) {
|
||||
console.warn('No loco props', type);
|
||||
return acc;
|
||||
}
|
||||
|
||||
const [type, constructionType, cabinType, maxSpeed, sponsorsTimestamp] = loco;
|
||||
const locoProps = vehiclesData.vehicleProps.find((prop) => constructionType == prop.type);
|
||||
acc.push({
|
||||
group: group as LocoGroupType,
|
||||
|
||||
acc.push({
|
||||
power: vehiclePower as TLocoGroup,
|
||||
group: vehiclePower as TLocoGroup,
|
||||
type,
|
||||
constructionType,
|
||||
cabinType,
|
||||
maxSpeed: Number(maxSpeed),
|
||||
isSponsorsOnly: Number(sponsorsTimestamp) > Date.now(),
|
||||
sponsorsOnlyTimestamp: Number(sponsorsTimestamp),
|
||||
imageSrc: '',
|
||||
type,
|
||||
constructionType,
|
||||
cabinType,
|
||||
|
||||
length:
|
||||
locoProps?.length && type.startsWith('2EN')
|
||||
? locoProps.length * 2
|
||||
: locoProps?.length ?? 0,
|
||||
weight: locoProps?.weight && type.startsWith('2EN') ? 253000 : locoProps?.weight ?? 0,
|
||||
isSponsorsOnly: (locoProps.supporterTimestamp ?? 0) > Date.now(),
|
||||
sponsorsOnlyTimestamp: locoProps.supporterTimestamp ?? 0,
|
||||
|
||||
coldStart: locoProps?.coldStart ?? false,
|
||||
doubleManned: locoProps?.doubleManned ?? false,
|
||||
});
|
||||
maxSpeed: locoProps.speed,
|
||||
length: locoProps.length,
|
||||
weight: locoProps.weight,
|
||||
|
||||
coldStart: locoProps.coldStart ?? false,
|
||||
doubleManned: locoProps.doubleManned ?? false,
|
||||
});
|
||||
|
||||
return acc;
|
||||
@@ -54,35 +57,30 @@ export function locoDataList(vehiclesData: IVehiclesAPI | undefined) {
|
||||
export function carDataList(vehiclesData: IVehiclesAPI | undefined) {
|
||||
if (!vehiclesData) return [];
|
||||
|
||||
return Object.keys(vehiclesData.vehicleInfo).reduce((acc, vehicleUseType) => {
|
||||
if (!vehicleUseType.startsWith('car')) return acc;
|
||||
return vehiclesData.vehicleList.reduce((acc, vehicleInfoArray) => {
|
||||
// check if data array has 3 elements (wagons only)
|
||||
if (vehicleInfoArray.length != 3) return acc;
|
||||
|
||||
const carVehiclesData = vehiclesData.vehicleInfo[vehicleUseType as TCarWagonGroup];
|
||||
const [type, constructionType, group] = vehicleInfoArray;
|
||||
const wagonProps = vehiclesData.vehicleProps.find((v) => type.toString().startsWith(v.type));
|
||||
|
||||
carVehiclesData.forEach((car) => {
|
||||
const [type, constructionType, loadable, sponsorsOnlyTimestamp, maxSpeed] = car;
|
||||
if (!wagonProps) {
|
||||
console.warn('No wagon props', type);
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (sponsorsOnlyTimestamp && Number(sponsorsOnlyTimestamp) <= Date.now()) return;
|
||||
acc.push({
|
||||
group: group as WagonGroupType,
|
||||
type,
|
||||
constructionType,
|
||||
loadable: wagonProps.cargoTypes ? wagonProps.cargoTypes.length > 0 : false,
|
||||
isSponsorsOnly: (wagonProps.supporterTimestamp ?? 0) > Date.now(),
|
||||
sponsorsOnlyTimestamp: wagonProps.supporterTimestamp ?? 0,
|
||||
cargoTypes: wagonProps?.cargoTypes ?? [],
|
||||
|
||||
const carPropsData = vehiclesData.vehicleProps.find((v) =>
|
||||
type.toString().startsWith(v.type)
|
||||
);
|
||||
|
||||
acc.push({
|
||||
useType: vehicleUseType as TCarWagonGroup,
|
||||
group: vehicleUseType as TCarWagonGroup,
|
||||
type,
|
||||
constructionType,
|
||||
loadable,
|
||||
isSponsorsOnly: Number(sponsorsOnlyTimestamp) > Date.now(),
|
||||
sponsorsOnlyTimestamp: Number(sponsorsOnlyTimestamp),
|
||||
maxSpeed: Number(maxSpeed),
|
||||
imageSrc: '',
|
||||
cargoTypes: carPropsData?.cargoTypes ?? [],
|
||||
|
||||
weight: carPropsData?.weight || 0,
|
||||
length: carPropsData?.length || 0,
|
||||
});
|
||||
maxSpeed: wagonProps.speed,
|
||||
weight: wagonProps?.weight || 0,
|
||||
length: wagonProps?.length || 0,
|
||||
});
|
||||
|
||||
return acc;
|
||||
@@ -142,5 +140,5 @@ export function isTrainPassenger(stockList: IStock[]) {
|
||||
|
||||
return stockList
|
||||
.filter((stock) => !stock.isLoco)
|
||||
.every((stock) => stock.useType === EVehicleUseType.CAR_PASSENGER);
|
||||
.every((stock) => stock.group === 'wagon-passenger');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user