'use client'; import { leaders } from '@/game/cards'; import type { GameView } from '@/game/engine'; import { Button } from './ui/button'; /** The parent owns timing and target availability; this editor only uses * publicly listed native leader identities and never tests private plans. */ export function TruthFutureBattleLeader({ game, target, leader, available, busy, onLeaderChange, onAsk }: { game: GameView; target: string; leader: string; available: boolean; busy: boolean; onLeaderChange: (leader: string) => void; onAsk: (target: string, leader: string) => void; }) { const respondent = target !== game.me ? game.players.find(player => player.id === target) : undefined; const nativeIds = new Set(respondent ? leaders(respondent.faction).map(item => item.id) : []); const nativeLeaders = game.allLeaders.filter(item => nativeIds.has(item.id) && item.faction === respondent?.faction); const uniqueLeaders = nativeLeaders.filter((item, index) => nativeLeaders.findIndex(other => other.id === item.id) === index); const selected = uniqueLeaders.find(item => item.id === leader); const disabled = busy || !available || !respondent; const blocked = disabled || !selected; return <> {!respondent &&

Choose another seated player for this question.

} {respondent && }
If you submit a battle plan later this turn, will you use {selected?.name ?? '[leader]'} in your first such battle?

If you submit no later battle plan this turn, there is no opportunity to use that leader.

; } /** Only the answering seat receives this receipt in its projection. */ export function FutureBattleLeaderPromises({ game }: {game: GameView}) { const promises = game.futureBattleLeaderPromises.filter(row => row.turn === game.turn && (row.status === 'waiting' || row.status === 'bound')); if (!promises.length) return null; return
{promises.map((row, index) =>

Your Truthtrance answer commits you to {row.answer ? 'use' : 'not use'}{' '} {game.allLeaders.find(leader => leader.id === row.leader)?.name ?? row.leader} in the first battle for which you submit a plan this turn. {row.status === 'waiting' ? ' If you submit no battle plan, there is no opportunity.' : ' This battle is the opportunity.'}

)}
; }