File size: 15,347 Bytes
f0175ec
8800c81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f0175ec
 
8800c81
 
 
 
 
 
 
 
f0175ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8800c81
 
 
f0175ec
 
8800c81
 
 
 
f0175ec
 
8800c81
 
f0175ec
8800c81
 
 
 
 
 
f0175ec
8800c81
 
 
 
 
 
f0175ec
8800c81
 
f0175ec
8800c81
 
 
f0175ec
 
8800c81
 
f0175ec
8800c81
 
f0175ec
 
 
 
 
 
 
 
 
 
 
8800c81
 
 
 
f0175ec
8800c81
 
 
f0175ec
8800c81
 
 
f0175ec
 
 
8800c81
 
f0175ec
8800c81
 
 
 
 
 
 
 
 
 
 
f0175ec
 
8800c81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f0175ec
 
 
 
8800c81
 
 
f0175ec
 
 
8800c81
f0175ec
8800c81
 
 
 
f0175ec
 
8800c81
f0175ec
8800c81
f0175ec
 
 
 
 
 
 
 
 
 
8800c81
 
 
 
f0175ec
8800c81
 
f0175ec
8800c81
 
 
f0175ec
 
 
 
8800c81
f0175ec
8800c81
 
 
f0175ec
 
 
 
 
8800c81
f0175ec
 
 
 
 
 
 
 
 
8800c81
 
 
f0175ec
8800c81
 
 
 
 
f0175ec
8800c81
f0175ec
 
8800c81
 
 
 
 
f0175ec
8800c81
f0175ec
 
8800c81
 
f0175ec
8800c81
f0175ec
8800c81
 
 
 
f0175ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8800c81
 
f0175ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8800c81
f0175ec
8800c81
 
 
 
f0175ec
8800c81
 
 
 
 
 
f0175ec
 
 
8800c81
 
 
 
 
 
 
f0175ec
8800c81
f0175ec
 
 
 
 
 
 
 
 
 
 
 
 
 
8800c81
 
 
 
 
 
 
 
 
f0175ec
8800c81
 
f0175ec
8800c81
f0175ec
8800c81
f0175ec
 
 
 
 
 
 
 
 
 
8800c81
f0175ec
 
 
 
 
 
 
 
8800c81
f0175ec
8800c81
f0175ec
 
 
 
8800c81
 
 
f0175ec
8800c81
f0175ec
 
8800c81
f0175ec
8800c81
 
 
 
 
f0175ec
 
8800c81
f0175ec
 
 
8800c81
 
 
 
 
f0175ec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
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<number>;
  theme: MapTheme;
  showNodeNumbers: boolean;
  onNodeClick: (index: number) => void;
  hoveredNodeIndex: number | null;
  setHoveredNodeIndex: (index: number | null) => void;
}

