'use client'; import { useState } from 'react'; import type { Action, GameView } from '@/game/engine'; import { faction, PHASES } from '@/game/catalog'; import type { TupileIntelligenceCategory } from '@/game/tupile-intelligence'; import { tupileIntelligenceCanAct, tupileIntelligenceChoice, } from '@/game/tupile-intelligence-options'; import { Button } from './ui/button'; type Props = { game: GameView; act: (action: Action) => void; busy: boolean }; export function TupileIntelligence({ game, act, busy }: Props) { if (!game.tupileIntelligence || game.tupileIntelligence.owner !== game.me) return null; return ; } function IntelligencePanel({ game, act, busy }: Props) { const offer = game.tupileIntelligence!; const [target, setTarget] = useState(''); const [category, setCategory] = useState('weapons'); const currentTarget = target || offer.targets.find((candidate) => !candidate.blocked)?.player || ''; const canAct = tupileIntelligenceCanAct(game); const choice = tupileIntelligenceChoice(game, currentTarget, category); const eligible = offer.targets.some((candidate) => !candidate.blocked); const disabled = busy || !canAct || !eligible; return (

Your Tupile intelligence

Once per faction, learn their current spice and one card count.

{offer.blocked &&

{offer.blocked}

} {!eligible && (

No faction is currently available for a request.

{!!offer.targets.length && (
    {offer.targets.map((candidate) => (
  • {faction(candidate.faction).name}: {candidate.blocked}
  • ))}
)}
)} {eligible && !offer.blocked && choice.blocked && (

{choice.blocked}

)} {!!offer.receipts.length && (

Your private observations

These are past observations. They do not update when a hand or balance changes.

    {[...offer.receipts].reverse().map((receipt) => (
  • {faction(receipt.faction).name}: {receipt.spice} spice, {receipt.count}{' '} {receipt.category === 'weapons' ? receipt.count === 1 ? 'weapon' : 'weapons' : receipt.count === 1 ? 'defense' : 'defenses'}. Turn {receipt.turn} · {PHASES[receipt.phase]}
  • ))}
)}
); }