'use client'; import type { GameView } from '@/game/engine'; import type { MixedActionExpression } from '@/game/mixed-action-question'; import { MIXED_BID_MAX_DEPTH, MIXED_BID_MAX_LEAVES, parseBidActionClaim, type BidActionClaim } from '@/game/mixed-bid-question'; import { MixedActionFields, mixedActionInputError, type MixedActionConfig } from './mixed-action-fields'; import { Input } from './ui/input'; const config: MixedActionConfig = { prefix: 'mixed-bid', legend: 'Mixed current-fact / future ordinary-lot bid claim', actionLabel: 'ordinary-lot bid condition', actionTiming: 'Future bid · this ordinary lot', actionHelp: <>Count one future accepted native bid declaration after the answer and before this ordinary lot closes. Smaller bids do not add together. A qualifying declaration counts even if another player wins; this does not promise a purchase. If you win, the original payment rules still apply. Existing funding, Karama and prepaid ally aid rules still apply. Ordinary bank auctions only; optional modules and native special auctions are excluded. An unknown current fact uses the conservative future commitment that guarantees the whole answer. If no such value is available, the answer is I don’t know., fallbackError: 'Choose a current fact and a future ordinary-lot bid condition.', maxLeaves: MIXED_BID_MAX_LEAVES, maxDepth: MIXED_BID_MAX_DEPTH, newAction: () => ({ minimum: 1 }), parseAction: value => parseBidActionClaim(value), renderAction: ({ value, id, disabled, onChange }) => <> onChange({ ...value, minimum: event.currentTarget.valueAsNumber })} /> , }; const richeseConfig: MixedActionConfig = { ...config, prefix: 'mixed-richese-bid', legend: 'Mixed current-fact / future Richese-lot bid claim', actionLabel: 'Richese-lot bid condition', actionTiming: 'Future bid · this Richese lot', actionHelp: <>Count the one remaining accepted bid declaration after the answer in this Richese lot. A qualifying bid does not promise a win; normal funding, bidding and winning-payment rules still apply. In a Silent auction, submitted bid amounts stay private until the native reveal. An unknown current fact uses a future commitment that guarantees the whole answer; otherwise the answer is I don’t know., fallbackError: 'Choose a current fact and a future Richese-lot bid condition.', }; export function mixedBidInputError(value: unknown, game: GameView, target: string, variant: 'ordinary' | 'richese' = 'ordinary'): string | null { return mixedActionInputError(value, game, target, variant === 'richese' ? richeseConfig : config); } export function MixedBidFields(props: { value: MixedActionExpression; game: GameView; target: string; disabled: boolean; variant?: 'ordinary' | 'richese'; onChange: (expression: MixedActionExpression) => void; }) { if (props.variant === 'richese') { const method = props.game.richeseAuction?.method; const selected = method === 'silent' ? 'Silent' : 'Once Around'; return MixedActionFields({ ...props, config: { ...richeseConfig, legend: `${richeseConfig.legend} · Turn ${props.game.turn} · ${selected}` } }); } const lot = props.game.bidPromiseLot; return MixedActionFields({ ...props, config: lot ? { ...config, legend: `${config.legend} · Turn ${lot.turn} · Ordinary lot ${lot.lot}` } : config }); }