'use client'; import { useState } from 'react'; import type { Action, GameView } from '@/game/engine'; import { faction } from '@/game/catalog'; import { leaderStrengthLabel } from '@/game/cards'; import { CHEAP_HERO_TRAITOR } from '@/game/traitors'; import { LeaderInspector, type LeaderDisplayIdentity } from './leader-inspector'; import { Button } from './ui/button'; function identity(game: GameView, id: string): LeaderDisplayIdentity | null { if (id === CHEAP_HERO_TRAITOR) return { name: 'Cheap Hero / Heroine', factionName: 'Any faction', strength: 0, cheapHero: true }; const leader = game.allLeaders.find((l) => l.id === id); return leader ? { id: leader.id, name: leader.name, factionName: faction(leader.faction).name, strength: leaderStrengthLabel(leader) } : null; } function Card({ game, id, faceDancer = false }: { game: GameView; id: string; faceDancer?: boolean }) { const card = identity(game, id); return card ?
{card.name}
:

Card identity unavailable.

; } export function RihaniHistory({ game }: { game: GameView }) { const history = game.rihani?.history; const faceDancer = game.players.find(p => p.id === game.me)?.faction === 'tleilaxu'; if (!history?.length) return null; return
Your private Rihani inspections

A peek records the deck at that moment. Later draws can change who holds those cards.

{[...history].reverse().map((r) =>

Turn {r.turn}

{r.peeked.length > 0 && <>

Normal inspection — returned to the shuffled deck

{r.peeked.map((id) => )}} {r.drawn.length > 0 && <>

Separate skilled draw

{r.drawn.map((id) => )}} {r.kept &&

Kept {identity(game, r.kept)?.name}; revealed and returned {identity(game, r.given!)?.name}.

}
)}
; } export function RihaniChoice({ game, act, busy }: { game: GameView; act: (action: Action) => void; busy: boolean }) { const [kept, setKept] = useState(''), [given, setGiven] = useState(''); const pending = game.rihani?.pending; if (!pending || pending.owner !== game.me) return null; const blocked = busy || !!game.truthtrance; const faceDancer = game.players.find(p => p.id === game.me)?.faction === 'tleilaxu'; const cardName = faceDancer ? 'Face Dancer' : 'Traitor'; const oldCard = faceDancer ? 'unrevealed' : 'unused'; if (pending.stage === 'offer') return

You may draw two {cardName} Cards. Once drawn, you must keep one new card by publicly revealing and returning one {oldCard} card you already hold.

The other drawn card returns secretly. Your normal inspection, when available, has already returned its cards to the shuffled deck.

; return

Keep one newly drawn card and reveal one {oldCard} card from your old hand. The revealed card and the other new card return to the shuffled deck.

Keep one new {cardName} — private {pending.drawn?.map((id) =>
)}
Reveal and return one {oldCard} old {cardName} — public {pending.eligible?.map((id) =>
)}
; }