mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
chore: updated stock speed limit calculation
This commit is contained in:
@@ -219,15 +219,23 @@ export default defineComponent({
|
||||
stockSpeedLimit() {
|
||||
let isPassenger = true;
|
||||
|
||||
const vehicleMaxSpeed = this.train.stockList.reduce((acc, stockName) => {
|
||||
const vehicleData = this.apiStore.vehiclesData?.find(
|
||||
(v) => v.name == stockName.split(':')[0]
|
||||
);
|
||||
const vehicleMaxSpeed = this.train.stockList.reduce((acc, stockName, i) => {
|
||||
const [vehicleName, vehicleCargo] = stockName.split(':');
|
||||
|
||||
const vehicleData = this.apiStore.vehiclesData?.find((v) => v.name == vehicleName);
|
||||
|
||||
if (!vehicleData) return acc;
|
||||
if (vehicleData.type == 'wagon-freight') isPassenger = false;
|
||||
|
||||
const vehicleSpeed = vehicleData.group.speed;
|
||||
let vehicleSpeed = vehicleData.group.speed;
|
||||
|
||||
if (vehicleData.type == 'wagon-freight') {
|
||||
isPassenger = false;
|
||||
|
||||
if (vehicleCargo !== undefined && vehicleData.group.speedLoaded) {
|
||||
vehicleSpeed = vehicleData.group.speedLoaded;
|
||||
console.log('detected loaded', vehicleSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
return Math.min(vehicleSpeed, acc);
|
||||
}, Infinity);
|
||||
|
||||
Reference in New Issue
Block a user