Support phase-wide bidding across all auctions
Verify and publish checkpoint container / container (push) Successful in 12m14s
Verify and publish checkpoint container / container (push) Successful in 12m14s
This commit is contained in:
1 parent
12060f3112
commit
38f1684e03
17 files changed
+1070
-18
No files matched your search
@@ -0,0 +1,67 @@
|
||||
'use client';
|
||||
|
||||
import type { Action, GameView } from '@/game/engine';
|
||||
import { phaseAnyBidClaimText } from '@/game/phase-any-bid-promises';
|
||||
import { Button } from './ui/button';
|
||||
|
||||
type Props = { game: GameView; busy: boolean; send: (action: Action) => void };
|
||||
|
||||
/** Use only the exact server-selected declaration for the live source and owner. */
|
||||
export function PhaseAnyBidGuideButton(props: Props) {
|
||||
const game = props.game, guide = game.phaseAnyBidGuide;
|
||||
if (!guide) return null;
|
||||
const actor = game.me, turn = game.turn, action = guide.action;
|
||||
const signature = JSON.stringify(action), ordinary = game.auction, special = game.richeseAuction;
|
||||
const ordinarySignature = ordinary && JSON.stringify([ordinary.bid, ordinary.bidder, ordinary.active, ordinary.remaining]);
|
||||
const specialSignature = special && JSON.stringify([special.event, special.method, special.active,
|
||||
special.bid, special.bidder, special.submitted, special.ownBid]);
|
||||
const canAct = () => {
|
||||
const current = props.game, me = current.players.find(player => player.id === actor);
|
||||
if (props.busy || current !== game || current.me !== actor || current.turn !== turn ||
|
||||
current.status !== 'playing' || current.phase !== 3 || current.phaseAnyBidGuide !== guide ||
|
||||
guide.action !== action || JSON.stringify(action) !== signature || !me || me.autopilot ||
|
||||
current.truthtrance || current.response || current.decision || current.phaseOpening ||
|
||||
current.automaticContinuationPending || current.roomControl?.paused || current.roomControl?.closed ||
|
||||
typeof action.phaseAnyBidPromiseEvent !== 'string' ||
|
||||
!current.phaseAnyBidPromises.some(promise => promise.event === action.phaseAnyBidPromiseEvent &&
|
||||
promise.player === actor && promise.turn === turn && !promise.fulfilled && !promise.released)) return false;
|
||||
if (action.type === 'bid' || action.type === 'passBid')
|
||||
return !!ordinary && current.auction === ordinary && ordinary.active === actor &&
|
||||
JSON.stringify([ordinary.bid, ordinary.bidder, ordinary.active, ordinary.remaining]) === ordinarySignature &&
|
||||
typeof action.phaseAnyBidLot === 'number' && current.bidPromiseLot?.turn === turn &&
|
||||
current.bidPromiseLot.lot === action.phaseAnyBidLot;
|
||||
if (action.type !== 'richeseBid' || !special || current.richeseAuction !== special ||
|
||||
special.event !== action.event || special.event !== action.phaseAnyBidLotEvent ||
|
||||
JSON.stringify([special.event, special.method, special.active, special.bid, special.bidder,
|
||||
special.submitted, special.ownBid]) !== specialSignature) return false;
|
||||
return special.method === 'silent' ? !special.submitted.includes(actor) : special.active === actor;
|
||||
};
|
||||
return <Button className="game-action min-h-11 whitespace-normal" data-testid="phase-any-bid-guide"
|
||||
disabled={!canAct()} onClick={() => { if (canAct()) props.send(action); }}>
|
||||
{typeof action.amount === 'number' && action.amount > 0
|
||||
? `Bid ${action.amount} spice while honoring your phase answers`
|
||||
: action.amount === 0 ? 'Submit zero spice while honoring your phase answers'
|
||||
: 'Pass this lot while honoring your phase answers'}
|
||||
</Button>;
|
||||
}
|
||||
|
||||
export function PhaseAnyBidPromises(props: Props) {
|
||||
const game = props.game, own = game.phaseAnyBidPromises.filter(promise => promise.player === game.me);
|
||||
if (!own.length) return null;
|
||||
const waiting = own.some(promise => promise.turn === game.turn && !promise.fulfilled && !promise.released);
|
||||
return <section className="notice space-y-3" aria-label="Your Truthtrance any-auction bid promises" id="phase-any-bid-guidance">
|
||||
<h3>Your any-auction bid promises</h3>
|
||||
<ul>{own.map(promise => <li key={promise.event}>
|
||||
Turn {promise.turn}: You answered {promise.answer ? 'Yes' : 'No'} to {phaseAnyBidClaimText(promise)}.
|
||||
{promise.released ? ' Released: this commitment is no longer possible.'
|
||||
: promise.fulfilled ? ' Fulfilled: this commitment is complete.' : ' This answer is binding through this Bidding phase.'}
|
||||
</li>)}</ul>
|
||||
<p>Yes requires a qualifying future bid while possible. No forbids qualifying bids through Bidding close.
|
||||
Ordinary, Richese cache and Black Market auctions count. A bid can fulfill Yes even if another player wins;
|
||||
its native funding and payment rules still apply.</p>
|
||||
<p className="fine">Earlier bids do not count. The answer adds no funds or bidding opportunity.
|
||||
Some combinations with other bidding commitments remain unavailable.</p>
|
||||
{waiting && !game.phaseAnyBidGuide && <p>Your next supported opportunity may still be ahead.</p>}
|
||||
{waiting && <PhaseAnyBidGuideButton {...props} />}
|
||||
</section>;
|
||||
}
|
||||
Reference in new issue
Block a user