Support mixed Truthtrance questions in Richese auctions
Verify and publish checkpoint container / container (push) Canceled after 0s

This commit is contained in:
Quintine committed 2026-11-16 18:42:40 +11:00
1 parent 1f3bc349ba
commit 6ce9a4b4a7
16 files changed
+504 -10

No files matched your search

+2
View File
@@ -46,6 +46,7 @@ import { BribeExpressionPromises } from './bribe-expression-promises';
import { MixedBribePromises } from './mixed-bribe-promises';
import { MixedRevivalPromises } from './mixed-revival-promises';
import { MixedBidPromises } from './mixed-bid-promises';
import { MixedRicheseBidPromises } from './mixed-richese-bid-promises';
import { RevivalPromises } from './revival-promises';
import { RevivalExpressionPromises } from './revival-expression-promises';
import { LeaderRevivalPromises } from './leader-revival-promises';
@@ -2172,6 +2173,7 @@ export function GameTable({
{g.status === 'playing' && <PhaseBidPromises game={g} send={act} busy={busy} />}
{g.status === 'playing' && <EarlyRicheseBidPromises game={g} />}
{g.status === 'playing' && <MixedBidPromises game={g} send={act} busy={busy} />}
{g.status === 'playing' && <MixedRicheseBidPromises game={g} send={act} busy={busy} />}
{g.status === 'playing' && <MixedBattlePromises game={g} />}
{g.status === 'playing' && <FutureBattleLeaderPromises game={g} />}
{g.status === 'playing' && g.shortAllianceVictory && <p className="notice">
+23 -2
View File
@@ -31,16 +31,37 @@ const config: MixedActionConfig<BidActionClaim> = {
</>,
};
export function mixedBidInputError(value: unknown, game: GameView, target: string): string | null {
return mixedActionInputError(value, game, target, config);
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}` }
+49
View File
@@ -0,0 +1,49 @@
'use client';
import type { Action, GameView } from '@/game/engine';
import { truthQuestionText } from '@/game/truthtrance';
import { CHEAP_HERO_TRAITOR } from '@/game/traitors';
import { Button } from './ui/button';
/** Only the whole question, its answer and current status are projected. */
export function MixedRicheseBidPromises(props: { game: GameView; busy: boolean; send: (action: Action) => void }) {
const game = props.game;
const own = game.mixedRicheseBidPromises.filter(promise => promise.player === game.me);
if (!own.length) return null;
const leaderName = (id: string) => id === 'kwisatz' ? 'Kwisatz Haderach'
: id === CHEAP_HERO_TRAITOR ? 'Cheap Hero / Heroine' : game.allLeaders.find(leader => leader.id === id)?.name ?? id;
const auction = game.richeseAuction, guide = game.richeseBidPromiseGuide;
const live = !!auction && own.some(promise => promise.turn === game.turn && promise.event === auction.event &&
!promise.fulfilled && !promise.released);
const action = guide?.action, signature = action && JSON.stringify(action);
const isCurrentGuide = () => {
if (props.game !== game || !auction || game.richeseAuction !== auction ||
!guide || game.richeseBidPromiseGuide !== guide || !action || guide.action !== action ||
JSON.stringify(action) !== signature || action.type !== 'richeseBid' || action.event !== auction.event ||
typeof action.richeseBidPromiseId !== 'string') return false;
return own.some(promise => promise.id === action.richeseBidPromiseId && promise.turn === game.turn &&
promise.event === auction.event && !promise.fulfilled && !promise.released);
};
const canGuide = () => !props.busy && isCurrentGuide();
return <section className="notice space-y-3" aria-label="Your Truthtrance mixed Richese bid promises" id="mixed-richese-bid-promise-guidance">
<h3>Your mixed Richese bid promises</h3>
<ul>{own.map(promise => <li key={promise.id}>
Turn {promise.turn}: You answered {promise.answer ? 'Yes' : 'No'} to {truthQuestionText({ kind: 'mixedRicheseBid',
target: promise.player, turn: promise.turn, event: promise.event, mixed: promise.mixed }, leaderName,
id => game.combatLocations.find(location => location.id === id)?.name ?? id,
id => game.players.find(player => player.id === id)?.name ?? id)}
{promise.released ? ' Released: this whole commitment is no longer possible.'
: promise.fulfilled ? ' Fulfilled: this whole commitment is complete.' : ' This whole answer is binding for this lot.'}
</li>)}</ul>
<p>Current facts are evaluated when you answer; they do not require you to keep cards, spice or forces afterward.
AND requires every condition; OR requires at least one. No negates the whole expression.
The original bidding, funding and payment rules still apply. Silent bids remain private until the native reveal.</p>
{live && !guide && <p>Your remaining bid opportunity may still be ahead; the answer stays visible while the lot continues.</p>}
{live && isCurrentGuide() && <Button className="game-action min-h-11 whitespace-normal" data-testid="mixed-richese-bid-promise-guide"
disabled={!canGuide()} onClick={() => { if (canGuide() && action) props.send(action); }}>
{typeof action?.amount === 'number' && action.amount > 0
? `Bid ${action.amount} spice while honoring your answers`
: action?.amount === 0 ? 'Submit zero spice while honoring your answers' : 'Pass this lot while honoring your answers'}
</Button>}
</section>;
}
+19 -1
View File
@@ -159,7 +159,7 @@ export function Truthtrance({
g.players.find((p) => p.id !== me.id)!.id,
);
const [kind, setKind] = useState<
'fact' | 'freeform' | 'charity' | 'battlePlan' | 'futureBattleLeader' | 'shipment' | 'mixedShipment' | 'movement' | 'traitorCall' | 'bid' | 'phaseBid' | 'richeseBid' | 'earlyRicheseBid' | 'revival' | 'bribe' | 'pledgeAid' | 'alliance' | 'leaderRevival' | 'gholaLeader' | 'revivalExpression' | 'bribeExpression' | 'movementExpression' | 'mixedMovement' | 'mixedBribe' | 'mixedRevival' | 'mixedBid' | 'allianceExpression' | 'mixedAlliance' | 'mixedBattlePlan' | 'mixedTraitorCall' | 'travel' | 'turnActions'
'fact' | 'freeform' | 'charity' | 'battlePlan' | 'futureBattleLeader' | 'shipment' | 'mixedShipment' | 'movement' | 'traitorCall' | 'bid' | 'phaseBid' | 'richeseBid' | 'earlyRicheseBid' | 'revival' | 'bribe' | 'pledgeAid' | 'alliance' | 'leaderRevival' | 'gholaLeader' | 'revivalExpression' | 'bribeExpression' | 'movementExpression' | 'mixedMovement' | 'mixedBribe' | 'mixedRevival' | 'mixedBid' | 'mixedRicheseBid' | 'allianceExpression' | 'mixedAlliance' | 'mixedBattlePlan' | 'mixedTraitorCall' | 'travel' | 'turnActions'
>('fact');
const [revivalLeader, setRevivalLeader] = useState(g.allLeaders.find(leader =>
leader.faction === g.players.find(player => player.id === target)?.faction)?.id ?? '');
@@ -230,6 +230,7 @@ export function Truthtrance({
{ kind: 'action', action: { minimum: 4 } },
] });
const mixedBidError = mixedBidInputError(mixedBid, g, target);
const mixedRicheseBidError = mixedBidInputError(mixedBid, g, target, 'richese');
const [mixedBattle, setMixedBattle] = useState<MixedActionExpression<MixedBattleActionClaim>>({ kind: 'and', terms: [
{ kind: 'fact', fact: { kind: 'hand', name: 'Shield' } },
{ kind: 'action', action: { kind: 'dial', compare: 'eq', value: 0 } },
@@ -308,6 +309,7 @@ export function Truthtrance({
: kind === 'pledgeAid' ? { kind, target, turn: g.turn, phase: g.phase === 3 ? 3 : 5, ally: pledgeAlly, minimum: pledgeMinimum }
: kind === 'revival' ? { kind, target, ...revivalClaim }
: kind === 'mixedBid' ? { kind, target, turn: bidClaim.turn, lot: bidClaim.lot, mixed: mixedBid }
: kind === 'mixedRicheseBid' ? { kind, target, turn: g.turn, event: g.richeseAuction?.event ?? '', mixed: mixedBid }
: kind === 'bid' ? { kind, target, ...bidClaim }
: kind === 'phaseBid' ? { kind, target, ...phaseBidClaim }
: kind === 'earlyRicheseBid' ? { kind, target, turn:g.turn, minimum:bidMinimum }
@@ -432,6 +434,13 @@ export function Truthtrance({
{button(answer === 'unknown' ? 'I don’t know yet' : `Answer ${answer === 'yes' ? 'Yes' : 'No'}`, { type: 'truthAnswer', answer })}
</div>)}
</>
) : w.question!.kind === 'mixedRicheseBid' ? (
<>
<p className="notice">Answer the whole mixed question. Current facts freeze now; any remaining bid conditions concern your one future accepted declaration in this Richese lot. No keeps the whole expression false. Normal funding and payment rules apply, and Silent bids remain sealed until the native reveal. An unknown fact requires a commitment that guarantees the whole answer; otherwise choose I don’t know.</p>
{(g.truthMixedRicheseBidAnswers ?? []).map(answer => <div key={answer}>
{button(answer === 'unknown' ? 'I don’t know' : `Answer ${answer === 'yes' ? 'Yes' : 'No'}`, { type: 'truthAnswer', answer })}
</div>)}
</>
) : w.question!.kind === 'mixedBid' ? (
<>
<p className="notice">Answer the whole mixed question. Current facts freeze now; any remaining bid conditions concern future accepted declarations in this ordinary lot. No keeps the whole expression false. Passing, funding, Karama and the original winning payment still follow the auction rules. An unknown fact requires a commitment that guarantees the whole answer; otherwise choose I don’t know.</p>
@@ -712,6 +721,7 @@ export function Truthtrance({
<option value="phaseBid">Bind a bid this Bidding phase</option>
<option value="earlyRicheseBid">Bind a bid in the first Richese cache auction</option>
<option value="richeseBid">Bind a bid in this Richese lot</option>
<option value="mixedRicheseBid">Combine current facts and a Richese bid</option>
<option value="mixedBid">Combine current facts and ordinary bids</option>
<option value="traitorCall">Bind this battle’s Traitor declaration</option>
<option value="mixedTraitorCall">Combine current facts and this Traitor declaration</option>
@@ -782,6 +792,13 @@ export function Truthtrance({
{!g.truthMixedAllianceTargets.includes(target) && <p className="notice">Choose a supported participant in a quiet ordinary Nexus.</p>}
<p className="notice" aria-label="Public mixed alliance question preview">{mixedAllianceError ?? truthQuestionText(question, leaderName, locationName, name)}</p>
</>
) : kind === 'mixedRicheseBid' ? (
<>
<MixedBidFields value={mixedBid} game={g} target={target} variant="richese"
disabled={busy || !g.richeseAuction || !g.truthMixedRicheseBidTargets.includes(target)} onChange={setMixedBid} />
{!g.truthMixedRicheseBidTargets.includes(target) && <p className="notice">Choose a bidder with a remaining opportunity in this supported Richese Once Around or Silent auction.</p>}
<p className="notice" aria-label="Public mixed Richese bid question preview">{mixedRicheseBidError ?? truthQuestionText(question, leaderName, locationName, name)}</p>
</>
) : kind === 'mixedBid' ? (
<>
<MixedBidFields value={mixedBid} game={g} target={target}
@@ -1035,6 +1052,7 @@ export function Truthtrance({
(kind === 'pledgeAid' && (!!pledgeClaimInputError(pledgeMinimum) || !g.truthPledgeTargets.includes(target))) ||
(kind === 'revival' && (!!revivalClaimInputError(revivalClaim) || !g.truthRevivalTargets.includes(target))) ||
(kind === 'mixedBid' && (!!mixedBidError || !g.truthMixedBidTargets.includes(target))) ||
(kind === 'mixedRicheseBid' && (!!mixedRicheseBidError || !g.richeseAuction || !g.truthMixedRicheseBidTargets.includes(target))) ||
(kind === 'bid' && (!!bidClaimInputError(bidClaim) || !g.truthBidTargets.includes(target))) ||
(kind === 'earlyRicheseBid' && (!!richeseBidMinimumError(bidMinimum) || !g.truthEarlyRicheseBidTargets.includes(target))) ||
(kind === 'richeseBid' && (!!richeseBidMinimumError(bidMinimum) || !g.richeseAuction || !g.truthRicheseBidTargets.includes(target))) ||