From 77eccc2b2881d46a5bf972aa5a981cbda058b6a3 Mon Sep 17 00:00:00 2001 From: David Wheatley Date: Sun, 16 Jun 2024 23:11:28 +0100 Subject: [PATCH] feat: try DVP short platforms for HS1 --- src/data/liveTrains/shortPlatforms.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/data/liveTrains/shortPlatforms.ts b/src/data/liveTrains/shortPlatforms.ts index d6068b9c1..9c46664dc 100644 --- a/src/data/liveTrains/shortPlatforms.ts +++ b/src/data/liveTrains/shortPlatforms.ts @@ -1772,6 +1772,15 @@ const data: Record< }, }, DVP: { + '1': { + SE: southeasternHs1('front.8', 'front.12'), + }, + '2': { + SE: southeasternHs1('front.8', 'front.10'), + }, + '3': { + SE: 'front.8', + }, '*': { SE: 'front.8', }, @@ -2161,3 +2170,21 @@ function southernTurboElectro(turboLen: `${'front' | 'middle' | 'rear'}.${number return electroLen } } + +function southeasternHs1(nonHs1: `${'front' | 'middle' | 'rear'}.${number}`, hs1: `${'front' | 'middle' | 'rear'}.${number}`) { + return (trainService: TrainService): `${'front' | 'middle' | 'rear'}.${number}` | null => { + const hs1Stations = ['STP', 'EBD', 'SFA', 'ASI', 'AFK'] + + if ( + trainService.origin.some(s => hs1Stations.includes(s.crs)) || + trainService.destination.some(s => hs1Stations.includes(s.crs)) || + trainService.origin.some(s => hs1Stations.includes(s.crs)) || + trainService.destination.some(s => hs1Stations.includes(s.crs)) || + trainService.subsequentLocations.some(s => hs1Stations.includes(s.crs || '')) + ) { + return hs1 + } + + return nonHs1 + } +}