Support mixed Truthtrance questions in Richese auctions
Verify and publish checkpoint container / container (push) Canceled after 0s
Verify and publish checkpoint container / container (push) Canceled after 0s
This commit is contained in:
1 parent
1f3bc349ba
commit
6ce9a4b4a7
16 files changed
+504
-10
No files matched your search
@@ -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>;
|
||||
}
|
||||
Reference in new issue
Block a user