Files
Dune/components/mixed-bid-fields.tsx
T
Quintine 6ce9a4b4a7
Verify and publish checkpoint container / container (push) Canceled after 0s
Support mixed Truthtrance questions in Richese auctions
2026-11-16 18:42:40 +11:00

70 lines
3.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'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<BidActionClaim> = {
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 }) => <>
<label htmlFor={`${id}-minimum`}>Minimum bid in spice</label>
<Input id={`${id}-minimum`} type="number" min={1} max={Number.MAX_SAFE_INTEGER} step={1} required disabled={disabled}
value={Number.isFinite(value.minimum) ? value.minimum : ''}
aria-invalid={!Number.isSafeInteger(value.minimum) || value.minimum < 1}
onChange={event => onChange({ ...value, minimum: event.currentTarget.valueAsNumber })} />
</>,
};
const richeseConfig: MixedActionConfig<BidActionClaim> = {
...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<BidActionClaim>;
game: GameView;
target: string;
disabled: boolean;
variant?: 'ordinary' | 'richese';
onChange: (expression: MixedActionExpression<BidActionClaim>) => 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 });
}