import { Tile } from "../../types/flights"; import { buildSeed } from "../seed/build-seed"; import { procedurallyGetBoolean } from "../seed/procedurally-get-boolean"; import { procedurallyGetUuidV4 } from "../seed/procedurally-get-uuid-v4"; import { procedurallyPickItemFrom } from "../seed/procedurally-pick-item-from"; import { getFareOptions } from "./get-fare-options"; interface GetTilesOptions { bundleSeed: number; } interface GenerateTileOptions { bundleSeed: number; tileTier: "1" | "2" | "3" | "4" | "5"; } // TODO: titles by airlines const tileTitlesByTier = { 1: ["Main basic", "Economy Basic", "Basic Economy", "Basic", "Light"], 2: ["Classic", "Main Cabin", "Standard"], 3: ["Comfort Classic", "Comfort Basic", "Main Plus"], 4: [ "Premium Economy", "Premium", "Premium Select", "First Classic", "First Extra", "First", ], 5: ["Business Plus", "Premium Business", "Flagship Business"], }; const generateTile = ({ bundleSeed, tileTier }: GenerateTileOptions): Tile => { const tileSeed = buildSeed(`${bundleSeed}-${tileTier}-tile-generator`); const isEmptyTile = procedurallyGetBoolean(tileSeed, 30); if (isEmptyTile) { return null; } const title = procedurallyPickItemFrom(tileSeed, tileTitlesByTier[tileTier]); const fareOptions = getFareOptions({ tileSeed, tileTier, tileTitle: title, }); return { id: procedurallyGetUuidV4(tileSeed), title, // TODO: these odds should change based on airline and tile tier // TODO: should these values even be booleans? or should they be an array of features for example? isMixedCabin: procedurallyGetBoolean(tileSeed, 50), isFreeCheckedBag: procedurallyGetBoolean(tileSeed, 50), fareOptions, }; }; export const getTiles = ({ bundleSeed }: GetTilesOptions) => { const tiles = (["1", "2", "3", "4", "5"] as const).map((value) => generateTile({ bundleSeed, tileTier: value, }) ); return tiles; };