/** Vector airfield for edition 00475. Positions share the engine's slot IDs. */ type Point = { x: number; y: number; angle: number; label: string }; type Geometry = { ab_stands: number; b_stands: number; ac_stands: number; queue_capacity: number; runways: string[]; }; type Marker = { key: string; caption: string; color: string; size: number; name: string; }; type MapView = { geometry: Geometry; markers: Record; pickable: Set; destinations: Set; selected: string; weather: string | null; piles?: { deck: number; discard: string; weather: string }; }; const width = 1080, height = 548; const laneY = (lane: string) => (lane === "31R" ? 57 : 491); const queueY = (lane: string) => (lane === "31R" ? 129 : 419); const spread = (i: number, n: number, from: number, to: number) => n <= 1 ? (from + to) / 2 : from + ((to - from) * i) / (n - 1); function geometry(b: Geometry) { const points: Record = {}; const add = ( id: string, x: number, y: number, angle: number, label: string, ) => (points[id] = { x, y, angle, label }); for (const lane of b.runways) { const sy = laneY(lane), qy = queueY(lane); add("D:" + lane + ":0", 987, sy, -90, "D"); for (let n = 1; n < b.queue_capacity; n++) add( "D:" + lane + ":" + n, spread(n - 1, b.queue_capacity - 1, 949, 670), qy, 90, "D" + n, ); } for (let n = 0; n < b.ab_stands; n++) { const upper = n < Math.ceil(b.ab_stands / 2), count = upper ? Math.ceil(b.ab_stands / 2) : Math.floor(b.ab_stands / 2); add( "A:B" + (n + 1), spread(upper ? n : n - Math.ceil(b.ab_stands / 2), count, 440, 600), upper ? 215 : 332, upper ? 180 : 0, "A" + (n + 1), ); } for (let n = 0; n < b.b_stands; n++) add( "B:B" + (n + 1), spread(n, b.b_stands, 410, 638), n % 2 ? 371 : 176, 90, "B" + (n + 1), ); for (let n = 0; n < b.ac_stands; n++) { const x = spread(n, b.ac_stands, 116, 258); add("A:C" + (n + 1), x, 260, 0, "A" + (n + 1)); add("C:C" + (n + 1), x, 311, 180, "C" + (n + 1)); } for (const lane of b.runways) { const upper = lane === "31R"; add("V1:" + lane, 834, upper ? 231 : 317, 90, "VIP1"); add("V2:" + lane, 914, upper ? 231 : 317, 90, "VIP2"); } return points; } function runway(lane: string, weather: string | null) { const y = laneY(lane); const bars = Array.from( { length: 6 }, (_, i) => '', ).join(""); const lights = Array.from( { length: 24 }, (_, i) => '', ).join(""); return ` ${bars} ${lights} ${lane} ${weather === lane || weather === "FG" ? '' : ""}`; } const fieldDefs = ` `; function building(x: number, y: number, w: number, h: number) { const vents = Array.from( { length: Math.max(1, Math.floor(w / 44)) }, (_, i) => ``, ).join(""); return ` ${vents}`; } function apronEquipment() { const carts = ( x: number, y: number, angle: number, ) => ` ${[9, 18, 27].map((x) => ``).join("")}`; const hatches = Array.from( { length: 9 }, (_, i) => ``, ).join(""); return `${hatches} ${carts(374, 317, 0)}${carts(626, 288, 90)}${carts(786, 299, -90)} `; } function terrain(points: Record) { let seed = 49075; function rand() { seed = (1664525 * seed + 1013904223) >>> 0; return seed / 4294967296; } const trees = [ [45, 172, 34, 202], [65, 91, 265, 22], [69, 447, 270, 18], [383, 96, 200, 15], [361, 442, 214, 12], [1012, 187, 31, 161], ] .map(([x, y, w, h]) => Array.from( { length: Math.ceil((w * h) / 180) }, () => ``, ).join(""), ) .join(""); const routes: string[] = [ "M91 129H938Q987 129 987 90V57", "M91 419H938Q987 419 987 458V491", "M91 129Q72 129 72 151V397Q72 419 91 419", "M350 129V419", "M350 176H680Q722 176 752 129", "M350 371H680Q722 371 752 419", "M776 129Q758 170 758 202V342Q758 374 776 419", "M758 231H914Q955 231 955 265V283Q955 317 914 317H758", ]; for (const [id, p] of Object.entries(points)) { if (id.startsWith("A:B")) routes.push(`M${p.x} ${p.y}V${p.y < 274 ? 176 : 371}`); if (id.startsWith("A:C")) routes.push(`M${p.x} 129V419`); } const line = routes.map((d) => ``).join(""); const apron = ''; const fingers = Object.entries(points) .filter(([k]) => k.startsWith("A:B")) .map(([, p]) => { const top = p.y < 274, y = top ? 235 : 296; return ``; }) .join(""); return ` ${trees}${apron}${line}${line}${line} ${apronEquipment()}${fingers}${building(399, 251, 259, 45)}${building(441, 244, 114, 16)} ТЕРМИНАЛ ${building(805, 259, 99, 36)}VIP ${building(239, 179, 45, 27)}${building(286, 312, 28, 55)}${building(350, 254, 23, 41)} ПЕРРОН A / C `; } function cardBays(v: MapView) { const items = [ ["ПОГОДА", v.piles?.weather ?? "—"], ["КОЛОДА", String(v.piles?.deck ?? "—")], ["СБРОС", v.piles?.discard ?? "—"], ]; return items .map( ( [label, value], i, ) => ` ${label}${value}`, ) .join(""); } export function airfield(v: MapView) { const pts = geometry(v.geometry); const markers = Object.entries(pts) .map(([id, p]) => { const m = v.markers[id], dest = v.destinations.has(id), canPick = m && v.pickable.has(m.key); const picked = !!m && m.key === v.selected; const title = m ? m.name + " · " + p.label : p.label + " · " + id; const action = canPick ? "pick" : dest ? "mapdest" : ""; const attr = action ? `role="button" tabindex="0" data-act="${action}" data-val="${canPick ? m.key : id}"` : ""; const label = p.label === "D" ? "СТАРТ" : p.label; return `${title} ${dest || picked ? '' : ""} ${ m ? ` ${m.caption}` : `${label}` }`; }) .join(""); return `${fieldDefs}${terrain(pts)}${v.geometry.runways.map((l) => runway(l, v.weather)).join("")}${markers}${cardBays(v)}`; }