@@ -229,498 +18,26 @@
\ No newline at end of file
diff --git a/src/components/ListSection.vue b/src/components/ListSection.vue
new file mode 100644
index 0000000..0eecc9e
--- /dev/null
+++ b/src/components/ListSection.vue
@@ -0,0 +1,438 @@
+
+
+
+
+
+
+ POGLĄD WYBRANEGO POJAZDU
+
+
+ ŁADOWANIE OBRAZU...
+
+
![]()
+
![]()
+
+
+
+
+
+
+
+
+
+
+
+ Masa: {{ totalMass }} t | Długość:
+ {{ totalLength }}
+ m | Vmax składu:
+ {{ maxSpeed }} km/h
+
+
+ -
+
Lista pojazdów jest pusta!
+
+
+ -
+
+
+ {{ stock.isLoco ? stock.type : getCarSpecFromType(stock.type) }}
+
+ ({{ stock.cargo?.id }})
+
+ {{ stock.length }}m
+
+ {{ stock.cargo ? stock.cargo.totalMass : stock.mass }}t
+
+
+
+
+
+
{{ stock.count }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main.ts b/src/main.ts
index b670de8..1e573fb 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,4 +1,24 @@
import { createApp } from "vue";
import App from "./App.vue";
-createApp(App).mount("#app");
+import { ICargo, ICarWagon, ILocomotive, IStock, IStore } from "./types";
+import { reactive } from "@vue/reactivity";
+
+const Store: IStore = reactive({
+ chosenCar: null as ICarWagon | null,
+ chosenLoco: null as ILocomotive | null,
+ chosenCargo: null as ICargo | null,
+
+ showSupporter: false,
+ imageLoading: false,
+
+ chosenLocoPower: "loco-e",
+ chosenCarUseType: "car-passenger",
+
+ stockList: [] as IStock[],
+ cargoOptions: [] as any[][],
+})
+
+createApp(App)
+ .provide('Store', Store)
+ .mount("#app");
diff --git a/src/mixins/StatsMixin.ts b/src/mixins/StatsMixin.ts
new file mode 100644
index 0000000..c1b27b6
--- /dev/null
+++ b/src/mixins/StatsMixin.ts
@@ -0,0 +1,147 @@
+import { IVehicleData, ILocomotive, ICarWagon, IStore } from "@/types";
+import { defineComponent, inject } from "@vue/runtime-core";
+import { computed } from "@vue/reactivity";
+
+import vehicleDataJSON from "@/data/vehicleData.json";
+import vehiclePropsJSON from "@/data/vehicleProps.json";
+
+export default defineComponent({
+
+ setup() {
+ return {
+ store: inject("Store") as IStore
+ }
+ },
+
+ computed: {
+ locoDataList() {
+ return Object.keys(vehicleDataJSON).reduce(
+ (acc, vehicleTypeKey) => {
+ if (!vehicleTypeKey.startsWith("loco")) return acc;
+
+ const locoVehiclesData = (vehicleDataJSON as IVehicleData)[
+ vehicleTypeKey
+ ];
+
+ locoVehiclesData.forEach((loco) => {
+ if (loco[4] && !this.store.showSupporter) return;
+
+ const locoType = loco[0] as string;
+
+ let length = 0,
+ mass = 0;
+
+ // Elektrowozy
+ if (vehicleTypeKey.startsWith("loco-e")) {
+ // 32m dla ET41, reszta 16
+ length = locoType.startsWith("ET") ? 32 : 16;
+
+ // 80t dla wszystkich EU06, EP08
+ mass = 80;
+
+ // 83t dla: EU07 o nr większych niż 300 & dla wszystkich EP07 oprócz nr 135,242,1002,1048
+ const locoNumber = Number(locoType.split("-")[1]);
+
+ if (
+ (locoType.startsWith("EU") && locoNumber > 300) ||
+ (locoType.startsWith("EP") &&
+ ![242, 135, 1002, 1048].includes(locoNumber))
+ ) {
+ mass = 83;
+ }
+ }
+
+ // Spalinowozy
+ if (vehicleTypeKey.startsWith("loco-s")) {
+ length = 14;
+ mass = 74;
+ }
+
+ // EZT
+ if (vehicleTypeKey.startsWith("loco-ezt")) {
+ // EN57
+ length = 65;
+ mass = 126;
+
+ // EN71
+ if (locoType.startsWith("EN71")) {
+ length = 86;
+ mass = 182;
+ }
+
+ // 2xEN57
+ if (locoType.startsWith("2EN57")) {
+ length = 130;
+ mass = 253;
+ }
+ }
+
+ // SZT
+ if (vehicleTypeKey.startsWith("loco-szt")) {
+ length = 14;
+ mass = 23;
+ }
+
+ acc.push({
+ power: vehicleTypeKey,
+ type: loco[0] as string,
+ constructionType: loco[1] as string,
+ cabinType: loco[2] as string,
+ maxSpeed: Number(loco[3] as string),
+ supportersOnly: loco[4] as boolean,
+ imageSrc: loco[5] as string,
+
+ length,
+ mass,
+ });
+ });
+
+ return acc;
+ },
+ [] as ILocomotive[]
+ );
+
+ },
+
+ carDataList() {
+ return Object.keys(vehicleDataJSON).reduce(
+ (acc, vehicleTypeKey) => {
+ if (!vehicleTypeKey.startsWith("car")) return acc;
+
+ const carVehiclesData = (vehicleDataJSON as IVehicleData)[
+ vehicleTypeKey
+ ];
+
+ carVehiclesData.forEach((car) => {
+ if (car[3] && !this.store.showSupporter) return;
+
+ const carPropsData = vehiclePropsJSON.find((v) =>
+ car[0].toString().includes(v.type)
+ );
+
+ acc.push({
+ useType: vehicleTypeKey,
+ type: car[0] as string,
+ constructionType: car[1] as string,
+ loadable: car[2] as boolean,
+ supportersOnly: car[3] as boolean,
+ maxSpeed: Number(car[4] as string),
+ imageSrc: car[5] as string,
+ cargoList:
+ carPropsData?.cargo.split(";").map((cargo) => ({
+ id: cargo.split(":")[0],
+ totalMass: Number(cargo.split(":")[1]),
+ })) || [],
+
+ mass: carPropsData?.mass || 0,
+ length: carPropsData?.length || 0,
+ });
+ });
+
+ return acc;
+ },
+ [] as ICarWagon[]
+ );
+ },
+ }
+});
diff --git a/src/types.ts b/src/types.ts
new file mode 100644
index 0000000..5ec2211
--- /dev/null
+++ b/src/types.ts
@@ -0,0 +1,63 @@
+export interface IStore {
+ chosenCar: ICarWagon | null;
+ chosenLoco: ILocomotive | null;
+ chosenCargo: ICargo | null;
+
+ showSupporter: boolean;
+ imageLoading: boolean;
+
+ chosenLocoPower: string;
+ chosenCarUseType: string;
+
+ stockList: IStock[];
+ cargoOptions: any[][];
+}
+
+export interface IVehicleData {
+ [key: string]: (string | boolean)[][];
+}
+
+export interface ILocomotive {
+ type: string;
+ power: string;
+ constructionType: string;
+ cabinType: string;
+ maxSpeed: number;
+ supportersOnly: boolean;
+ imageSrc: string;
+
+ mass: number;
+ length: number;
+}
+
+export interface ICarWagon {
+ //"203V_PKPC_Fll_01","203V",true,false,"100",img
+ type: string;
+ useType: string;
+ constructionType: string;
+ loadable: boolean;
+ supportersOnly: boolean;
+ maxSpeed: number;
+ imageSrc: string;
+
+ mass: number;
+ length: number;
+ cargoList: { id: string; totalMass: number }[];
+}
+
+export interface ICargo {
+ id: string;
+ totalMass: number;
+}
+
+export interface IStock {
+ useType: string;
+ type: string;
+ length: number;
+ mass: number;
+ maxSpeed: number;
+ cargo?: { id: string; totalMass: number };
+ isLoco: boolean;
+ count: number;
+ imgSrc: string;
+}
\ No newline at end of file