export const CurvyPathAndNodes: React.FC<CurvyPathAndNodesProps> = ({
  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 (
        <g transform="translate(0, -10)" pointerEvents="none">
          <path
            d="M -11,4 L 0,-11 L 11,4 Z"
            fill={fillTone}
            stroke={stroke}
            strokeWidth="1.5"
            strokeLinejoin="round"
          />
          <path d="M -3,4 L 0,-3 L 3,4 Z" fill={stroke} />
          <line x1="0" y1="-11" x2="0" y2="-17" stroke={stroke} strokeWidth="1.3" />
          <polygon points="0,-17 7,-14 0,-11" fill={isCompleted ? '#991b1b' : '#d97706'} />
        </g>
      );
    }

    const milestoneTier = Math.round((idx + 1) / 25) % 3;
    if (milestoneTier === 1) {
      // Node 25, 100...: Wayfarer's Campfire
      return (
        <g transform="translate(0, -9)" pointerEvents="none">
          <line x1="-8" y1="3" x2="8" y2="-1" stroke={stroke} strokeWidth="2" strokeLinecap="round" />
          <line x1="-8" y1="-1" x2="8" y2="3" stroke={stroke} strokeWidth="2" strokeLinecap="round" />
          <path
            d="M -5,0 C -6,-7 -1,-9 0,-14 C 2,-9 6,-7 5,0 Z"
            fill={isLit || isCompleted ? '#ea580c' : fillTone}
            stroke={stroke}
            strokeWidth="1.2"
          />
        </g>
      );
    } else if (milestoneTier === 2) {
      // Node 50, 125...: Stone Watchtower
      return (
        <g transform="translate(0, -9)" pointerEvents="none">
          <path
            d="M -7,3 L -5,-12 L 5,-12 L 7,3 Z"
            fill={fillTone}
            stroke={stroke}
            strokeWidth="1.5"
          />
          <path
            d="M -7,-12 L -7,-16 L -3,-16 L -3,-12 L 3,-12 L 3,-16 L 7,-16 L 7,-12 Z"
            fill={fillTone}
            stroke={stroke}
            strokeWidth="1.3"
          />
        </g>
      );
    } else {
      // Node 75, 150...: Mountain Arch Gatehouse
      return (
        <g transform="translate(0, -9)" pointerEvents="none">
          <path
            d="M -9,3 L -9,-12 L 9,-12 L 9,3 L 4,3 L 4,-5 C 4,-9 -4,-9 -4,-5 L -4,3 Z"
            fill={fillTone}
            stroke={stroke}
            strokeWidth="1.5"
            strokeLinejoin="round"
          />
        </g>
      );
    }
  };

  return (
    <g id="curvy-path-nodes-layer">
      {/* 1. Base Unlit Surveyor's Trail (Double-Inked Cartographic Footpath) */}
      <g id="unlit-path" filter="url(#quillInk)">
        <path
          d={fullPathD}
          fill="none"
          stroke={theme.pencilShade}
          strokeWidth="4.2"
          strokeDasharray="2 8"
          strokeLinecap="round"
          strokeLinejoin="round"
          opacity={0.45}
        />
        <path
          d={fullPathD}
          fill="none"
          stroke={theme.pencilColor}
          strokeWidth="2.2"
          strokeDasharray="7 6"
          strokeLinecap="round"
          strokeLinejoin="round"
          opacity={0.85}
        />
      </g>

      {/* 2. Illuminated Lit-Up Path (Sepia-Cased Alchemical Gold Leaf Trail) */}
      {litIndex > 0 && litPathD && (
        <g id="lit-path">
          {/* Warm Alchemical Aura */}
          <path
            d={litPathD}
            fill="none"
            stroke="#d97706"
            strokeWidth="10"
            strokeLinecap="round"
            strokeLinejoin="round"
            opacity={0.28}
            filter="url(#goldenGlow)"
          />
          {/* Dark Sepia Ink Casing so the gold leaf pops on light parchment */}
          <path
            d={litPathD}
            fill="none"
            stroke={theme.pencilColor}
            strokeWidth="6.8"
            strokeLinecap="round"
            strokeLinejoin="round"
            opacity={0.85}
          />
          {/* Burnished Gold Leaf Core */}
          <path
            d={litPathD}
            fill="none"
            stroke="url(#goldPathGradient)"
            strokeWidth="4.2"
            strokeLinecap="round"
            strokeLinejoin="round"
          />
          {/* Fine Center Ink Highlight */}
          <path
            d={litPathD}
            fill="none"
            stroke="#fef3c7"
            strokeWidth="1.3"
            strokeDasharray="12 6"
            strokeLinecap="round"
            strokeLinejoin="round"
            opacity={0.8}
          />
        </g>
      )}

      {/* 3. The Map Nodes */}
      <g id="nodes-collection">
        {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 (
            <g
              key={node.id}
              id={`node-${node.id}`}
              transform={`translate(${node.x}, ${node.y})`}
              className="cursor-pointer transition-transform duration-200"
              onClick={(e) => {
                e.stopPropagation();
                onNodeClick(idx);
              }}
              onMouseEnter={() => setHoveredNodeIndex(idx)}
              onMouseLeave={() => setHoveredNodeIndex(null)}
            >
              {/* Invisible larger hit target */}
              <circle cx="0" cy="0" r="18" fill="transparent" />

              {/* Milestone Mini-Landmark Illustration */}
              {isMilestone && renderMilestoneLandmark(idx, isLit, isCompleted)}

              {/* UNLIT NODE STATE (Hand-Inked Cartographic Ring / X-Mark) */}
              {!isLit && !isCompleted && (
                <g>
                  <circle
                    cx="0.8"
                    cy="1.2"
                    r={isMilestone ? 7.5 : 4.5}
                    fill={theme.pencilShade}
                    opacity={0.35}
                  />
                  <circle
                    cx="0"
                    cy="0"
                    r={isMilestone ? 7 : 4.2}
                    fill={isDark ? '#28221b' : '#efe3c9'}
                    stroke={theme.pencilColor}
                    strokeWidth={isMilestone ? 2 : 1.5}
                  />
                  {isMilestone ? (
                    /* Cartographic X-Mark inside Milestone Ring */
                    <path
                      d="M -3,-3 L 3,3 M -3,3 L 3,-3"
                      stroke={theme.pencilColor}
                      strokeWidth="1.6"
                      strokeLinecap="round"
                    />
                  ) : (
                    <circle cx="0" cy="0" r="1.3" fill={theme.pencilColor} />
                  )}
                </g>
              )}

              {/* LIT / COMPLETED NODE STATE (Crimson Wax Seal or Brass Astrolabe) */}
              {isLit && !isActive && (
                <g filter="url(#nodeGlow)">
                  {/* Outer Stamped Rim */}
                  <circle
                    cx="0"
                    cy="0"
                    r={isMilestone ? 9 : 6}
                    fill={isCompleted ? 'url(#waxSealGradient)' : 'url(#brassNodeGradient)'}
                    stroke={theme.pencilColor}
                    strokeWidth="1.5"
                  />
                  {/* Inner Embossed Wax Ring */}
                  <circle
                    cx="0"
                    cy="0"
                    r={isMilestone ? 6.2 : 3.8}
                    fill="none"
                    stroke="#fef3c7"
                    strokeWidth="0.9"
                    opacity={0.75}
                  />
                  {/* Center Stamped Emblem */}
                  {isMilestone ? (
                    <polygon
                      points="0,-4.5 1.3,-1.3 4.5,0 1.3,1.3 0,4.5 -1.3,1.3 -4.5,0 -1.3,-1.3"
                      fill="#fef3c7"
                    />
                  ) : (
                    <circle cx="0" cy="0" r="1.6" fill="#fef3c7" />
                  )}
                </g>
              )}

              {/* ACTIVE CURRENT NODE STATE (Surveyor's Compass Beacon & Pennant) */}
              {isActive && (
                <g id="active-node-beacon">
                  <circle
                    cx="0"
                    cy="0"
                    r="13"
                    fill="none"
                    stroke="#b45309"
                    strokeWidth="2"
                    className="beacon-wave"
                  />
                  <circle
                    cx="0"
                    cy="0"
                    r="13"
                    fill="none"
                    stroke="#d97706"
                    strokeWidth="1.5"
                    className="beacon-wave-delayed"
                  />
                  <circle cx="0" cy="0" r="22" fill="url(#beaconGlow)" />

                  {/* Outer Compass Ring */}
                  <circle
                    cx="0"
                    cy="0"
                    r="9.5"
                    fill={isCompleted ? 'url(#waxSealGradient)' : 'url(#brassNodeGradient)'}
                    stroke={theme.pencilColor}
                    strokeWidth="2.2"
                    filter="url(#nodeGlow)"
                  />
                  <circle
                    cx="0"
                    cy="0"
                    r="6.5"
                    fill="none"
                    stroke="#fef3c7"
                    strokeWidth="1"
                  />
                  <polygon
                    points="0,-4.5 1.4,-1.4 4.5,0 1.4,1.4 0,4.5 -1.4,1.4 -4.5,0 -1.4,-1.4"
                    fill="#fef3c7"
                  />

                  {/* Explorer's Heraldic Pennant Flag */}
                  <g transform="translate(0, -19)" filter="url(#nodeGlow)">
                    <line
                      x1="0"
                      y1="-12"
                      x2="0"
                      y2="11"
                      stroke={theme.pencilColor}
                      strokeWidth="2.2"
                      strokeLinecap="round"
                    />
                    <path
                      d="M 0,-12 L 15,-7 L 11,-3 L 15,1 L 0,-2 Z"
                      fill={isCompleted ? '#991b1b' : '#b45309'}
                      stroke="#fef3c7"
                      strokeWidth="1.2"
                      strokeLinejoin="round"
                    />
                    <circle cx="0" cy="-13" r="2" fill="#fbbf24" stroke={theme.pencilColor} strokeWidth="0.9" />
                  </g>
                </g>
              )}

              {/* Hover Ink Caliper Ring */}
              {isHovered && !isActive && (
                <circle
                  cx="0"
                  cy="0"
                  r="13"
                  fill="none"
                  stroke={isCompleted ? '#991b1b' : '#b45309'}
                  strokeWidth="1.8"
                  strokeDasharray="4 3"
                />
              )}

              {/* Node Number Label */}
              {(showNodeNumbers || isMilestone || isHovered) && (
                <text
                  x="0"
                  y={isMilestone ? 19 : -10}
                  textAnchor="middle"
                  fill={
                    isCompleted
                      ? isDark
                        ? '#fca5a5'
                        : '#7f1d1d'
                      : isLit
                        ? isDark
                          ? '#fcd34d'
                          : '#92400e'
                        : theme.pencilColor
                  }
                  className={`font-pencil font-bold select-none ${isMilestone ? 'text-[12px]' : 'text-[10px]'
                    }`}
                  opacity={isLit ? 1 : 0.78}
                >
                  {node.id < 0 ? `P${idx + 1}` : node.id}
                </text>
              )}
            </g>
          );
        })}
      </g>

      {/* 4. Active Node Tattered Scroll Tooltip Banner on Canvas */}
      {activeNode && (
        <g
          transform={`translate(${activeNode.x}, ${activeNode.y - 46})`}
          className="pointer-events-none select-none transition-all duration-300"
          filter="url(#nodeGlow)"
        >
          {/* Notched Parchment Scroll Body */}
          <path
            d="M -88,-24
               Q 0,-28 88,-24
               L 81,-7
               L 88,10
               Q 0,14 -88,10
               L -81,-7 Z"
            fill={isDark ? '#221b14' : '#f4e8cf'}
            stroke={theme.pencilColor}
            strokeWidth="1.8"
            strokeLinejoin="round"
          />
          {/* Inner Scroll Rule */}
          <path
            d="M -78,-20 Q 0,-24 78,-20 M -78,6 Q 0,10 78,6"
            fill="none"
            stroke={theme.pencilShade}
            strokeWidth="0.8"
          />
          {/* Pointer Tail */}
          <polygon
            points="-6,10 6,10 0,17"
            fill={isDark ? '#221b14' : '#f4e8cf'}
            stroke={theme.pencilColor}
            strokeWidth="1.6"
          />
          <text
            x="0"
            y="-9"
            textAnchor="middle"
            fill={isDark ? '#fbbf24' : '#7c2d12'}
            className="font-cinzel font-bold text-[11px] tracking-wider"
          >
            WAYPOINT {activeNode.sequenceIndex + 1} OF {nodes.length}
          </text>
          <text
            x="0"
            y="4"
            textAnchor="middle"
            fill={isDark ? '#f4ebd9' : '#2c1d11'}
            className="font-garamond italic font-bold text-[12px]"
          >
            {activeNode.name.length > 22
              ? activeNode.name.substring(0, 20) + '…'
              : activeNode.name}
          </text>
        </g>
      )}
    </g>
  );
};