mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
Przygotowanie pod nowszą wersję pliku JSON
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import ScheduledTrain from "./ScheduledTrain";
|
||||
import StationRoutes from "./StationRoutes";
|
||||
|
||||
export default interface Station {
|
||||
name: string;
|
||||
@@ -8,13 +9,11 @@ export default interface Station {
|
||||
url: string;
|
||||
|
||||
reqLevel: number;
|
||||
supportersOnly: boolean;
|
||||
// supportersOnly: boolean;
|
||||
|
||||
lines: string;
|
||||
project: string;
|
||||
|
||||
SBL: string;
|
||||
TWB: string;
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
|
||||
@@ -24,17 +23,14 @@ export default interface Station {
|
||||
nonPublic: boolean;
|
||||
unavailable: boolean;
|
||||
|
||||
routes: {
|
||||
oneWay: { catenary: number; noCatenary: number };
|
||||
twoWay: { catenary: number; noCatenary: number };
|
||||
};
|
||||
routes: StationRoutes;
|
||||
|
||||
checkpoints: {
|
||||
checkpointName: string;
|
||||
scheduledTrains: ScheduledTrain[];
|
||||
}[];
|
||||
};
|
||||
|
||||
|
||||
onlineInfo?: {
|
||||
hash: string;
|
||||
name: string;
|
||||
@@ -42,23 +38,23 @@ export default interface Station {
|
||||
maxUsers: number;
|
||||
currentUsers: number;
|
||||
|
||||
spawns: { spawnName: string; spawnLength: number }[];
|
||||
spawns: { spawnName: string; spawnLength: number }[];
|
||||
dispatcherRate: number;
|
||||
dispatcherName: string;
|
||||
dispatcherExp: number;
|
||||
dispatcherId: number;
|
||||
dispatcherIsSupporter: boolean;
|
||||
|
||||
|
||||
statusTimestamp: number;
|
||||
statusTimeString: string;
|
||||
statusID: string;
|
||||
|
||||
|
||||
stationTrains?: {
|
||||
driverName: string;
|
||||
trainNo: number;
|
||||
stopStatus?: string;
|
||||
}[];
|
||||
|
||||
|
||||
scheduledTrains?: ScheduledTrain[];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
export default interface StationRoutes {
|
||||
oneWay:
|
||||
{
|
||||
name: string;
|
||||
catenary: boolean;
|
||||
SBL: boolean;
|
||||
TWB: boolean
|
||||
}[];
|
||||
|
||||
twoWay: {
|
||||
name: string;
|
||||
catenary: boolean;
|
||||
SBL: boolean;
|
||||
TWB: boolean
|
||||
}[];
|
||||
|
||||
/* [catenary, noCatenary] */
|
||||
oneWayCatenaryRouteNames: string[];
|
||||
oneWayNoCatenaryRouteNames: string[];
|
||||
twoWayCatenaryRouteNames: string[];
|
||||
twoWayNoCatenaryRouteNames: string[];
|
||||
sblRouteNames: string[];
|
||||
}
|
||||
@@ -77,26 +77,25 @@ const filterStations = (station: Station, filters: Filter) => {
|
||||
if (station.generalInfo?.unavailable && filters['unavailable']) return returnMode;
|
||||
|
||||
if (station.generalInfo) {
|
||||
const routes = station.generalInfo.routes;
|
||||
|
||||
if (station.generalInfo.default && filters['default']) return returnMode;
|
||||
if (!station.generalInfo.default && filters['notDefault']) return returnMode;
|
||||
|
||||
if (filters['real'] && station.generalInfo.lines != '') return returnMode;
|
||||
if (filters['fictional'] && station.generalInfo.lines == '') return returnMode;
|
||||
|
||||
// if (station.generalInfo.reqLevel == -1) return true;
|
||||
// if (station.generalInfo.reqLevel == -1 && filters['minLevel'] == 0) return true;
|
||||
|
||||
if (station.generalInfo.reqLevel + ((station.generalInfo.nonPublic || station.generalInfo.unavailable) ? 1 : 0) < filters['minLevel']) return returnMode;
|
||||
if (station.generalInfo.reqLevel + ((station.generalInfo.nonPublic || station.generalInfo.unavailable) ? 1 : 0) > filters['maxLevel']) return returnMode;
|
||||
|
||||
if (filters['no-1track'] && (station.generalInfo.routes.oneWay.catenary != 0 || station.generalInfo.routes.oneWay.noCatenary != 0)) return returnMode;
|
||||
if (filters['no-2track'] && (station.generalInfo.routes.twoWay.catenary != 0 || station.generalInfo.routes.twoWay.noCatenary != 0)) return returnMode;
|
||||
if (filters['no-1track'] && (routes.oneWayCatenaryRouteNames.length != 0 || routes.oneWayNoCatenaryRouteNames.length != 0)) return returnMode;
|
||||
if (filters['no-2track'] && (routes.twoWayCatenaryRouteNames.length != 0 || routes.twoWayNoCatenaryRouteNames.length != 0)) return returnMode;
|
||||
|
||||
if (station.generalInfo.routes.oneWay.catenary < filters['minOneWayCatenary']) return returnMode;
|
||||
if (station.generalInfo.routes.oneWay.noCatenary < filters['minOneWay']) return returnMode;
|
||||
if (routes.oneWayCatenaryRouteNames.length < filters['minOneWayCatenary']) return returnMode;
|
||||
if (routes.oneWayNoCatenaryRouteNames.length < filters['minOneWay']) return returnMode;
|
||||
|
||||
if (station.generalInfo.routes.twoWay.catenary < filters['minTwoWayCatenary']) return returnMode;
|
||||
if (station.generalInfo.routes.twoWay.noCatenary < filters['minTwoWay']) return returnMode;
|
||||
if (routes.twoWayCatenaryRouteNames.length < filters['minTwoWayCatenary']) return returnMode;
|
||||
if (routes.twoWayNoCatenaryRouteNames.length < filters['minTwoWay']) return returnMode;
|
||||
|
||||
if (filters[station.generalInfo.controlType]) return returnMode;
|
||||
if (filters[station.generalInfo.signalType]) return returnMode;
|
||||
@@ -112,7 +111,7 @@ const filterStations = (station: Station, filters: Filter) => {
|
||||
|
||||
if (filters['ręczne'] && station.generalInfo.controlType.includes('ręczne')) return returnMode;
|
||||
|
||||
if (filters['SBL'] && station.generalInfo.SBL) return returnMode;
|
||||
if (filters['SBL'] && routes.sblRouteNames.length > 0) return returnMode;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export const URLs = {
|
||||
sceneryData: "https://spythere.github.io/api/stationDataDev.json",
|
||||
sceneryData: "https://spythere.github.io/api/stationDataNew.json",
|
||||
sceneryDataDev: "http://127.0.0.1:8000/data",
|
||||
stations: "https://api.td2.info.pl:9640/?method=getStationsOnline",
|
||||
trains: "https://api.td2.info.pl:9640/?method=getTrainsOnline",
|
||||
|
||||
Reference in New Issue
Block a user