'use client'; import { useId } from 'react'; import { FACTIONS } from '@/game/catalog'; import type { TruthFact } from '@/game/truthtrance'; import { knowledgeFactInputError } from '@/game/truthtrance-knowledge'; import { Input } from '@/components/ui/input'; type KnowledgeFact = Extract; type NumericKnowledgeFact = Exclude; function isNumericKnowledgeFact(fact: KnowledgeFact): fact is NumericKnowledgeFact { return fact.kind !== 'prediction' || fact.field === 'turn'; } export function KnowledgeFactFields({ value, onChange, }: { value: KnowledgeFact; onChange: (fact: KnowledgeFact) => void; }) { const id = useId(); const isFaction = !isNumericKnowledgeFact(value); const numericValue = isNumericKnowledgeFact(value) ? value : null; const isTurn = numericValue?.kind === 'prediction' && numericValue.field === 'turn'; const min = isTurn ? 1 : numericValue?.kind === 'stormForecast' ? 1 : 0; const max = isTurn ? 10 : numericValue?.kind === 'stormForecast' ? 6 : 20; const invalid = knowledgeFactInputError(value); return ( <> {isFaction ? ( ) : numericValue && ( <> {(isTurn || numericValue.kind === 'stormDial' || numericValue.kind === 'stormForecast') && ( )}

This asks about an already recorded choice or a forecast the target currently knows. If no such value is available, the answer is I don’t know. Only the answer is published.

)} {isFaction &&

This asks about an already recorded faction choice. If no such value is available, the answer is I don’t know. Only the answer is published.

} {invalid && } ); }