import type { MapNode, MountainPeak, RiverPath, ForestPatch, BiomeType, TreeData } from '../types/mapTypes'; // Map Dimensions export const MAP_WIDTH = 2600; export const MAP_HEIGHT = 1500; // Region Names & Biomes across percentage of journey const REGION_SEGMENTS: { tMax: number; name: string; biome: BiomeType }[] = [ { tMax: 0.15, name: 'The Whispering Coast & Lowlands', biome: 'coast' }, { tMax: 0.32, name: 'The Elderwood Deep Forest', biome: 'forest' }, { tMax: 0.48, name: 'River Elden & The Twin Fords', biome: 'river' }, { tMax: 0.68, name: 'The Dragon Tooth Mountains & Passes', biome: 'mountain' }, { tMax: 0.83, name: 'The Misty Glade & Highland Woods', biome: 'forest' }, { tMax: 0.93, name: 'The Roaring Gorge & Cataracts', biome: 'river' }, { tMax: 1.00, name: 'The Sunstone Peaks & Ancient Citadel', biome: 'ancient_ruins' }, ]; const LORE_SNIPPETS = [ 'Pencil marks still visible from the cartographer’s first survey.', 'A calm breeze sweeps through the grass, carrying the scent of pine.', 'Wooden planks creak underfoot as the river roars below.', 'Craggy pencil hatchings reveal steep, unforgiving granite slopes.', 'Ancient roots break through the worn gravel pathway.', 'The sound of rushing water echoes across the canyon walls.', 'A solitary stone marker inscribed with early explorer symbols.', 'Golden light filters softly through the sketched canopy.', 'Distant mountain ridges frame the expanding horizon.', 'A tranquil haven where wanderers rest before the mountain climb.', ]; // Generate Nodes along a graceful, curving adventure path for any sequence length export function generateMapNodes(sequence: number[] = [], titles: Record = {}): MapNode[] { const nodes: MapNode[] = []; const count = sequence.length > 0 ? sequence.length : 150; // Control anchor points that shape the grand adventure const waypoints = [ { t: 0.00, x: 220, y: 1320, elev: 10 }, // Start harbor { t: 0.08, x: 380, y: 1140, elev: 45 }, // Coastal plains { t: 0.16, x: 580, y: 980, elev: 120 }, // First Forest entry { t: 0.24, x: 820, y: 1120, elev: 90 }, // Forest clearing loop { t: 0.32, x: 940, y: 860, elev: 180 }, // River crossing 1 { t: 0.40, x: 720, y: 640, elev: 320 }, // Valley between rivers { t: 0.48, x: 1050, y: 520, elev: 580 }, // Mountain base approach { t: 0.56, x: 1320, y: 720, elev: 890 }, // Mountain Gorge pass { t: 0.64, x: 1540, y: 480, elev: 1250 }, // Dragon Tooth peak pass { t: 0.72, x: 1780, y: 680, elev: 920 }, // Highland forest descent { t: 0.80, x: 1980, y: 920, elev: 460 }, // Upper river rapids loop { t: 0.88, x: 2220, y: 760, elev: 750 }, // Ancient ruins plateau { t: 0.94, x: 2180, y: 480, elev: 1180 }, // Ascent to citadel { t: 1.00, x: 2420, y: 240, elev: 1620 }, // Final Pinnacle ]; for (let i = 0; i < count; i++) { const t = count > 1 ? i / (count - 1) : 0; // Find waypoint segment let seg = 0; while (seg < waypoints.length - 2 && waypoints[seg + 1].t < t) { seg++; } const p0 = waypoints[Math.max(0, seg - 1)]; const p1 = waypoints[seg]; const p2 = waypoints[Math.min(waypoints.length - 1, seg + 1)]; const p3 = waypoints[Math.min(waypoints.length - 1, seg + 2)]; const span = p2.t - p1.t || 0.001; const localT = (t - p1.t) / span; // Catmull-Rom spline interpolation const tt = localT; const tt2 = tt * tt; const tt3 = tt2 * tt; const q0 = -0.5 * tt3 + tt2 - 0.5 * tt; const q1 = 1.5 * tt3 - 2.5 * tt2 + 1.0; const q2 = -1.5 * tt3 + 2.0 * tt2 + 0.5 * tt; const q3 = 0.5 * tt3 - 0.5 * tt2; let x = q0 * p0.x + q1 * p1.x + q2 * p2.x + q3 * p3.x; let y = q0 * p0.y + q1 * p1.y + q2 * p2.y + q3 * p3.y; // Organic gentle pencil wander/jitter so it looks authentically hand-mapped const wanderX = Math.sin(i * 0.45) * 14 + Math.cos(i * 0.9) * 8; const wanderY = Math.cos(i * 0.4) * 14 + Math.sin(i * 0.85) * 8; x = Math.round(x + wanderX); y = Math.round(y + wanderY); const elev = Math.round(p1.elev + localT * (p2.elev - p1.elev) + Math.sin(i * 0.5) * 15); // Determine region and biome by progression t const regionObj = REGION_SEGMENTS.find(r => t <= r.tMax) || REGION_SEGMENTS[REGION_SEGMENTS.length - 1]; const probId = sequence.length > 0 ? sequence[i] : i + 1; const syncedTitle = titles[probId]; const nodeName = syncedTitle || (probId < 0 ? `Custom Challenge ${i + 1}` : `LeetCode #${probId}`); const lore = LORE_SNIPPETS[i % LORE_SNIPPETS.length]; nodes.push({ id: probId, sequenceIndex: i, x, y, name: nodeName, biome: regionObj.biome, regionName: regionObj.name, elevation: Math.max(10, elev), lore, }); } return nodes; } // Pre-generated mountain peaks for realistic cartographic hand-drawn look export const MOUNTAIN_RANGES: MountainPeak[] = [ // 1. WESTERN CRAGS & MIST MOUNTAINS (Top Left) { id: 'wm-bg1', x: 380, y: 310, size: 70, height: 85, ridgeShift: -4, hasSnow: false, layer: 0, elevation: 840, rangeName: 'Western Crags' }, { id: 'wm-bg2', x: 490, y: 280, size: 85, height: 105, ridgeShift: 6, hasSnow: true, layer: 0, elevation: 1120, name: 'Peak of the North Wind', rangeName: 'Western Crags' }, { id: 'wm-bg3', x: 620, y: 300, size: 75, height: 95, ridgeShift: -3, hasSnow: false, layer: 0, elevation: 960, rangeName: 'Western Crags' }, { id: 'wm-bg4', x: 730, y: 320, size: 65, height: 80, ridgeShift: 4, hasSnow: false, layer: 0, elevation: 780, rangeName: 'Western Crags' }, { id: 'm1', x: 430, y: 375, size: 80, height: 105, ridgeShift: 5, hasSnow: true, elevation: 1240, name: 'Crag of the Mist', rangeName: 'Western Crags' }, { id: 'm2', x: 530, y: 345, size: 95, height: 125, ridgeShift: -7, hasSnow: true, elevation: 1480, name: 'Peak of Solitude', rangeName: 'Western Crags' }, { id: 'm3', x: 630, y: 365, size: 85, height: 110, ridgeShift: 3, hasSnow: true, elevation: 1310, name: 'Shadowhorn', rangeName: 'Western Crags' }, { id: 'm4', x: 720, y: 385, size: 70, height: 90, ridgeShift: -4, hasSnow: false, elevation: 990, rangeName: 'Western Crags' }, { id: 'm5', x: 370, y: 430, size: 55, height: 65, ridgeShift: 4, hasSnow: false, layer: 2, elevation: 620, rangeName: 'Western Crags' }, { id: 'm6', x: 470, y: 425, size: 68, height: 80, ridgeShift: -3, hasSnow: false, layer: 2, elevation: 760, name: 'Gullwing Bluff', rangeName: 'Western Crags' }, { id: 'm6b', x: 575, y: 420, size: 72, height: 88, ridgeShift: 3, hasSnow: false, layer: 2, elevation: 850, rangeName: 'Western Crags' }, { id: 'm6c', x: 670, y: 435, size: 58, height: 70, ridgeShift: -2, hasSnow: false, layer: 2, elevation: 680, rangeName: 'Western Crags' }, // 2. CENTRAL DRAGON'S TOOTH ALPINE RANGE (Center North through Middle) { id: 'dt-bg1', x: 1130, y: 260, size: 90, height: 120, ridgeShift: -6, hasSnow: true, layer: 0, elevation: 1850, rangeName: "Dragon's Tooth Range" }, { id: 'dt-bg2', x: 1250, y: 225, size: 115, height: 150, ridgeShift: 8, hasSnow: true, layer: 0, elevation: 2180, name: 'Crown of the North', rangeName: "Dragon's Tooth Range" }, { id: 'dt-bg3', x: 1380, y: 210, size: 130, height: 175, ridgeShift: -10, hasSnow: true, layer: 0, elevation: 2450, name: 'Apex of Clouds', rangeName: "Dragon's Tooth Range" }, { id: 'dt-bg4', x: 1510, y: 240, size: 110, height: 145, ridgeShift: 7, hasSnow: true, layer: 0, elevation: 2020, rangeName: "Dragon's Tooth Range" }, { id: 'dt-bg5', x: 1640, y: 280, size: 90, height: 115, ridgeShift: -5, hasSnow: true, layer: 0, elevation: 1690, rangeName: "Dragon's Tooth Range" }, { id: 'm7', x: 1190, y: 325, size: 105, height: 140, ridgeShift: -8, hasSnow: true, elevation: 1980, name: "The Dragon's Crest", rangeName: "Dragon's Tooth Range" }, { id: 'm8', x: 1310, y: 295, size: 125, height: 165, ridgeShift: 10, hasSnow: true, elevation: 2360, name: 'Frostcrag Pinnacle', rangeName: "Dragon's Tooth Range" }, { id: 'm9', x: 1435, y: 320, size: 115, height: 150, ridgeShift: -6, hasSnow: true, elevation: 2120, name: 'Thunderhorn Peak', rangeName: "Dragon's Tooth Range" }, { id: 'm10', x: 1560, y: 355, size: 98, height: 125, ridgeShift: 7, hasSnow: true, elevation: 1780, name: 'Screaming Ridge', rangeName: "Dragon's Tooth Range" }, { id: 'm10b', x: 1680, y: 375, size: 85, height: 105, ridgeShift: -4, hasSnow: false, elevation: 1420, rangeName: "Dragon's Tooth Range" }, { id: 'm11', x: 1260, y: 415, size: 90, height: 115, ridgeShift: -5, hasSnow: true, elevation: 1560, name: 'Ironhorn Needle', rangeName: "Dragon's Tooth Range" }, { id: 'm12', x: 1375, y: 405, size: 100, height: 130, ridgeShift: 6, hasSnow: true, elevation: 1720, name: 'Shadowcrevasse Crag', rangeName: "Dragon's Tooth Range" }, { id: 'm13', x: 1490, y: 440, size: 88, height: 110, ridgeShift: -4, hasSnow: true, elevation: 1490, rangeName: "Dragon's Tooth Range" }, { id: 'm14', x: 1610, y: 435, size: 82, height: 100, ridgeShift: 5, hasSnow: false, elevation: 1320, rangeName: "Dragon's Tooth Range" }, { id: 'm15', x: 1160, y: 590, size: 80, height: 100, ridgeShift: 5, hasSnow: false, elevation: 1180, name: "Wanderer's Bluff", rangeName: 'Mid-Pass Gorge' }, { id: 'm16', x: 1390, y: 610, size: 90, height: 115, ridgeShift: -6, hasSnow: true, elevation: 1390, name: 'Eagle Eye Ridge', rangeName: 'Mid-Pass Gorge' }, { id: 'm17', x: 1510, y: 585, size: 95, height: 120, ridgeShift: 5, hasSnow: true, elevation: 1520, name: 'Razorback Spine', rangeName: 'Mid-Pass Gorge' }, { id: 'm18', x: 1630, y: 565, size: 85, height: 105, ridgeShift: -4, hasSnow: false, elevation: 1280, rangeName: 'Mid-Pass Gorge' }, { id: 'm18b', x: 1740, y: 580, size: 75, height: 90, ridgeShift: 3, hasSnow: false, elevation: 1050, rangeName: 'Mid-Pass Gorge' }, // 3. EASTERN SUNSTONE & CITADEL HIGHLAND RANGE (East & Citadel) { id: 'es-bg1', x: 1980, y: 310, size: 88, height: 115, ridgeShift: -5, hasSnow: true, layer: 0, elevation: 1650, rangeName: 'Sunstone Highlands' }, { id: 'es-bg2', x: 2110, y: 245, size: 105, height: 140, ridgeShift: 6, hasSnow: true, layer: 0, elevation: 1980, name: 'Sun Pillar', rangeName: 'Sunstone Highlands' }, { id: 'es-bg3', x: 2260, y: 160, size: 135, height: 180, ridgeShift: -8, hasSnow: true, layer: 0, elevation: 2580, name: 'Crown of the Heavens', rangeName: 'Sunstone Highlands' }, { id: 'es-bg4', x: 2410, y: 210, size: 115, height: 150, ridgeShift: 7, hasSnow: true, layer: 0, elevation: 2240, rangeName: 'Sunstone Highlands' }, { id: 'm19', x: 2040, y: 375, size: 98, height: 128, ridgeShift: 6, hasSnow: true, elevation: 1720, name: 'Sunstone Spire', rangeName: 'Sunstone Highlands' }, { id: 'm20', x: 2170, y: 315, size: 115, height: 150, ridgeShift: -7, hasSnow: true, elevation: 2080, name: 'Sanctuary Peak', rangeName: 'Sunstone Highlands' }, { id: 'm21', x: 2310, y: 220, size: 130, height: 170, ridgeShift: 8, hasSnow: true, elevation: 2390, name: 'Pinnacle of the Ancients', rangeName: 'Sunstone Highlands' }, { id: 'm22', x: 2440, y: 360, size: 90, height: 115, ridgeShift: -5, hasSnow: true, elevation: 1610, name: 'Falcon Perch', rangeName: 'Sunstone Highlands' }, { id: 'm23', x: 2260, y: 405, size: 82, height: 98, ridgeShift: 4, hasSnow: false, elevation: 1250, name: 'Altar Crag', rangeName: 'Sunstone Highlands' }, { id: 'm24', x: 2380, y: 420, size: 76, height: 88, ridgeShift: -3, hasSnow: false, elevation: 1120, rangeName: 'Sunstone Highlands' }, { id: 'm25', x: 2140, y: 450, size: 70, height: 80, ridgeShift: 3, hasSnow: false, elevation: 980, rangeName: 'Sunstone Highlands' }, ]; // Meandering Hand-drawn Rivers export const RIVERS: RiverPath[] = [ { id: 'river-elden', name: 'River Elden', d: 'M 1340,290 C 1310,380 1260,460 1210,540 C 1140,640 1020,700 960,820 C 900,940 930,1060 880,1180 C 840,1280 760,1360 690,1480', width: 14, hasBridges: [ { x: 945, y: 855, angle: -35 }, { x: 890, y: 1160, angle: 25 }, ] }, { id: 'river-silver', name: 'Silver Meander', d: 'M 580,410 C 650,490 730,550 780,660 C 830,760 910,810 960,820', width: 8, hasBridges: [ { x: 740, y: 620, angle: 45 } ] }, { id: 'river-cataract', name: 'Highland Torrent', d: 'M 2150,320 C 2100,450 2050,600 2020,760 C 1990,920 1920,1050 1840,1180 C 1760,1310 1710,1420 1660,1500', width: 11, hasBridges: [ { x: 2010, y: 810, angle: -20 } ] } ]; // Forest patches with realistic hand-drawn pencil trees export const FOREST_ZONES: ForestPatch[] = [ { id: 'f1', name: 'The Whispering Pines', cx: 580, cy: 1040, rx: 230, ry: 160, treeCount: 42, trees: generateTrees(580, 1040, 210, 140, 42, 'pines'), }, { id: 'f2', name: 'Elderwood Deep', cx: 820, cy: 1140, rx: 250, ry: 180, treeCount: 52, trees: generateTrees(820, 1140, 230, 160, 52, 'oaks'), }, { id: 'f3', name: 'Mistwood Valley', cx: 860, cy: 620, rx: 190, ry: 140, treeCount: 36, trees: generateTrees(860, 620, 170, 120, 36, 'willows'), }, { id: 'f4', name: 'Highland Spruces', cx: 1760, cy: 740, rx: 210, ry: 155, treeCount: 38, trees: generateTrees(1760, 740, 190, 135, 38, 'highland_spruce'), }, { id: 'f5', name: 'Verdant Basin', cx: 1960, cy: 980, rx: 200, ry: 150, treeCount: 38, trees: generateTrees(1960, 980, 180, 130, 38, 'mixed'), }, { id: 'f6', name: 'Shadowglen Copse', cx: 390, cy: 690, rx: 140, ry: 100, treeCount: 22, trees: generateTrees(390, 690, 120, 80, 22, 'pines'), }, { id: 'f7', name: 'Sunstone Grove', cx: 2360, cy: 580, rx: 150, ry: 110, treeCount: 24, trees: generateTrees(2360, 580, 130, 90, 24, 'mixed'), }, ]; function generateTrees( cx: number, cy: number, rx: number, ry: number, count: number, forestKind: 'pines' | 'oaks' | 'willows' | 'highland_spruce' | 'mixed' ): TreeData[] { const trees: TreeData[] = []; for (let i = 0; i < count; i++) { const angle = i * 2.399963 + Math.sin(i * 1.7) * 0.4; const r = Math.pow((i + 0.5) / count, 0.65); const offsetX = (Math.sin(i * 4.3 + cx) * 14); const offsetY = (Math.cos(i * 3.9 + cy) * 12); const x = Math.round(cx + rx * r * Math.cos(angle) + offsetX); const y = Math.round(cy + ry * r * Math.sin(angle) + offsetY); let scale = 0.85 + (i % 4) * 0.1; if (i === 0 || i === 5) scale = 1.35; else if (i % 7 === 0) scale = 0.68; let type: TreeData['type'] = 'pine'; if (forestKind === 'pines') { type = i % 6 === 0 ? 'birch' : 'pine'; } else if (forestKind === 'oaks') { if (i === 0 || i === 5) type = 'ancient_oak'; else if (i % 5 === 0) type = 'birch'; else type = 'oak'; } else if (forestKind === 'willows') { if (i % 3 === 0) type = 'willow'; else if (i % 4 === 0) type = 'birch'; else type = 'oak'; } else if (forestKind === 'highland_spruce') { type = i % 5 === 0 ? 'pine' : 'spruce'; } else { const mod = i % 5; if (mod === 0) type = 'ancient_oak'; else if (mod === 1) type = 'pine'; else if (mod === 2) type = 'oak'; else if (mod === 3) type = 'spruce'; else type = 'birch'; } trees.push({ x, y, scale, type, seed: Math.round(cx * 7 + cy * 11 + i * 31), }); } return trees; } // Generate smooth SVG Path string through all nodes export function buildPathString(nodes: MapNode[]): string { if (nodes.length === 0) return ''; if (nodes.length === 1) return `M ${nodes[0].x},${nodes[0].y}`; let d = `M ${nodes[0].x},${nodes[0].y}`; for (let i = 0; i < nodes.length - 1; i++) { const curr = nodes[i]; const next = nodes[i + 1]; const mx = (curr.x + next.x) / 2; const my = (curr.y + next.y) / 2; if (i === 0) { d += ` Q ${curr.x},${curr.y} ${mx},${my}`; } else { const prev = nodes[i - 1]; const ctrlX = curr.x + (next.x - prev.x) * 0.18; const ctrlY = curr.y + (next.y - prev.y) * 0.18; d += ` S ${ctrlX},${ctrlY} ${next.x},${next.y}`; } } return d; } // Generate partial SVG path up to active illuminated node index export function buildSubPathString(nodes: MapNode[], activeIndex: number): string { if (activeIndex <= 0 || nodes.length === 0) return ''; const subset = nodes.slice(0, activeIndex + 1); return buildPathString(subset); }