mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
chore: adjusted to new version of API vehicles data
This commit is contained in:
@@ -23,9 +23,9 @@
|
||||
<span v-if="vehicleCargo">({{ vehicleCargo.id }})</span>
|
||||
</div>
|
||||
|
||||
<div class="vehicle-props" v-if="vehicleProps">
|
||||
{{ vehicleProps.speed }}km/h • {{ vehicleProps.length }}m •
|
||||
{{ (vehicleProps.weight / 1000).toFixed(1) }}t
|
||||
<div class="vehicle-props" v-if="vehicleData">
|
||||
{{ vehicleData.group.speed }}km/h • {{ vehicleData.group.length }}m •
|
||||
{{ (vehicleData.group.weight / 1000).toFixed(1) }}t
|
||||
<span v-if="vehicleCargo">(+{{ (vehicleCargo.weight / 1000).toFixed(1) }}t)</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -72,23 +72,27 @@ export default defineComponent({
|
||||
return this.tooltipStore.content.split(':')[0];
|
||||
},
|
||||
|
||||
vehicleCargo() {
|
||||
return this.vehicleProps?.cargoTypes?.find(
|
||||
(c) => c.id == this.tooltipStore.content.split(':')[1]
|
||||
);
|
||||
vehicleData() {
|
||||
return this.apiStore.vehiclesData?.find((v) => v.name == this.vehicleName);
|
||||
},
|
||||
|
||||
vehicleProps() {
|
||||
const vehicleDataArray = this.apiStore.vehiclesData?.vehicleList.find(
|
||||
([name]) => name === this.vehicleName
|
||||
);
|
||||
|
||||
if (!vehicleDataArray) return null;
|
||||
|
||||
return (
|
||||
this.apiStore.vehiclesData!.vehicleProps.find((v) => v.type == vehicleDataArray[1]) ?? null
|
||||
vehicleCargo() {
|
||||
return this.vehicleData?.group.cargoTypes?.find(
|
||||
(c) => c.id == this.tooltipStore.content.split(':')[1]
|
||||
);
|
||||
}
|
||||
|
||||
// vehicleProps() {
|
||||
// const vehicleDataArray = this.apiStore.vehiclesData?.vehicleList.find(
|
||||
// ([name]) => name === this.vehicleName
|
||||
// );
|
||||
|
||||
// if (!vehicleDataArray) return null;
|
||||
|
||||
// return (
|
||||
// this.apiStore.vehiclesData!.vehicleProps.find((v) => v.type == vehicleDataArray[1]) ?? null
|
||||
// );
|
||||
// }
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
<img src="/images/icon-speed.svg" alt="speed icon" />
|
||||
{{ train.speed }} km/h
|
||||
|
||||
<span v-if="maxSpeed != Infinity">
|
||||
<span v-if="stockSpeedLimit != Infinity">
|
||||
•
|
||||
<em
|
||||
class="text--grayed"
|
||||
@@ -140,7 +140,7 @@
|
||||
tabindex="0"
|
||||
:data-tooltip="$t('trains.vmax-tooltip')"
|
||||
>
|
||||
{{ maxSpeed }} km/h
|
||||
{{ stockSpeedLimit }} km/h
|
||||
</em>
|
||||
</span>
|
||||
</div>
|
||||
@@ -204,24 +204,14 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
computed: {
|
||||
maxSpeed() {
|
||||
stockSpeedLimit() {
|
||||
return this.train.stockList.reduce((acc, stockName) => {
|
||||
const stockVehicleInfo = this.apiStore.vehiclesData?.vehicleList.find(
|
||||
(v) => v[0] == stockName.split(':')[0]
|
||||
);
|
||||
const vehicleSpeed =
|
||||
this.apiStore.vehiclesData?.find((v) => v.name == stockName.split(':')[0])?.group.speed ??
|
||||
300;
|
||||
|
||||
if (!stockVehicleInfo) return acc;
|
||||
|
||||
const stockVehicleProps = this.apiStore.vehiclesData?.vehicleProps.find(
|
||||
(v) => v.type == stockVehicleInfo[1]
|
||||
);
|
||||
|
||||
if (!stockVehicleProps) return acc;
|
||||
|
||||
if (stockVehicleProps.speed < acc) return stockVehicleProps.speed;
|
||||
|
||||
return acc;
|
||||
}, Infinity);
|
||||
return Math.min(vehicleSpeed, acc);
|
||||
}, 300);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user