import type { Airport } from "../../types/airport"; import { procedurallyGetIntegerBetween } from "../seed/procedurally-get-integer-between"; interface GetFlightCountOptions { originAirport: Airport; destinationAirport: Airport; seed: number; } export const getFlightCount = ({ originAirport, destinationAirport, seed, }: GetFlightCountOptions) => { const originAirportType = originAirport.type; const destinationAirportType = destinationAirport.type; const isNationalFlight = originAirport.iso_country === destinationAirport.iso_country; const isSameContinentFlight = originAirport.continent === destinationAirport.continent; const isLargeAirportFlight = originAirportType === "large_airport" && destinationAirportType === "large_airport"; const isMediumAirportFlight = originAirportType === "medium_airport" && destinationAirportType === "medium_airport"; if (isNationalFlight) { if (isLargeAirportFlight) { return procedurallyGetIntegerBetween(seed, 18, 36); } if (isMediumAirportFlight) { return procedurallyGetIntegerBetween(seed, 3, 9); } return procedurallyGetIntegerBetween(seed, 6, 24); } if (isSameContinentFlight) { if (isLargeAirportFlight) { return procedurallyGetIntegerBetween(seed, 5, 15); } if (isMediumAirportFlight) { return procedurallyGetIntegerBetween(seed, 0, 3); } return procedurallyGetIntegerBetween(seed, 0, 12); } if (isLargeAirportFlight) { return procedurallyGetIntegerBetween(seed, 0, 10); } if (isMediumAirportFlight) { return 0; } return procedurallyGetIntegerBetween(seed, 0, 1); };