import React from 'react'; import type { MapNode, MapTheme } from '../../types/mapTypes'; import { buildPathString, buildSubPathString } from '../../data/mapData'; interface CurvyPathAndNodesProps { nodes: MapNode[]; activeNodeIndex: number; completions: Set; theme: MapTheme; showNodeNumbers: boolean; onNodeClick: (index: number) => void; hoveredNodeIndex: number | null; setHoveredNodeIndex: (index: number | null) => void; } export const CurvyPathAndNodes: React.FC = ({ nodes, activeNodeIndex, completions, theme, showNodeNumbers, onNodeClick, hoveredNodeIndex, setHoveredNodeIndex, }) => { const isDark = theme.id !== 'parchment'; // Find highest completed index in sequence to light the continuous trail const highestCompletedIdx = nodes.reduce((maxIdx, node, idx) => { return completions.has(node.id) ? Math.max(maxIdx, idx) : maxIdx; }, -1); const litIndex = Math.max(activeNodeIndex, highestCompletedIdx); const fullPathD = buildPathString(nodes); const litPathD = buildSubPathString(nodes, litIndex); const activeNode = activeNodeIndex >= 0 && activeNodeIndex < nodes.length ? nodes[activeNodeIndex] : null; // Render hand-drawn mini-landmarks at milestone waypoints (every 25th node) const renderMilestoneLandmark = (idx: number, isLit: boolean, isCompleted: boolean) => { // Do not draw a mini-landmark on the final node since the Huge Stone Tower is already there if (idx === nodes.length - 1) return null; const stroke = theme.pencilColor; const fillTone = isCompleted ? '#b91c1c' : isLit ? '#d97706' : isDark ? '#2c241b' : '#dfd1b4'; if (idx === 0) { // Waypoint 1: Explorer's Basecamp Tent return ( ); } const milestoneTier = Math.round((idx + 1) / 25) % 3; if (milestoneTier === 1) { // Node 25, 100...: Wayfarer's Campfire return ( ); } else if (milestoneTier === 2) { // Node 50, 125...: Stone Watchtower return ( ); } else { // Node 75, 150...: Mountain Arch Gatehouse return ( ); } }; return ( {/* 1. Base Unlit Surveyor's Trail (Double-Inked Cartographic Footpath) */} {/* 2. Illuminated Lit-Up Path (Sepia-Cased Alchemical Gold Leaf Trail) */} {litIndex > 0 && litPathD && ( {/* Warm Alchemical Aura */} {/* Dark Sepia Ink Casing so the gold leaf pops on light parchment */} {/* Burnished Gold Leaf Core */} {/* Fine Center Ink Highlight */} )} {/* 3. The Map Nodes */} {nodes.map((node, idx) => { const isCompleted = completions.has(node.id); const isLit = idx <= litIndex || isCompleted; const isActive = idx === activeNodeIndex; const isHovered = hoveredNodeIndex === idx; const isMilestone = (idx + 1) % 25 === 0 || idx === 0 || idx === nodes.length - 1; return ( { e.stopPropagation(); onNodeClick(idx); }} onMouseEnter={() => setHoveredNodeIndex(idx)} onMouseLeave={() => setHoveredNodeIndex(null)} > {/* Invisible larger hit target */} {/* Milestone Mini-Landmark Illustration */} {isMilestone && renderMilestoneLandmark(idx, isLit, isCompleted)} {/* UNLIT NODE STATE (Hand-Inked Cartographic Ring / X-Mark) */} {!isLit && !isCompleted && ( {isMilestone ? ( /* Cartographic X-Mark inside Milestone Ring */ ) : ( )} )} {/* LIT / COMPLETED NODE STATE (Crimson Wax Seal or Brass Astrolabe) */} {isLit && !isActive && ( {/* Outer Stamped Rim */} {/* Inner Embossed Wax Ring */} {/* Center Stamped Emblem */} {isMilestone ? ( ) : ( )} )} {/* ACTIVE CURRENT NODE STATE (Surveyor's Compass Beacon & Pennant) */} {isActive && ( {/* Outer Compass Ring */} {/* Explorer's Heraldic Pennant Flag */} )} {/* Hover Ink Caliper Ring */} {isHovered && !isActive && ( )} {/* Node Number Label */} {(showNodeNumbers || isMilestone || isHovered) && ( {node.id < 0 ? `P${idx + 1}` : node.id} )} ); })} {/* 4. Active Node Tattered Scroll Tooltip Banner on Canvas */} {activeNode && ( {/* Notched Parchment Scroll Body */} {/* Inner Scroll Rule */} {/* Pointer Tail */} WAYPOINT {activeNode.sequenceIndex + 1} OF {nodes.length} {activeNode.name.length > 22 ? activeNode.name.substring(0, 20) + '…' : activeNode.name} )} ); };