'use client'; import { useId } from 'react'; import { Dialog as DialogPrimitive } from '@base-ui/react/dialog'; import { Eye, X } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Dialog, DialogClose, DialogDescription, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, } from '@/components/ui/dialog'; import type { SpiceCard } from '@/game/cards'; import { territory } from '@/game/board'; import { isDiscoverySpiceCardId, DISCOVERY_CARD_PLACEMENTS, } from '@/game/discoveries'; import { PHASE_HELP } from '@/game/reference'; /** Only the supplied visible face is read. No deck, discard pile or game is accepted. */ export type SpiceCardInspectorProps = { card: Readonly; context?: string; }; export function spiceCardTitle(card: Readonly): string { if ('territory' in card) return `${card.discovery ? 'Discovery · ' : ''}${territory(card.territory).name} · ${card.amount} spice · sector ${card.sector}`; if ('sandtrout' in card) return 'Sandtrout'; return `${card.greatMaker ? 'Great Maker' : 'Shai-Hulud'}${card.thumper ? ' · Thumper encounter' : ''}${card.suppressed ? ' · suppressed' : ''}`; } /** Original vector illustration, with no claim to reproduce a printed card face. */ function SpiceIllustration({ kind, }: { kind: 'territory' | 'worm' | 'sandtrout'; }) { const paint = `${useId()}-dune`; return ( ); } export function SpiceCardInspector({ card, context }: SpiceCardInspectorProps) { const kind = 'territory' in card ? 'territory' : 'sandtrout' in card ? 'sandtrout' : 'worm'; const title = spiceCardTitle(card); const faceName = 'territory' in card ? territory(card.territory).name : kind === 'worm' ? 'worm' in card && card.greatMaker ? 'Great Maker' : 'Shai-Hulud' : 'Sandtrout'; const placement = 'territory' in card && isDiscoverySpiceCardId(card.discovery) ? DISCOVERY_CARD_PLACEMENTS[card.discovery] : null; const description = kind === 'territory' ? placement ? `Destroy all previous spice and forces in the named territory, including Fremen, then place six spice in the indicated sector. Draw a random ${placement.type === 'hiereg' ? 'Hiereg' : 'Smuggler'} Discovery token and place it face down in ${territory(placement.territory).name}, sector ${placement.sector}. The storm can destroy the new spice.` : 'This spice blow names the territory, sector and base spice amount. The storm and card effects can change how much spice actually appears.' : kind === 'worm' ? 'worm' in card && card.greatMaker ? 'Resolve the normal worm destruction, then vote in storm order. A strict yes majority creates a Nexus; a tie does not. Fremen may afterward ride with any number of reserve forces, following storm and occupancy rules. Preventing Fremen survival in the devoured territory does not prevent this reserve ride.' : 'A Shai-Hulud encounter can consume forces and spice in the territory identified by the preceding card in its spice discard pile. Resolve protection, Nexus and riding decisions through the table.' : 'Sandtrout breaks existing alliances and waits for the next active drawn Shai-Hulud. It suppresses that encounter, then the immediate replacement determines whether a spice blow is doubled.'; return ( } aria-label={`Inspect spice card: ${title}${context ? ` · ${context}` : ''}`} >
Spice card inspection } >

{kind === 'territory' ? placement ? 'Discovery spice blow' : 'Spice blow' : kind === 'worm' ? 'Worm encounter' : 'Sandtrout'}

{faceName} {'territory' in card && (
Card amount
{card.amount} spice
Sector
{card.sector}
)} {'worm' in card && card.thumper && (

Thumper-created encounter

)} {'worm' in card && card.suppressed && (

Suppressed by Sandtrout

)}

Spice · gameplay guide

{context && (

{context}

)} {description}

Inspection does not draw a card or resolve an effect. Close this view to use the table’s phase controls.

{kind === 'territory' ? (

Spice cannot appear in the storm’s sector. A fresh blow remains open for Harvester before acceptance. The amount on this face is the card’s base value, not the total spice currently on the board.

) : kind === 'worm' ? (

First-turn drawn worms are ignored and later shuffled back. A worm suppressed by Sandtrout does not devour the preceding territory or create its own Nexus or Fremen ride. A normal encounter follows the table’s worm and alliance decisions.

) : ( <>

Territories drawn before the next active Shai-Hulud receive their usual spice. Sandtrout remains pending until that worm is suppressed, even across spice blows or turns.

If the immediate replacement is a territory, double its spice; Harvester may enhance that fresh blow again. If the replacement is another Shai-Hulud, resolve it normally and do not double a later territory. Spice still cannot appear in the storm.

)}

{PHASE_HELP[1]}

); }