Support Advanced early cache bid promises
Verify and publish checkpoint container / container (push) Successful in 11m48s
Verify and publish checkpoint container / container (push) Successful in 11m48s
This commit is contained in:
1 parent
1a65e69932
commit
225b2174ad
14 files changed
+1071
-22
No files matched your search
@@ -17,6 +17,14 @@ open mode gates.
|
|||||||
|
|
||||||
## Current checkpoint and work
|
## Current checkpoint and work
|
||||||
|
|
||||||
|
**Advanced early cache through Black Market — 16 November. Prototyped /
|
||||||
|
Partial.** Supported bare Advanced CHOAM-deck games can bind the early cache
|
||||||
|
question, alone or with a phase-wide answer, through the original Black Market
|
||||||
|
and Advanced Semuta response. A third independent current-market bid binding,
|
||||||
|
Kull and other module combinations, complete games and deployed acceptance
|
||||||
|
remain open. Eighteen related unit files pass 214 cases.
|
||||||
|
[Scope](TRUTHTRANCE_BID_PROMISES.md#advanced-early-cache-and-black-market--16-november-2026).
|
||||||
|
|
||||||
**Sandmaster on concealed Ambassador relocation — 16 November. Prototyped /
|
**Sandmaster on concealed Ambassador relocation — 16 November. Prototyped /
|
||||||
Partial.** Supported selected-deck Skills games can collect one destination
|
Partial.** Supported selected-deck Skills games can collect one destination
|
||||||
spice while a Fremen Ambassador relocates Richese's concealed marker, including
|
spice while a Fremen Ambassador relocates Richese's concealed marker, including
|
||||||
@@ -37,7 +45,7 @@ Eighteen related unit files covering both changes pass 211 cases.
|
|||||||
Partial.** Supported Basic games can bind both answers before Bidding; a real
|
Partial.** Supported Basic games can bind both answers before Bidding; a real
|
||||||
cache declaration can satisfy both, or separately funded bids retain their
|
cache declaration can satisfy both, or separately funded bids retain their
|
||||||
own costs and hand slots. The cache-only route and Semuta continuation are
|
own costs and hand slots. The cache-only route and Semuta continuation are
|
||||||
connected. Sixteen related unit files pass 236 cases. Advanced, Kull and other
|
connected. Sixteen related unit files passed 236 cases at that checkpoint. Kull and other
|
||||||
promise combinations, complete games and
|
promise combinations, complete games and
|
||||||
deployed acceptance remain open.
|
deployed acceptance remain open.
|
||||||
[Scope](TRUTHTRANCE_BID_PROMISES.md#all-auction-and-early-richese-cache-bids--16-november-2026).
|
[Scope](TRUTHTRANCE_BID_PROMISES.md#all-auction-and-early-richese-cache-bids--16-november-2026).
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# Rule decision index
|
# Rule decision index
|
||||||
|
|
||||||
|
## Advanced early cache and Black Market — 16 November 2026
|
||||||
|
|
||||||
|
Supported Advanced early-cache and all-auction answers preserve the original
|
||||||
|
Black Market purchase and subsequent cache. Funding forecasts and online
|
||||||
|
timing are provisional; a separate current-lot third binding remains guarded.
|
||||||
|
[Scope](TRUTHTRANCE_BID_PROMISES.md#advanced-early-cache-and-black-market--16-november-2026).
|
||||||
|
|
||||||
## Sandmaster and concealed Ambassador relocation — 16 November 2026
|
## Sandmaster and concealed Ambassador relocation — 16 November 2026
|
||||||
|
|
||||||
The existing provisional Sandmaster destination collection composes with an
|
The existing provisional Sandmaster destination collection composes with an
|
||||||
|
|||||||
@@ -1,5 +1,38 @@
|
|||||||
# Truthtrance ordinary bid commitments
|
# Truthtrance ordinary bid commitments
|
||||||
|
|
||||||
|
## Advanced early cache and Black Market — 16 November 2026
|
||||||
|
|
||||||
|
**Prototyped / Partial.** Before Bidding in supported bare Advanced CHOAM-deck
|
||||||
|
games, players may ask about the first real Richese cache bid, including with
|
||||||
|
an all-auction phase answer. The optional Black Market still happens first.
|
||||||
|
The forecast reserves a potentially winning market bid, its own and allied
|
||||||
|
funding, hand space and a possible Harkonnen bonus before relying on the later
|
||||||
|
cache. Paid seller retention keeps the original card without a new hand slot.
|
||||||
|
Only the bidder's own Silent commitment and public hand capacities are used.
|
||||||
|
Guides, minimal bots and the auction clock use the same native declaration;
|
||||||
|
the latter preserves a fundable cache commitment. An unresolved market cannot
|
||||||
|
release a still-fundable phase answer merely because its later ordinary lot
|
||||||
|
count is not yet established. Actual cancellation and settlement keep their
|
||||||
|
native rules. Fresh Advanced Semuta offers on definite early/phase questions
|
||||||
|
bind both ledgers; Unknown keeps the Truthtrance.
|
||||||
|
|
||||||
|
The Advanced revision's Richese section (supplied PDF physical p. 36, printed
|
||||||
|
p. 34) and publisher R2 pp. 4–6, 10–12 establish the physical cache and market
|
||||||
|
sequence. The existing online forecast, seller retention and Truthtrance timing
|
||||||
|
are provisional compositions, not new publisher rulings. A new current-lot
|
||||||
|
Black Market bid question cannot yet create a third independent binding while
|
||||||
|
an early-cache receipt waits; constant-fact mixed answers remain available.
|
||||||
|
Kull, other Advanced modules, full games and deployed acceptance remain open.
|
||||||
|
[Market cases](../tests/truth-early-richese-advanced-black-market.test.ts),
|
||||||
|
[guide cases](../tests/truth-early-richese-advanced-market-guides.test.ts),
|
||||||
|
[funding cases](../tests/truth-early-richese-advanced-aid.test.ts),
|
||||||
|
[boundary cases](../tests/truth-early-richese-advanced-market-boundaries.test.ts)
|
||||||
|
and [Semuta cases](../tests/truth-early-richese-advanced-semuta.test.ts)
|
||||||
|
use native public starts with disclosed conserved staging. The
|
||||||
|
[selective-release case](../tests/truth-early-richese-advanced-market-release.test.ts)
|
||||||
|
uses real questions and an explicitly staged external wallet shortfall.
|
||||||
|
Eighteen related unit files pass 214 cases.
|
||||||
|
|
||||||
## Voluntary cancellation of a promised cache — 16 November 2026
|
## Voluntary cancellation of a promised cache — 16 November 2026
|
||||||
|
|
||||||
**Prototyped / Partial.** A player with a still-feasible early cache Yes cannot
|
**Prototyped / Partial.** A player with a still-feasible early cache Yes cannot
|
||||||
@@ -36,7 +69,8 @@ independently viable phase Yes. Fresh Semuta discard continuations bind both
|
|||||||
waiting ledgers; older saved continuations keep their original signatures.
|
waiting ledgers; older saved continuations keep their original signatures.
|
||||||
The FAQ and supplied Advanced revision support current-turn questions and
|
The FAQ and supplied Advanced revision support current-turn questions and
|
||||||
compliance while possible; this online forecast and ordering are provisional.
|
compliance while possible; this online forecast and ordering are provisional.
|
||||||
Advanced and Kull early-cache admission, other commitments, optional modules,
|
The bare Advanced extension is described above. Kull early-cache admission,
|
||||||
|
other commitments and optional modules,
|
||||||
complete games and deployed acceptance remain open.
|
complete games and deployed acceptance remain open.
|
||||||
[Joint cases](../tests/truth-phase-any-early-richese-joint.test.ts),
|
[Joint cases](../tests/truth-phase-any-early-richese-joint.test.ts),
|
||||||
[last cache cases](../tests/truth-phase-any-early-richese-last.test.ts),
|
[last cache cases](../tests/truth-phase-any-early-richese-last.test.ts),
|
||||||
@@ -257,7 +291,7 @@ minimal bot profiles. Additional real-auction cases exercise voluntary spending,
|
|||||||
the final hand slot, canceled cache and the owner's Once Around turn; some
|
the final hand slot, canceled cache and the owner's Once Around turn; some
|
||||||
explicitly stage conserved unopened cards. The owner sees a persistent waiting
|
explicitly stage conserved unopened cards. The owner sees a persistent waiting
|
||||||
reminder; controls are tested with component callbacks. Printed Kull, broader
|
reminder; controls are tested with component callbacks. Printed Kull, broader
|
||||||
combinations, Advanced early questions and deployed
|
combinations, other Advanced profiles and deployed
|
||||||
acceptance remain open.
|
acceptance remain open.
|
||||||
`npm run check:quick` and the production build passed for this batch.
|
`npm run check:quick` and the production build passed for this batch.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
import type { RicheseBidPromise } from './richese-bid-promises';
|
import type { RicheseBidPromise } from './richese-bid-promises';
|
||||||
|
import { bidPromiseModeSupported } from './bid-promises';
|
||||||
|
|
||||||
|
/** Early cache questions support the existing Basic profile and the bare
|
||||||
|
* Advanced CHOAM deck. Other Advanced module/semuta profiles stay separate. */
|
||||||
|
export function earlyRicheseBidModeSupported(game: Parameters<typeof bidPromiseModeSupported>[0]): boolean {
|
||||||
|
return !game.kullPreview && bidPromiseModeSupported({...game,semutaPreview:undefined}) &&
|
||||||
|
(!game.advanced || !game.semutaPreview && game.expansions.length === 1 && game.expansions[0] === 'choam');
|
||||||
|
}
|
||||||
|
|
||||||
/** A single bid in the first actual cache auction of this turn, before its
|
/** A single bid in the first actual cache auction of this turn, before its
|
||||||
* card, method, direction and public event have been chosen. */
|
* card, method, direction and public event have been chosen. */
|
||||||
|
|||||||
+118
-12
@@ -35,7 +35,7 @@ import { RicheseBidPromiseError, richeseBidCompletionRange, richeseBidRequired,
|
|||||||
liveRicheseBidPromises, reconcileRicheseBidPromises, finishRicheseBidLot, validateRicheseBidPromises,
|
liveRicheseBidPromises, reconcileRicheseBidPromises, finishRicheseBidLot, validateRicheseBidPromises,
|
||||||
type RicheseBidClaim, type RicheseBidPromise, type RicheseBidOpportunity } from './richese-bid-promises';
|
type RicheseBidClaim, type RicheseBidPromise, type RicheseBidOpportunity } from './richese-bid-promises';
|
||||||
import { jointRicheseBidCompletionRange } from './joint-richese-bids';
|
import { jointRicheseBidCompletionRange } from './joint-richese-bids';
|
||||||
import { EarlyRicheseBidError, earlyRicheseBidAnswerOptions, bindEarlyRicheseBid,
|
import { EarlyRicheseBidError, earlyRicheseBidModeSupported, earlyRicheseBidAnswerOptions, bindEarlyRicheseBid,
|
||||||
attachEarlyRicheseBids, liveEarlyRicheseBidPromises, reconcileEarlyRicheseBids,
|
attachEarlyRicheseBids, liveEarlyRicheseBidPromises, reconcileEarlyRicheseBids,
|
||||||
validateEarlyRicheseBidPromises, type EarlyRicheseBidClaim, type EarlyRicheseBidPromise } from './early-richese-bid';
|
validateEarlyRicheseBidPromises, type EarlyRicheseBidClaim, type EarlyRicheseBidPromise } from './early-richese-bid';
|
||||||
import { quoteJointEarlyRicheseBids } from './joint-early-richese-bids';
|
import { quoteJointEarlyRicheseBids } from './joint-early-richese-bids';
|
||||||
@@ -2012,6 +2012,8 @@ export type Game = {
|
|||||||
jointOrdinaryPhaseBid?: true;
|
jointOrdinaryPhaseBid?: true;
|
||||||
/** Fresh waiting cache/all-auction answer; absent on older receipts. */
|
/** Fresh waiting cache/all-auction answer; absent on older receipts. */
|
||||||
jointEarlyPhaseBid?: true;
|
jointEarlyPhaseBid?: true;
|
||||||
|
/** Fresh Advanced pre-Bidding cache/phase answer and its ledgers. */
|
||||||
|
advancedEarlyCacheTruth?: true;
|
||||||
resume: NonNullable<Game['pendingNullentropy']>['resume'];
|
resume: NonNullable<Game['pendingNullentropy']>['resume'];
|
||||||
promise:
|
promise:
|
||||||
| { kind: 'shipment'; index: number; value: ShipmentPromise }
|
| { kind: 'shipment'; index: number; value: ShipmentPromise }
|
||||||
@@ -8070,6 +8072,8 @@ function truthtranceDiscardSignature(g: Game, next: TruthDiscardContinuation) {
|
|||||||
bidPromises:g.bidPromises,mixedBidQuestions:g.mixedBidQuestions} : {}),
|
bidPromises:g.bidPromises,mixedBidQuestions:g.mixedBidQuestions} : {}),
|
||||||
...(next.jointEarlyPhaseBid ? {jointEarlyPhaseBid:true,phaseAnyBidPromises:g.phaseAnyBidPromises,
|
...(next.jointEarlyPhaseBid ? {jointEarlyPhaseBid:true,phaseAnyBidPromises:g.phaseAnyBidPromises,
|
||||||
earlyRicheseBidPromises:g.earlyRicheseBidPromises} : {}),
|
earlyRicheseBidPromises:g.earlyRicheseBidPromises} : {}),
|
||||||
|
...(next.advancedEarlyCacheTruth ? {advancedEarlyCacheTruth:true,phaseAnyBidPromises:g.phaseAnyBidPromises,
|
||||||
|
earlyRicheseBidPromises:g.earlyRicheseBidPromises} : {}),
|
||||||
...(next.record.question.kind === 'mixedRevival' ? {
|
...(next.record.question.kind === 'mixedRevival' ? {
|
||||||
mixedRevivalQuestions: g.mixedRevivalQuestions, revivalExpressionPromises: g.revivalExpressionPromises,
|
mixedRevivalQuestions: g.mixedRevivalQuestions, revivalExpressionPromises: g.revivalExpressionPromises,
|
||||||
} : {}),
|
} : {}),
|
||||||
@@ -8153,6 +8157,7 @@ function finishTruthtranceAnswer(g: Game) {
|
|||||||
record,
|
record,
|
||||||
remaining,
|
remaining,
|
||||||
...(advancedTruthAuctionSupported(g,record.question.kind) ? {advancedAuctionTruth:true as const} : {}),
|
...(advancedTruthAuctionSupported(g,record.question.kind) ? {advancedAuctionTruth:true as const} : {}),
|
||||||
|
...(advancedEarlyCacheTruthSupported(g,record.question.kind) ? {advancedEarlyCacheTruth:true as const} : {}),
|
||||||
...(supportedRicheseTruthLot(g) || advancedTruthAuctionSupported(g,record.question.kind) &&
|
...(supportedRicheseTruthLot(g) || advancedTruthAuctionSupported(g,record.question.kind) &&
|
||||||
supportedSaphoRicheseTruthLot(g) ? {richeseLotEvent:g.richeseAuction!.event} : {}),
|
supportedSaphoRicheseTruthLot(g) ? {richeseLotEvent:g.richeseAuction!.event} : {}),
|
||||||
...(g.richeseAuction && ['phaseAnyBid','richeseBid','mixedRicheseBid'].includes(record.question.kind) &&
|
...(g.richeseAuction && ['phaseAnyBid','richeseBid','mixedRicheseBid'].includes(record.question.kind) &&
|
||||||
@@ -9194,6 +9199,9 @@ function treacheryDiscardIntegrity(g: Game) {
|
|||||||
'The consumed Truthtrance does not match its completed answer history.',
|
'The consumed Truthtrance does not match its completed answer history.',
|
||||||
);
|
);
|
||||||
const remaining = c.remaining;
|
const remaining = c.remaining;
|
||||||
|
requireRule(!c.advancedEarlyCacheTruth || c.advancedEarlyCacheTruth === true &&
|
||||||
|
advancedEarlyCacheTruthSupported(g,record.question.kind),
|
||||||
|
'The completed Truthtrance no longer matches its original Advanced cache question.');
|
||||||
if (c.jointEarlyPhaseBid) {
|
if (c.jointEarlyPhaseBid) {
|
||||||
const target = record.question.target;
|
const target = record.question.target;
|
||||||
requireRule(c.jointEarlyPhaseBid === true &&
|
requireRule(c.jointEarlyPhaseBid === true &&
|
||||||
@@ -10013,6 +10021,13 @@ function advancedTruthAuctionSupported(g: Game, kind: TruthQuestion['kind']): bo
|
|||||||
return advancedSaphoAuctionSemuta(g) &&
|
return advancedSaphoAuctionSemuta(g) &&
|
||||||
['fact','freeform','bid','mixedBid','phaseBid','phaseAnyBid','richeseBid','mixedRicheseBid'].includes(kind);
|
['fact','freeform','bid','mixedBid','phaseBid','phaseAnyBid','richeseBid','mixedRicheseBid'].includes(kind);
|
||||||
}
|
}
|
||||||
|
/** Fresh pre-Bidding Advanced cache questions have their own signed ledgers;
|
||||||
|
* older saved Truth discards keep their original continuation and signature. */
|
||||||
|
function advancedEarlyCacheTruthSupported(g: Game, kind: TruthQuestion['kind']): boolean {
|
||||||
|
return g.semutaAdvancedOrdinaryPreview === true && bareAdvancedClassicSemutaProfile(g) &&
|
||||||
|
g.status === 'playing' && g.phase >= 0 && g.phase <= 2 && (g.richeseCache?.length ?? 0) > 0 &&
|
||||||
|
['earlyRicheseBid','phaseAnyBid'].includes(kind);
|
||||||
|
}
|
||||||
/** Bind a parked native ride to its original remaining Spice Blow sequence. */
|
/** Bind a parked native ride to its original remaining Spice Blow sequence. */
|
||||||
function wormDiscardCursor(g: Game): string {
|
function wormDiscardCursor(g: Game): string {
|
||||||
return JSON.stringify([g.turn, g.phase, g.wormRides, g.spiceSequence,
|
return JSON.stringify([g.turn, g.phase, g.wormRides, g.spiceSequence,
|
||||||
@@ -10091,6 +10106,9 @@ function semutaOfferSupported(
|
|||||||
advancedTruthAuctionSupported(g,continuation.record.question.kind) &&
|
advancedTruthAuctionSupported(g,continuation.record.question.kind) &&
|
||||||
(!g.richeseAuction || supportedSaphoRicheseTruthLot(g) &&
|
(!g.richeseAuction || supportedSaphoRicheseTruthLot(g) &&
|
||||||
continuation.richeseLotEvent === g.richeseAuction.event);
|
continuation.richeseLotEvent === g.richeseAuction.event);
|
||||||
|
const advancedEarlyCacheDiscard = continuation.kind === 'truthtranceDiscard' &&
|
||||||
|
continuation.advancedEarlyCacheTruth === true && continuation.promise === null &&
|
||||||
|
advancedEarlyCacheTruthSupported(g,continuation.record.question.kind);
|
||||||
const richeseBoxDiscard = supportedRicheseTruthLot(g) && continuation.kind === 'nullentropyDiscard' &&
|
const richeseBoxDiscard = supportedRicheseTruthLot(g) && continuation.kind === 'nullentropyDiscard' &&
|
||||||
continuation.auctionBinding?.kind === 'richese';
|
continuation.auctionBinding?.kind === 'richese';
|
||||||
const richeseDistransDiscard = continuation.kind === 'distransDiscard' &&
|
const richeseDistransDiscard = continuation.kind === 'distransDiscard' &&
|
||||||
@@ -10361,7 +10379,7 @@ function semutaOfferSupported(
|
|||||||
continuation.kind === 'nullentropyDiscard' || continuation.kind === 'distransDiscard' ||
|
continuation.kind === 'nullentropyDiscard' || continuation.kind === 'distransDiscard' ||
|
||||||
continuation.kind === 'residualPoisonDiscard' || continuation.kind === 'choamSaleDiscard' ||
|
continuation.kind === 'residualPoisonDiscard' || continuation.kind === 'choamSaleDiscard' ||
|
||||||
continuation.kind === 'saphoTruthOrderDiscard' && advancedSaphoAuctionSemuta(g) ||
|
continuation.kind === 'saphoTruthOrderDiscard' && advancedSaphoAuctionSemuta(g) ||
|
||||||
advancedTruthAuctionDiscard ||
|
advancedTruthAuctionDiscard || advancedEarlyCacheDiscard ||
|
||||||
continuation.kind === 'karamaEmperorShareDiscard' &&
|
continuation.kind === 'karamaEmperorShareDiscard' &&
|
||||||
emperorAuctionGiftResumeMatches(g, continuation.use.response, continuation.resume.decision) ||
|
emperorAuctionGiftResumeMatches(g, continuation.use.response, continuation.resume.decision) ||
|
||||||
((continuation.kind === 'choamKulonDiscard' || continuation.kind === 'choamLaLaLaDiscard' ||
|
((continuation.kind === 'choamKulonDiscard' || continuation.kind === 'choamLaLaLaDiscard' ||
|
||||||
@@ -18579,19 +18597,27 @@ function earlyRicheseBidRule<T>(run: () => T): T {
|
|||||||
try { return run(); } catch (error) { if (error instanceof EarlyRicheseBidError) throw new RuleError(error.message); throw error; }
|
try { return run(); } catch (error) { if (error instanceof EarlyRicheseBidError) throw new RuleError(error.message); throw error; }
|
||||||
}
|
}
|
||||||
function earlyRicheseBidWindow(g: Game): boolean {
|
function earlyRicheseBidWindow(g: Game): boolean {
|
||||||
return bidPromiseModeSupported({ ...g, semutaPreview: undefined }) && !g.kullPreview && !g.advanced &&
|
return earlyRicheseBidModeSupported(g) &&
|
||||||
g.status === 'playing' && g.phase >= 0 && g.phase <= 2 && !!byFaction(g, 'richese') &&
|
g.status === 'playing' && g.phase >= 0 && g.phase <= 2 && !!byFaction(g, 'richese') &&
|
||||||
(g.richeseCache?.length ?? 0) > 0 && !g.response && !g.decision && !g.phaseOpening &&
|
(g.richeseCache?.length ?? 0) > 0 && !g.response && !g.decision && !g.phaseOpening &&
|
||||||
!g.pendingKarama && !g.pendingTreacheryDiscard;
|
!g.pendingKarama && !g.pendingTreacheryDiscard;
|
||||||
}
|
}
|
||||||
/** A conservative witness uses the respondent's current uncommitted spice;
|
/** A conservative witness uses the respondent's current uncommitted spice;
|
||||||
* it does not assume an ally's future aid or an opponent's future bid. */
|
* it does not assume an ally's future aid or an opponent's future bid. */
|
||||||
|
function pendingBlackMarketCards(g: Game,p: Player): number {
|
||||||
|
const lot = g.richeseAuction;
|
||||||
|
const marketWin = lot?.source === 'blackMarket' && lot.owner !== p.id &&
|
||||||
|
!p.hand.some(card => card.id === lot.cardId) &&
|
||||||
|
(lot.outcome?.kind === 'sold' ? lot.outcome.winner === p.id : !lot.outcome &&
|
||||||
|
(lot.method === 'silent' ? (lot.sealed[p.id] ?? 0) > 0 : lot.bidder === p.id));
|
||||||
|
return marketWin ? 1 + Number(p.faction === 'harkonnen') : 0;
|
||||||
|
}
|
||||||
function earlyRicheseBidMaximum(g: Game, p: Player): number {
|
function earlyRicheseBidMaximum(g: Game, p: Player): number {
|
||||||
// A leading ordinary bid may become a real purchase when the other players
|
// A leading bid may become a real purchase when the other players pass.
|
||||||
// pass. Reserve its physical hand slot, including Harkonnen's bonus draw.
|
|
||||||
const pendingPurchase = g.auction?.bidder === p.id && !g.currentAuctionSale
|
const pendingPurchase = g.auction?.bidder === p.id && !g.currentAuctionSale
|
||||||
? 1 + Number(p.faction === 'harkonnen') : 0;
|
? 1 + Number(p.faction === 'harkonnen') : 0;
|
||||||
if (p.hand.length + pendingPurchase >= handLimit(p)) return 0;
|
const pendingMarket = pendingBlackMarketCards(g,p);
|
||||||
|
if (p.hand.length + pendingPurchase + pendingMarket >= handLimit(p)) return 0;
|
||||||
const amount = uncommittedSpice(g,p);
|
const amount = uncommittedSpice(g,p);
|
||||||
return Number.isSafeInteger(amount) ? Math.max(0,amount) : 0;
|
return Number.isSafeInteger(amount) ? Math.max(0,amount) : 0;
|
||||||
}
|
}
|
||||||
@@ -18696,6 +18722,11 @@ function richeseBidTruthAnswers(g: Game, p: Player, claim: RicheseBidClaim): Tru
|
|||||||
if (!richeseBidWindow(g) || !lot || claim.turn !== g.turn || claim.event !== lot.event ||
|
if (!richeseBidWindow(g) || !lot || claim.turn !== g.turn || claim.event !== lot.event ||
|
||||||
!lot.eligible.includes(p.id) || lot.acted.includes(p.id) ||
|
!lot.eligible.includes(p.id) || lot.acted.includes(p.id) ||
|
||||||
!richeseBidFitsHand(lot.source,lot.owner,p.id,p.hand.length,handLimit(p))) return [];
|
!richeseBidFitsHand(lot.source,lot.owner,p.id,p.hand.length,handLimit(p))) return [];
|
||||||
|
// A separately asked Black Market bid needs a three-ledger planner before
|
||||||
|
// it can coexist with an unbound first-cache promise. Do not admit a Yes
|
||||||
|
// that could reserve the same spice or hand space twice.
|
||||||
|
if (lot.source === 'blackMarket' &&
|
||||||
|
liveEarlyRicheseBidPromises(g.earlyRicheseBidPromises ?? [],p.id,g.turn).length) return [];
|
||||||
const base = g.richeseBidPromises ?? [], opportunity = richeseBidOpportunity(g,p);
|
const base = g.richeseBidPromises ?? [], opportunity = richeseBidOpportunity(g,p);
|
||||||
const context = {turn:g.turn,event:lot.event,player:p.id};
|
const context = {turn:g.turn,event:lot.event,player:p.id};
|
||||||
const asker = g.truthtrance?.queue[0]?.player ?? g.players.find(row => row.id !== p.id)?.id ?? g.host;
|
const asker = g.truthtrance?.queue[0]?.player ?? g.players.find(row => row.id !== p.id)?.id ?? g.host;
|
||||||
@@ -19110,6 +19141,34 @@ function phaseAnyLastCache(g: Game,p: Player): PhaseBidOpportunity | null {
|
|||||||
return Number.isSafeInteger(maximum) && maximum > 0
|
return Number.isSafeInteger(maximum) && maximum > 0
|
||||||
? {turn:g.turn,player:p.id,kind:'future',minimum:1,maximum} : null;
|
? {turn:g.turn,player:p.id,kind:'future',minimum:1,maximum} : null;
|
||||||
}
|
}
|
||||||
|
/** Before the Advanced market closes, quote a possible later ordinary lot
|
||||||
|
* from the actual cache, deck, public bid and this seat's own commitment.
|
||||||
|
* Never inspect another player's sealed bid or assume a future refund. */
|
||||||
|
function phaseAnyMarketOrdinary(g: Game,p: Player): PhaseBidOpportunity | null {
|
||||||
|
const lot = g.richeseAuction, round = g.richeseBidding;
|
||||||
|
if (g.phase !== 3 || lot?.source !== 'blackMarket' || !round || round.turn !== g.turn ||
|
||||||
|
round.stage !== 'lot' || !(g.deck.length || g.discard.length)) return null;
|
||||||
|
const cards = pendingBlackMarketCards(g,p);
|
||||||
|
if (p.hand.length + cards >= handLimit(p)) return null;
|
||||||
|
const ownBid = lot.outcome ? lot.outcome.kind === 'sold' && lot.outcome.winner === p.id :
|
||||||
|
lot.method === 'silent' ? (lot.sealed[p.id] ?? 0) > 0 : lot.bidder === p.id;
|
||||||
|
// While offers are still sealed, use only public hand capacities. A sale
|
||||||
|
// could fill at most one other buyer's hand and reduce the ordinary pool.
|
||||||
|
const possibleSale = !lot.outcome || lot.outcome.kind === 'sold';
|
||||||
|
const mayFill = (buyer: Player) => buyer.id !== p.id && buyer.id !== lot.owner &&
|
||||||
|
!buyer.hand.some(card => card.id === lot.cardId) && buyer.hand.length < handLimit(buyer) &&
|
||||||
|
buyer.hand.length + 1 + Number(buyer.faction === 'harkonnen') >= handLimit(buyer);
|
||||||
|
const possibleFullBuyer = lot.outcome?.kind === 'sold'
|
||||||
|
? mayFill(getPlayer(g,lot.outcome.winner)) : !lot.outcome && g.players.some(mayFill);
|
||||||
|
const eligible = auctionEligible(g).length;
|
||||||
|
if (eligible - Number(possibleFullBuyer) - Number(possibleSale) -
|
||||||
|
Number((g.richeseCache?.length ?? 0) > 0) < 1) return null;
|
||||||
|
const lockedAid = ownBid ? (g.richeseFunding?.[p.id]?.allyPayment ?? 0) : 0;
|
||||||
|
const maximum = Math.min(Number.MAX_SAFE_INTEGER,Math.max(0,uncommittedSpice(g,p)) +
|
||||||
|
Math.max(0,(aidFor(g,p)?.amount ?? 0)-lockedAid));
|
||||||
|
return Number.isSafeInteger(maximum) && maximum > 0
|
||||||
|
? {turn:g.turn,player:p.id,kind:'future',minimum:1,maximum} : null;
|
||||||
|
}
|
||||||
/** The waiting first cache is physical but its method and order are not yet
|
/** The waiting first cache is physical but its method and order are not yet
|
||||||
* known. Reserve only owned spice and never assume another player's bid. */
|
* known. Reserve only owned spice and never assume another player's bid. */
|
||||||
function pendingEarlyCacheMaximum(g: Game,p: Player): number {
|
function pendingEarlyCacheMaximum(g: Game,p: Player): number {
|
||||||
@@ -19197,18 +19256,34 @@ function phaseAnyBidWitnesses(g: Game, p: Player, promises: readonly PhaseBidPro
|
|||||||
const positive = phase.find(row => row.answer);
|
const positive = phase.find(row => row.answer);
|
||||||
if (!positive) return result;
|
if (!positive) return result;
|
||||||
const neutralPhase = [...phase.filter(row => !row.answer),{...positive,minimum:1}];
|
const neutralPhase = [...phase.filter(row => !row.answer),{...positive,minimum:1}];
|
||||||
for (const opportunity of viablePhaseBidWitnesses(g,p,neutralPhase,true)) {
|
if (special && lot?.source === 'blackMarket') {
|
||||||
|
// The current market bid is distinct from the still-waiting cache.
|
||||||
|
// Paid seller retention does not add a second card to its owner's hand.
|
||||||
|
const joint = quoteJointEarlyRicheseBids({player:p.id,turn:g.turn,early,phase:neutralPhase,cacheMaximum,
|
||||||
|
ordinary:{opportunity:special,cashAvailable:Math.max(0,uncommittedSpice(g,p)),
|
||||||
|
aidAvailable:Math.max(0,aidFor(g,p)?.amount ?? 0),freeSlots:Math.max(0,handLimit(p)-p.hand.length),
|
||||||
|
cacheWinSlots:1+Number(p.faction === 'harkonnen'),winSlots:lot.owner === p.id ? 0 : 1}});
|
||||||
|
if (joint.separate) result.push({...special,...joint.separate.ordinary});
|
||||||
|
}
|
||||||
|
const marketOrdinary = phaseAnyMarketOrdinary(g,p);
|
||||||
|
for (const opportunity of [...viablePhaseBidWitnesses(g,p,neutralPhase,true),
|
||||||
|
...(marketOrdinary ? [marketOrdinary] : [])]) {
|
||||||
// Later ordinary witnesses follow any required local purchase; current
|
// Later ordinary witnesses follow any required local purchase; current
|
||||||
// witnesses are that purchase and must not reserve it twice.
|
// witnesses are that purchase and must not reserve it twice.
|
||||||
const source = opportunity.kind === 'future' ? afterLocal : g;
|
const source = opportunity.kind === 'future' ? afterLocal : g;
|
||||||
const owner = getPlayer(source,p.id);
|
const owner = getPlayer(source,p.id);
|
||||||
const pendingCards = source.auction?.bidder === p.id && !source.currentAuctionSale
|
const pendingCards = source.auction?.bidder === p.id && !source.currentAuctionSale
|
||||||
? 1 + Number(p.faction === 'harkonnen') : 0;
|
? 1 + Number(p.faction === 'harkonnen') : 0;
|
||||||
const freeSlots = Math.max(0,handLimit(owner)-owner.hand.length-pendingCards);
|
const freeSlots = Math.max(0,handLimit(owner)-owner.hand.length-pendingCards-pendingBlackMarketCards(source,owner));
|
||||||
const cash = Math.max(0,uncommittedSpice(source,owner));
|
const cash = Math.max(0,uncommittedSpice(source,owner));
|
||||||
const lockedAid = source.auction?.bidder === p.id && !source.currentAuctionSale
|
const lockedAid = source.auction?.bidder === p.id && !source.currentAuctionSale
|
||||||
? (source.auction.allyPayment ?? 0) : 0;
|
? (source.auction.allyPayment ?? 0) : 0;
|
||||||
const aid = Math.max(0,(aidFor(source,owner)?.amount ?? 0)-lockedAid);
|
const market = source.richeseAuction;
|
||||||
|
const ownMarket = market?.source === 'blackMarket' && (market.outcome
|
||||||
|
? market.outcome.kind === 'sold' && market.outcome.winner === p.id
|
||||||
|
: market.method === 'silent' ? (market.sealed[p.id] ?? 0) > 0 : market.bidder === p.id);
|
||||||
|
const marketAid = ownMarket ? (source.richeseFunding?.[p.id]?.allyPayment ?? 0) : 0;
|
||||||
|
const aid = Math.max(0,(aidFor(source,owner)?.amount ?? 0)-lockedAid-marketAid);
|
||||||
const joint = quoteJointEarlyRicheseBids({player:p.id,turn:g.turn,early,phase:neutralPhase,cacheMaximum,
|
const joint = quoteJointEarlyRicheseBids({player:p.id,turn:g.turn,early,phase:neutralPhase,cacheMaximum,
|
||||||
ordinary:{opportunity,cashAvailable:cash,aidAvailable:aid,freeSlots,
|
ordinary:{opportunity,cashAvailable:cash,aidAvailable:aid,freeSlots,
|
||||||
cacheWinSlots:1+Number(p.faction === 'harkonnen')}});
|
cacheWinSlots:1+Number(p.faction === 'harkonnen')}});
|
||||||
@@ -19279,12 +19354,31 @@ function reconcilePhaseAnyBids(g: Game,voluntary?: {actor:string;action:Action})
|
|||||||
if (!g.phaseAnyBidPromises?.length || g.truthtrance || g.response || g.decision || g.phaseOpening ||
|
if (!g.phaseAnyBidPromises?.length || g.truthtrance || g.response || g.decision || g.phaseOpening ||
|
||||||
g.pendingTreacheryDiscard || g.pendingKarama || g.pendingKull || g.pendingRicheseBetrayal) return;
|
g.pendingTreacheryDiscard || g.pendingKarama || g.pendingKull || g.pendingRicheseBetrayal) return;
|
||||||
for (const p of g.players) {
|
for (const p of g.players) {
|
||||||
const live = livePhaseBidPromises(g.phaseAnyBidPromises,p.id,g.turn);
|
const live = livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn);
|
||||||
if (!live.length) continue;
|
if (!live.length) continue;
|
||||||
const change = voluntary?.actor === p.id ? 'voluntary' : 'external';
|
const change = voluntary?.actor === p.id ? 'voluntary' : 'external';
|
||||||
if (g.phase > 3) g.phaseAnyBidPromises = phaseBidRule(() => finishPhaseBidPhase(g.phaseAnyBidPromises!,p.id,g.turn,change));
|
if (g.phase > 3) g.phaseAnyBidPromises = phaseBidRule(() => finishPhaseBidPhase(g.phaseAnyBidPromises!,p.id,g.turn,change));
|
||||||
else g.phaseAnyBidPromises = phaseBidRule(() => reconcilePhaseBidPromises(g.phaseAnyBidPromises!,p.id,g.turn,
|
else {
|
||||||
phaseAnyBidWitnesses(g,p,g.phaseAnyBidPromises!),change));
|
const witnesses = phaseAnyBidWitnesses(g,p,g.phaseAnyBidPromises!);
|
||||||
|
// A pending market has not yet established its real ordinary-lot
|
||||||
|
// count. Do not release a still-fundable Yes solely because the
|
||||||
|
// conservative public-information lower bound cannot prove that count.
|
||||||
|
const lot = g.richeseAuction;
|
||||||
|
const deferred = new Set<string>();
|
||||||
|
if (change === 'external' && lot?.source === 'blackMarket' && !lot.outcome &&
|
||||||
|
liveEarlyRicheseBidPromises(g.earlyRicheseBidPromises ?? [],p.id,g.turn).length) {
|
||||||
|
const maximum = Math.min(Number.MAX_SAFE_INTEGER,Math.max(0,p.spice) + Math.max(0,aidFor(g,p)?.amount ?? 0));
|
||||||
|
const no = live.filter(row => !row.answer);
|
||||||
|
if (maximum > 0) for (const row of live) if (row.answer &&
|
||||||
|
!witnesses.some(witness => !!phaseBidCompletionRange([...no,row],witness)) &&
|
||||||
|
!!phaseBidCompletionRange([...no,row],{turn:g.turn,player:p.id,kind:'future',minimum:1,maximum}))
|
||||||
|
deferred.add(row.event);
|
||||||
|
}
|
||||||
|
const before: PhaseBidPromise[] = g.phaseAnyBidPromises ?? [];
|
||||||
|
const reconciled: PhaseBidPromise[] = phaseBidRule((): PhaseBidPromise[] =>
|
||||||
|
reconcilePhaseBidPromises(before,p.id,g.turn,witnesses,change));
|
||||||
|
g.phaseAnyBidPromises = reconciled.map((row,index) => deferred.has(row.event) ? before[index] : row);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** One exact native action is shared by both panels, bots and the clock. */
|
/** One exact native action is shared by both panels, bots and the clock. */
|
||||||
@@ -19347,6 +19441,18 @@ function projectedPhaseAnyBidGuide(g: Game, id: string): {action:Action} | null
|
|||||||
if (!lot || (lot.method === 'silent' ? Object.hasOwn(lot.sealed,id) : lot.active !== id)) return null;
|
if (!lot || (lot.method === 'silent' ? Object.hasOwn(lot.sealed,id) : lot.active !== id)) return null;
|
||||||
if (['onceAround','silent'].includes(lot.method) && liveRicheseBidPromises(g.richeseBidPromises ?? [],
|
if (['onceAround','silent'].includes(lot.method) && liveRicheseBidPromises(g.richeseBidPromises ?? [],
|
||||||
{turn:g.turn,event:lot.event,player:id}).length) return projectedJointRicheseBidGuide(g,id);
|
{turn:g.turn,event:lot.event,player:id}).length) return projectedJointRicheseBidGuide(g,id);
|
||||||
|
if (lot.source === 'blackMarket' && liveEarlyRicheseBidPromises(g.earlyRicheseBidPromises ?? [],id,g.turn).length) {
|
||||||
|
const witnesses = phaseAnyBidWitnesses(g,p,live), required = live.some(row => row.answer);
|
||||||
|
const current = witnesses.find(witness => witness.kind === 'current' && !!phaseBidCompletionRange(live,witness));
|
||||||
|
const range = current && phaseBidCompletionRange(live,current);
|
||||||
|
if (required && !range && !witnesses.some(witness => witness.kind === 'future' &&
|
||||||
|
!!phaseBidCompletionRange(live,witness))) return null;
|
||||||
|
const amount = required && range ? range.minimum : lot.method === 'silent' ? 0 : null;
|
||||||
|
const own = uncommittedSpice(g,p) + richeseOwnCommitment(lot,g.richeseFunding ?? {},id);
|
||||||
|
return {action:{type:'richeseBid',event:lot.event,amount,
|
||||||
|
allyPayment:amount === null ? 0 : Math.max(0,amount-own),phaseAnyBidPromiseEvent:live[0].event,
|
||||||
|
phaseAnyBidLotEvent:lot.event}};
|
||||||
|
}
|
||||||
const required = live.some(row => row.answer), opportunity = phaseAnySpecialOpportunity(g,p);
|
const required = live.some(row => row.answer), opportunity = phaseAnySpecialOpportunity(g,p);
|
||||||
const range = opportunity && phaseBidCompletionRange(live,opportunity);
|
const range = opportunity && phaseBidCompletionRange(live,opportunity);
|
||||||
if (required && !range) return null;
|
if (required && !range) return null;
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ export type JointEarlyRicheseBidInput = {
|
|||||||
freeSlots: number;
|
freeSlots: number;
|
||||||
/** Slots occupied by a potentially won cache card (including bonuses). */
|
/** Slots occupied by a potentially won cache card (including bonuses). */
|
||||||
cacheWinSlots: number;
|
cacheWinSlots: number;
|
||||||
|
/** Slots needed by the other bid; paid seller retention adds no card. */
|
||||||
|
winSlots?: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -76,13 +78,13 @@ export function quoteJointEarlyRicheseBids(input: JointEarlyRicheseBidInput): Jo
|
|||||||
|
|
||||||
let separate: JointEarlyRicheseBidQuote['separate'] = null;
|
let separate: JointEarlyRicheseBidQuote['separate'] = null;
|
||||||
if (input.ordinary && phaseRequired) {
|
if (input.ordinary && phaseRequired) {
|
||||||
const {opportunity, cashAvailable, aidAvailable, freeSlots, cacheWinSlots} = input.ordinary;
|
const {opportunity, cashAvailable, aidAvailable, freeSlots, cacheWinSlots, winSlots = 1} = input.ordinary;
|
||||||
if (!opportunity || opportunity.player !== input.player || opportunity.turn !== input.turn ||
|
if (!opportunity || opportunity.player !== input.player || opportunity.turn !== input.turn ||
|
||||||
!whole(cashAvailable) || !whole(aidAvailable) || !whole(freeSlots) || !whole(cacheWinSlots))
|
!whole(cashAvailable) || !whole(aidAvailable) || !whole(freeSlots) || !whole(cacheWinSlots) || !whole(winSlots))
|
||||||
throw new EarlyRicheseBidError('Retain the funded separate ordinary bid and hand capacity.');
|
throw new EarlyRicheseBidError('Retain the funded separate ordinary bid and hand capacity.');
|
||||||
const reserved = earlyRequired ? cache?.minimum : 0;
|
const reserved = earlyRequired ? cache?.minimum : 0;
|
||||||
if (reserved !== undefined && cashAvailable >= reserved &&
|
if (reserved !== undefined && cashAvailable >= reserved &&
|
||||||
freeSlots > (earlyRequired ? cacheWinSlots : 0)) {
|
freeSlots >= (earlyRequired ? cacheWinSlots : 0) + winSlots) {
|
||||||
const maximumOrdinary = Math.min(opportunity.maximum, Number.MAX_SAFE_INTEGER,
|
const maximumOrdinary = Math.min(opportunity.maximum, Number.MAX_SAFE_INTEGER,
|
||||||
cashAvailable - reserved + aidAvailable);
|
cashAvailable - reserved + aidAvailable);
|
||||||
if (maximumOrdinary >= opportunity.minimum) {
|
if (maximumOrdinary >= opportunity.minimum) {
|
||||||
|
|||||||
+2
-1
@@ -3791,8 +3791,9 @@ export const RULE_TOPICS: RuleTopic[] = [
|
|||||||
'Choose the separate all-auction phase bid question to include ordinary, Richese cache and Black Market declarations. One accepted qualifying bid fulfills Yes even if it loses; No caps qualifying bids until Bidding closes. Silent zero is a decline. Existing ordinary-only answers retain their original scope. Some combinations with other binding questions are not yet available.',
|
'Choose the separate all-auction phase bid question to include ordinary, Richese cache and Black Market declarations. One accepted qualifying bid fulfills Yes even if it loses; No caps qualifying bids until Bidding closes. Silent zero is a decline. Existing ordinary-only answers retain their original scope. Some combinations with other binding questions are not yet available.',
|
||||||
'A current ordinary, Richese Once Around or Silent bid answer can coexist with the all-auction answer. One native declaration may satisfy both; each No caps that declaration, and a phase-wide Yes may instead wait for a separately funded later lot.',
|
'A current ordinary, Richese Once Around or Silent bid answer can coexist with the all-auction answer. One native declaration may satisfy both; each No caps that declaration, and a phase-wide Yes may instead wait for a separately funded later lot.',
|
||||||
'In a Silent Richese lot the question binds the respondent’s single sealed submission. Zero declines; a positive bid remains hidden until the native simultaneous reveal. Available answers use that bidder’s own funding, without using opponents’ concealed amounts.',
|
'In a Silent Richese lot the question binds the respondent’s single sealed submission. Zero declines; a positive bid remains hidden until the native simultaneous reveal. Available answers use that bidder’s own funding, without using opponents’ concealed amounts.',
|
||||||
'Before Basic Bidding, ask about a minimum bid in the first actual Richese cache auction of this turn. The answer waits for the real event and does not predict its card or method. Current uncommitted personal funds and hand space supply a conservative Yes witness. You cannot cancel a cache required by your own feasible Yes; another player’s cancellation or opposing action can release an impossible commitment. The Richese owner’s Once Around turn may vanish if everyone else passes.',
|
'Before Bidding in supported Basic and bare Advanced Richese games, ask about a minimum bid in the first actual cache auction of this turn. The answer waits for the real event and does not predict its card or method. Current uncommitted personal funds and hand space supply a conservative Yes witness; in Advanced, a Black Market purchase reserves its actual cost and hand space first. You cannot cancel a cache required by your own feasible Yes; another player’s cancellation or opposing action can release an impossible commitment. The Richese owner’s Once Around turn may vanish if everyone else passes.',
|
||||||
'A supported early cache answer and the all-auction phase answer can coexist. A single qualifying cache bid may satisfy both; separate bids need enough currently funded spice and hand space for both purchases. A cache No ends with that lot, while a phase No continues until Bidding ends.',
|
'A supported early cache answer and the all-auction phase answer can coexist. A single qualifying cache bid may satisfy both; separate bids need enough currently funded spice and hand space for both purchases. A cache No ends with that lot, while a phase No continues until Bidding ends.',
|
||||||
|
'In the Advanced preview, a separate current Black Market bid question cannot yet bind a respondent who already has a waiting early-cache answer. The all-auction phase question remains available within its stated limits.',
|
||||||
'Your waiting cache commitment remains visible until its auction opens or it ends. Once the real lot opens, the ordinary Richese bid guide takes over.',
|
'Your waiting cache commitment remains visible until its auction opens or it ends. Once the real lot opens, the ordinary Richese bid guide takes over.',
|
||||||
'The phase-wide guide may wait for a later lot only when the existing funded sale, prepared next card and post-sale space and funds support it. An unbid lot, hypothetical rival raise, cancelable unfunded overbid or Harkonnen bonus slot is not invented as a future opportunity. Before Bidding, current funding and available card count provide a provisional forecast; special auction preparation and combined future commitments remain limited.',
|
'The phase-wide guide may wait for a later lot only when the existing funded sale, prepared next card and post-sale space and funds support it. An unbid lot, hypothetical rival raise, cancelable unfunded overbid or Harkonnen bonus slot is not invented as a future opportunity. Before Bidding, current funding and available card count provide a provisional forecast; special auction preparation and combined future commitments remain limited.',
|
||||||
'In supported Basic Ixian or Richese games, a phase-wide ordinary bid can wait through Ixian inspection or a first-position Richese cache. Only ordinary bids count; a potential cache purchase reserves your funds and hand space. If the ordinary auction clock expires and your Yes forbids passing, the normal guide supplies the required legal bid.',
|
'In supported Basic Ixian or Richese games, a phase-wide ordinary bid can wait through Ixian inspection or a first-position Richese cache. Only ordinary bids count; a potential cache purchase reserves your funds and hand space. If the ordinary auction clock expires and your Yes forbids passing, the normal guide supplies the required legal bid.',
|
||||||
|
|||||||
+3
-3
@@ -91,7 +91,7 @@ import { parseBidClaim, bidClaimText, bidPromiseModeSupported, currentBidPromise
|
|||||||
import { parsePhaseBidClaim, phaseBidClaimText, phaseBidPromiseModeSupported, type PhaseBidClaim } from './turn-bid-promises';
|
import { parsePhaseBidClaim, phaseBidClaimText, phaseBidPromiseModeSupported, type PhaseBidClaim } from './turn-bid-promises';
|
||||||
import { parsePhaseAnyBidClaim, phaseAnyBidClaimText, phaseAnyBidPromiseModeSupported, type PhaseAnyBidClaim } from './phase-any-bid-promises';
|
import { parsePhaseAnyBidClaim, phaseAnyBidClaimText, phaseAnyBidPromiseModeSupported, type PhaseAnyBidClaim } from './phase-any-bid-promises';
|
||||||
import { parseRicheseBidClaim, richeseBidClaimText, type RicheseBidClaim } from './richese-bid-promises';
|
import { parseRicheseBidClaim, richeseBidClaimText, type RicheseBidClaim } from './richese-bid-promises';
|
||||||
import { parseEarlyRicheseBidClaim, earlyRicheseBidClaimText, type EarlyRicheseBidClaim } from './early-richese-bid';
|
import { earlyRicheseBidModeSupported, parseEarlyRicheseBidClaim, earlyRicheseBidClaimText, type EarlyRicheseBidClaim } from './early-richese-bid';
|
||||||
|
|
||||||
export type TruthFact =
|
export type TruthFact =
|
||||||
| KnowledgeFact
|
| KnowledgeFact
|
||||||
@@ -448,11 +448,11 @@ function parseQuestion(g: Game, asker: string, value: unknown): TruthQuestion {
|
|||||||
check(Object.keys(v).sort().join(',') === 'kind,minimum,target,turn',
|
check(Object.keys(v).sort().join(',') === 'kind,minimum,target,turn',
|
||||||
'Supply the current turn, cache bid minimum and respondent.');
|
'Supply the current turn, cache bid minimum and respondent.');
|
||||||
const claim = parseEarlyRicheseBidClaim(v);
|
const claim = parseEarlyRicheseBidClaim(v);
|
||||||
check(bidPromiseModeSupported({ ...g, semutaPreview: undefined }) && !g.kullPreview && !g.advanced &&
|
check(earlyRicheseBidModeSupported(g) &&
|
||||||
g.status === 'playing' && g.phase >= 0 && g.phase <= 2 && claim.turn === g.turn &&
|
g.status === 'playing' && g.phase >= 0 && g.phase <= 2 && claim.turn === g.turn &&
|
||||||
g.players.some(player => player.faction === 'richese') && (g.richeseCache?.length ?? 0) > 0 &&
|
g.players.some(player => player.faction === 'richese') && (g.richeseCache?.length ?? 0) > 0 &&
|
||||||
!g.response && !g.decision && !g.phaseOpening && !g.pendingKarama && !g.pendingTreacheryDiscard,
|
!g.response && !g.decision && !g.phaseOpening && !g.pendingKarama && !g.pendingTreacheryDiscard,
|
||||||
'Choose a quiet Basic turn before the first Richese cache auction.');
|
'Choose a supported quiet turn before the first Richese cache auction.');
|
||||||
return { kind: 'earlyRicheseBid', target: v.target, ...claim };
|
return { kind: 'earlyRicheseBid', target: v.target, ...claim };
|
||||||
}
|
}
|
||||||
if (v.kind === 'richeseBid') {
|
if (v.kind === 'richeseBid') {
|
||||||
|
|||||||
@@ -0,0 +1,160 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import { viewGame, type Action, type Game } from '../game/engine';
|
||||||
|
import {
|
||||||
|
actTruthtranceRichesePromises as act,
|
||||||
|
advanceTruthtranceRichesePromises as advance,
|
||||||
|
createTruthtranceRichesePromisesFixture as fixture,
|
||||||
|
passTruthRicheseFreshDiscard,
|
||||||
|
truthtranceRichesePromisesClean as clean,
|
||||||
|
truthtranceRichesePromisesInventory as inventory,
|
||||||
|
truthtranceRichesePromisesPlayer as player,
|
||||||
|
type TruthtranceRichesePromisesFixture,
|
||||||
|
} from './fixture-truthtrance-richese-promises';
|
||||||
|
|
||||||
|
type Method = 'silent' | 'onceAround';
|
||||||
|
|
||||||
|
/** Public Advanced R/A/E setup; the second original Truthtrance and, in the
|
||||||
|
* seller-retention cases, two original unopened cards move from deck to hands.
|
||||||
|
* A mutual alliance is explicitly staged; the actual pledge, Truth answers,
|
||||||
|
* auction, payments and cache are all produced by native actions. */
|
||||||
|
function source(seller: boolean) {
|
||||||
|
const f = fixture({advanced:true});
|
||||||
|
const game = structuredClone(f.earlySource);
|
||||||
|
const target = seller ? f.richese : f.emperor;
|
||||||
|
const donor = seller ? f.emperor : f.asker;
|
||||||
|
player(game,target).ally = donor; player(game,donor).ally = target;
|
||||||
|
const at = game.deck.findIndex(card => card.effect === 'truthtrance' && card.id !== f.truth);
|
||||||
|
assert.ok(at >= 0);
|
||||||
|
const [second] = game.deck.splice(at,1); player(game,f.asker).hand.push(second);
|
||||||
|
if (seller) for (let i = 0; i < 2; i++) {
|
||||||
|
const index = game.deck.findIndex(card => card.effect !== 'truthtrance'); assert.ok(index >= 0);
|
||||||
|
const [card] = game.deck.splice(index,1); player(game,target).hand.push(card);
|
||||||
|
}
|
||||||
|
assert.ok(player(game,donor).spice >= 4);
|
||||||
|
assert.deepEqual(inventory(game),f.originalCards);
|
||||||
|
return {f,game,target,donor,second:second.id};
|
||||||
|
}
|
||||||
|
|
||||||
|
function ask(game:Game, f:TruthtranceRichesePromisesFixture, target:string, card:string,
|
||||||
|
kind:'earlyRicheseBid'|'phaseAnyBid', minimum:number) {
|
||||||
|
game = act(game,f.asker,{type:'card',card});
|
||||||
|
game = advance(game,state => state.truthtrance?.stage === 'ask');
|
||||||
|
game = act(game,f.asker,{type:'truthAsk',question:{kind,target,turn:game.turn,minimum}});
|
||||||
|
const view = viewGame(game,target);
|
||||||
|
assert.ok((kind === 'earlyRicheseBid' ? view.truthEarlyRicheseBidAnswers : view.truthPhaseAnyBidAnswers)?.includes('yes'));
|
||||||
|
return passTruthRicheseFreshDiscard(act(game,target,{type:'truthAnswer',answer:'yes'}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function begin(seller:boolean) {
|
||||||
|
const s = source(seller);
|
||||||
|
let game = ask(s.game,s.f,s.target,s.f.truth,'earlyRicheseBid',4);
|
||||||
|
game = ask(game,s.f,s.target,s.second,'phaseAnyBid',seller ? 3 : 6);
|
||||||
|
const early = game.earlyRicheseBidPromises?.find(row => row.player === s.target); assert.ok(early);
|
||||||
|
const phase = game.phaseAnyBidPromises?.find(row => row.player === s.target); assert.ok(phase);
|
||||||
|
return {...s,game,early,phase};
|
||||||
|
}
|
||||||
|
|
||||||
|
function market(game:Game, f:TruthtranceRichesePromisesFixture, method:Method) {
|
||||||
|
game = advance(game,state => state.decision?.kind === 'richeseBlackMarket');
|
||||||
|
game = act(game,f.richese,{type:'decision',event:game.richeseBidding!.event,card:f.targetCard,
|
||||||
|
method,...(method === 'onceAround' ? {direction:'clockwise'} : {})});
|
||||||
|
while (game.response) {
|
||||||
|
const actor = game.players.find(seat => !game.response!.passed.includes(seat.id)); assert.ok(actor);
|
||||||
|
game = act(game,actor.id,{type:'passResponse'});
|
||||||
|
}
|
||||||
|
assert.equal(game.richeseAuction?.source,'blackMarket');
|
||||||
|
assert.equal(game.richeseAuction?.method,method);
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
function reject(game:Game, actor:string, action:Action) {
|
||||||
|
const before = structuredClone(game);
|
||||||
|
assert.throws(() => act(game,actor,action));
|
||||||
|
assert.deepEqual(game,before,'Rejected bids and funding updates preserve the original source');
|
||||||
|
}
|
||||||
|
|
||||||
|
function finishMarket(game:Game, event:string, method:Method):Game {
|
||||||
|
while (game.richeseAuction?.event === event && !game.richeseAuction.outcome) {
|
||||||
|
const lot = game.richeseAuction;
|
||||||
|
const actor = method === 'silent' ? lot.eligible.find(id => !Object.hasOwn(lot.sealed,id)) : lot.active;
|
||||||
|
assert.ok(actor);
|
||||||
|
game = act(game,actor,{type:'richeseBid',event,amount:method === 'silent' ? 0 : null,allyPayment:0});
|
||||||
|
}
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
function completeCache(game:Game, f:TruthtranceRichesePromisesFixture, target:string, earlyId:string) {
|
||||||
|
game = advance(game,state => clean(state) && state.richeseAuction?.source === 'cache' &&
|
||||||
|
state.richeseAuction.method === 'silent' && !state.richeseAuction.outcome,[],{position:'first',method:'silent'});
|
||||||
|
const lot = game.richeseAuction!, card = lot.cardId;
|
||||||
|
assert.equal(game.earlyRicheseBidPromises?.find(row => row.id === earlyId)?.boundEvent,lot.event);
|
||||||
|
const guide = viewGame(game,target).richeseBidPromiseGuide?.action; assert.ok(guide);
|
||||||
|
assert.equal(guide.type,'richeseBid'); assert.equal(guide.event,lot.event); assert.equal(guide.amount,4);
|
||||||
|
game = act(game,target,guide);
|
||||||
|
assert.ok(game.richeseBidPromises?.some(row => row.id === earlyId && row.fulfilled));
|
||||||
|
game = advance(game,state => player(state,target).hand.some(item => item.id === card),[],
|
||||||
|
{position:'first',method:'silent'});
|
||||||
|
assert.deepEqual(inventory(game),f.originalCards);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const method of ['silent','onceAround'] as const) void test(
|
||||||
|
`Advanced ${method} Black Market protects the funded cache when the phase bid uses locked allied spice`, () => {
|
||||||
|
const s = begin(false), startCash = player(s.game,s.target).spice;
|
||||||
|
assert.equal(startCash,10);
|
||||||
|
let game = market(s.game,s.f,method);
|
||||||
|
game = act(game,s.donor,{type:'pledgeAid',amount:4});
|
||||||
|
if (method === 'onceAround')
|
||||||
|
game = advance(game,state => clean(state) && state.richeseAuction?.active === s.target);
|
||||||
|
const lot = game.richeseAuction!, event = lot.event;
|
||||||
|
reject(game,s.target,{type:'richeseBid',event,amount:11,allyPayment:4});
|
||||||
|
game = act(game,s.target,{type:'richeseBid',event,amount:10,allyPayment:4});
|
||||||
|
assert.equal(player(game,s.target).spice,startCash,'A submitted bid has not been paid');
|
||||||
|
assert.equal(game.richeseFunding?.[s.target]?.allyPayment,4);
|
||||||
|
assert.ok(game.phaseAnyBidPromises?.find(row => row.event === s.phase.event)?.fulfilled);
|
||||||
|
assert.ok(!game.earlyRicheseBidPromises?.find(row => row.id === s.early.id)?.released);
|
||||||
|
if (game.richeseAuction?.event === event && !game.richeseAuction.outcome) {
|
||||||
|
reject(game,s.donor,{type:'pledgeAid',amount:3});
|
||||||
|
reject(game,s.target,{type:'bribe',target:s.f.richese,amount:5});
|
||||||
|
}
|
||||||
|
game = finishMarket(game,event,method);
|
||||||
|
game = advance(game,state => player(state,s.target).hand.some(card => card.id === s.f.targetCard));
|
||||||
|
assert.equal(player(game,s.target).spice,startCash-6);
|
||||||
|
assert.equal(game.aid[s.donor]?.amount,0,'The pledged four was spent exactly once');
|
||||||
|
assert.ok(!game.earlyRicheseBidPromises?.find(row => row.id === s.early.id)?.released);
|
||||||
|
assert.deepEqual(inventory(game),s.f.originalCards);
|
||||||
|
completeCache(game,s.f,s.target,s.early.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const method of ['silent','onceAround'] as const) void test(
|
||||||
|
`Advanced ${method} Black Market paid self-retention reserves no extra seller hand slot`, () => {
|
||||||
|
const s = begin(true), originalHand = player(s.game,s.target).hand.map(card => card.id).sort();
|
||||||
|
const ownSpice = player(s.game,s.target).spice;
|
||||||
|
assert.equal(originalHand.length,3,'Only one physical cache hand slot remains');
|
||||||
|
let game = market(s.game,s.f,method);
|
||||||
|
game = act(game,s.donor,{type:'pledgeAid',amount:4});
|
||||||
|
const event = game.richeseAuction!.event;
|
||||||
|
if (method === 'onceAround') {
|
||||||
|
let opened = false;
|
||||||
|
while (game.richeseAuction?.event === event && game.richeseAuction.active !== s.target) {
|
||||||
|
const actor = game.richeseAuction.active; assert.ok(actor && actor !== s.target);
|
||||||
|
game = act(game,actor,{type:'richeseBid',event,amount:opened ? null : 1,allyPayment:0});
|
||||||
|
opened = true;
|
||||||
|
}
|
||||||
|
assert.ok(opened,'The seller gets its native Once Around turn after an opposing bid');
|
||||||
|
}
|
||||||
|
game = act(game,s.target,{type:'richeseBid',event,amount:4,allyPayment:4});
|
||||||
|
assert.ok(game.phaseAnyBidPromises?.find(row => row.event === s.phase.event)?.fulfilled);
|
||||||
|
assert.ok(!game.earlyRicheseBidPromises?.find(row => row.id === s.early.id)?.released);
|
||||||
|
if (game.richeseAuction?.event === event && !game.richeseAuction.outcome)
|
||||||
|
reject(game,s.donor,{type:'pledgeAid',amount:3});
|
||||||
|
game = finishMarket(game,event,method);
|
||||||
|
game = advance(game,state => state.decision?.kind === 'richeseDeclaration');
|
||||||
|
assert.deepEqual(player(game,s.target).hand.map(card => card.id).sort(),originalHand,
|
||||||
|
'The seller retains its own offered physical card instead of acquiring an extra card');
|
||||||
|
assert.equal(player(game,s.target).spice,ownSpice);
|
||||||
|
assert.equal(game.aid[s.donor]?.amount,0);
|
||||||
|
assert.ok(!game.earlyRicheseBidPromises?.find(row => row.id === s.early.id)?.released);
|
||||||
|
assert.deepEqual(inventory(game),s.f.originalCards);
|
||||||
|
completeCache(game,s.f,s.target,s.early.id);
|
||||||
|
});
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import { viewGame, type Action, type Game } from '../game/engine';
|
||||||
|
import {
|
||||||
|
actTruthtranceRichesePromises as act,
|
||||||
|
advanceTruthtranceRichesePromises as advance,
|
||||||
|
createTruthtranceRichesePromisesFixture as fixture,
|
||||||
|
passTruthRicheseFreshDiscard,
|
||||||
|
truthtranceRichesePromisesClean as clean,
|
||||||
|
truthtranceRichesePromisesInventory as inventory,
|
||||||
|
truthtranceRichesePromisesPlayer as player,
|
||||||
|
type TruthtranceRichesePromisesFixture,
|
||||||
|
} from './fixture-truthtrance-richese-promises';
|
||||||
|
|
||||||
|
type Method = 'silent' | 'onceAround';
|
||||||
|
type Position = 'first' | 'last';
|
||||||
|
|
||||||
|
/** The genuine Advanced R/A/E fixture selects only unopened deal/Spice order.
|
||||||
|
* Joint questions stage the second original Truthtrance from the unopened deck;
|
||||||
|
* the near-full-hand case stages two original cards from there. No wallet,
|
||||||
|
* promise, bid, phase or auction is installed. */
|
||||||
|
function source(joint = false, nearFull = false) {
|
||||||
|
const f = fixture({advanced:true});
|
||||||
|
const game = structuredClone(f.earlySource);
|
||||||
|
let second: string | undefined;
|
||||||
|
if (joint) {
|
||||||
|
const index = game.deck.findIndex(card => card.effect === 'truthtrance' && card.id !== f.truth);
|
||||||
|
assert.ok(index >= 0);
|
||||||
|
const [card] = game.deck.splice(index,1); second = card.id;
|
||||||
|
player(game,f.asker).hand.push(card);
|
||||||
|
}
|
||||||
|
if (nearFull) {
|
||||||
|
for (let i = 0; i < 2; i++) {
|
||||||
|
const index = game.deck.findIndex(card => card.effect !== 'truthtrance'); assert.ok(index >= 0);
|
||||||
|
const [card] = game.deck.splice(index,1); player(game,f.emperor).hand.push(card);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.deepEqual(inventory(game),f.originalCards);
|
||||||
|
return {f,game,second};
|
||||||
|
}
|
||||||
|
|
||||||
|
function answer(game:Game, f:TruthtranceRichesePromisesFixture, card:string,
|
||||||
|
kind:'earlyRicheseBid'|'phaseAnyBid', minimum:number) {
|
||||||
|
game = act(game,f.asker,{type:'card',card});
|
||||||
|
game = advance(game,state => state.truthtrance?.stage === 'ask');
|
||||||
|
game = act(game,f.asker,{type:'truthAsk',question:{kind,target:f.emperor,turn:game.turn,minimum}});
|
||||||
|
const view = viewGame(game,f.emperor);
|
||||||
|
const choices = kind === 'earlyRicheseBid' ? view.truthEarlyRicheseBidAnswers : view.truthPhaseAnyBidAnswers;
|
||||||
|
assert.ok(choices?.includes('yes'), `${kind} must admit the funded Yes`);
|
||||||
|
return passTruthRicheseFreshDiscard(act(game,f.emperor,{type:'truthAnswer',answer:'yes'}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function begin(joint = false, nearFull = false) {
|
||||||
|
const f = source(joint,nearFull);
|
||||||
|
let game = answer(f.game,f.f,f.f.truth,'earlyRicheseBid',4);
|
||||||
|
if (f.second) game = answer(game,f.f,f.second,'phaseAnyBid',6);
|
||||||
|
const early = game.earlyRicheseBidPromises?.find(row => row.player === f.f.emperor); assert.ok(early);
|
||||||
|
const phase = joint ? game.phaseAnyBidPromises?.find(row => row.player === f.f.emperor) : undefined;
|
||||||
|
if (joint) assert.ok(phase);
|
||||||
|
assert.deepEqual(inventory(game),f.f.originalCards);
|
||||||
|
return {f:f.f,game,early,phase};
|
||||||
|
}
|
||||||
|
|
||||||
|
function openMarket(game:Game, f:TruthtranceRichesePromisesFixture, method:Method) {
|
||||||
|
game = advance(game,state => state.decision?.kind === 'richeseBlackMarket');
|
||||||
|
assert.ok(player(game,f.richese).hand.some(card => card.id === f.targetCard));
|
||||||
|
game = act(game,f.richese,{type:'decision',event:game.richeseBidding!.event,
|
||||||
|
card:f.targetCard,method,...(method === 'onceAround' ? {direction:'clockwise'} : {})});
|
||||||
|
while (game.response) {
|
||||||
|
const actor = game.players.find(seat => !game.response!.passed.includes(seat.id)); assert.ok(actor);
|
||||||
|
game = act(game,actor.id,{type:'passResponse'});
|
||||||
|
}
|
||||||
|
assert.equal(game.richeseAuction?.source,'blackMarket');
|
||||||
|
assert.equal(game.richeseAuction?.method,method);
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
function reachBid(game:Game, f:TruthtranceRichesePromisesFixture, method:Method) {
|
||||||
|
if (method === 'onceAround')
|
||||||
|
game = advance(game,state => clean(state) && state.richeseAuction?.active === f.emperor);
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
function reject(game:Game, actor:string, action:Action) {
|
||||||
|
const original = structuredClone(game);
|
||||||
|
assert.throws(() => act(game,actor,action));
|
||||||
|
assert.deepEqual(game,original,'A rejected auction action keeps its original receipt and funds');
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeMarket(game:Game, f:TruthtranceRichesePromisesFixture, method:Method) {
|
||||||
|
const event = game.richeseAuction!.event;
|
||||||
|
while (game.richeseAuction?.event === event && !game.richeseAuction.outcome) {
|
||||||
|
const lot = game.richeseAuction;
|
||||||
|
const actor = method === 'silent' ? lot.eligible.find(id => !Object.hasOwn(lot.sealed,id)) : lot.active;
|
||||||
|
assert.ok(actor);
|
||||||
|
game = act(game,actor,{type:'richeseBid',event,amount:method === 'silent' ? 0 : null,allyPayment:0});
|
||||||
|
}
|
||||||
|
return advance(game,state => player(state,f.emperor).hand.some(card => card.id === f.targetCard));
|
||||||
|
}
|
||||||
|
|
||||||
|
function completeCache(game:Game, f:TruthtranceRichesePromisesFixture, id:string, method:Method, position:Position) {
|
||||||
|
game = advance(game,state => clean(state) && gameIsCache(state,method),[],{position,method});
|
||||||
|
const event = game.richeseAuction!.event, card = game.richeseAuction!.cardId;
|
||||||
|
if (method === 'onceAround') game = advance(game,state => clean(state) && state.richeseAuction?.active === f.emperor);
|
||||||
|
assert.equal(game.earlyRicheseBidPromises?.find(row => row.id === id)?.boundEvent,event);
|
||||||
|
const guide = viewGame(game,f.emperor).richeseBidPromiseGuide; assert.ok(guide);
|
||||||
|
assert.equal(guide.action.event,event); assert.equal(guide.action.amount,4);
|
||||||
|
const spice = player(game,f.emperor).spice;
|
||||||
|
game = act(game,f.emperor,guide.action);
|
||||||
|
assert.equal(player(game,f.emperor).spice,spice,'The accepted bid is not prepaid');
|
||||||
|
assert.ok(game.richeseBidPromises?.some(row => row.id === id && row.fulfilled));
|
||||||
|
game = advance(game,state => player(state,f.emperor).hand.some(item => item.id === card),[],{position,method});
|
||||||
|
assert.equal(player(game,f.emperor).spice,spice-4);
|
||||||
|
assert.deepEqual(inventory(game),f.originalCards);
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
function gameIsCache(game:Game, method:Method) {
|
||||||
|
return !!game.richeseAuction && game.richeseAuction.source === 'cache' &&
|
||||||
|
game.richeseAuction.method === method && !game.richeseAuction.outcome;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const method of ['onceAround','silent'] as const)
|
||||||
|
for (const position of ['first','last'] as const) void test(
|
||||||
|
`Advanced ${position} ${method}: Black Market purchase reserves the funded later cache`, () => {
|
||||||
|
const f = begin(true), before = player(f.game,f.f.emperor).spice;
|
||||||
|
assert.equal(before,10);
|
||||||
|
let game = reachBid(openMarket(f.game,f.f,method),f.f,method);
|
||||||
|
const event = game.richeseAuction!.event;
|
||||||
|
reject(game,f.f.emperor,{type:'richeseBid',event,amount:7,allyPayment:0});
|
||||||
|
game = act(game,f.f.emperor,{type:'richeseBid',event,amount:6,allyPayment:0});
|
||||||
|
assert.equal(player(game,f.f.emperor).spice,before);
|
||||||
|
assert.ok(!game.earlyRicheseBidPromises?.find(row => row.id === f.early.id)?.released);
|
||||||
|
assert.ok(game.phaseAnyBidPromises?.find(row => row.event === f.phase!.event)?.fulfilled);
|
||||||
|
if (method === 'silent') {
|
||||||
|
assert.equal(viewGame(game,f.f.asker).richeseAuction?.revealedBids,null);
|
||||||
|
assert.equal(viewGame(game,f.f.asker).richeseAuction?.ownBid,null);
|
||||||
|
}
|
||||||
|
game = closeMarket(game,f.f,method);
|
||||||
|
assert.equal(player(game,f.f.emperor).spice,before-6);
|
||||||
|
assert.ok(!game.earlyRicheseBidPromises?.find(row => row.id === f.early.id)?.released);
|
||||||
|
assert.deepEqual(inventory(game),f.f.originalCards);
|
||||||
|
completeCache(game,f.f,f.early.id,method,position);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const method of ['onceAround','silent'] as const) void test(
|
||||||
|
`Advanced ${method}: a Black Market win cannot consume the final cache hand slot`, () => {
|
||||||
|
const f = begin(false,true);
|
||||||
|
let game = reachBid(openMarket(f.game,f.f,method),f.f,method);
|
||||||
|
const event = game.richeseAuction!.event;
|
||||||
|
assert.equal(player(game,f.f.emperor).hand.length,3);
|
||||||
|
reject(game,f.f.emperor,{type:'richeseBid',event,amount:1,allyPayment:0});
|
||||||
|
game = act(game,f.f.emperor,{type:'richeseBid',event,amount:method === 'silent' ? 0 : null,allyPayment:0});
|
||||||
|
while (game.richeseAuction?.event === event && !game.richeseAuction.outcome) {
|
||||||
|
const lot = game.richeseAuction;
|
||||||
|
const actor = method === 'silent' ? lot.eligible.find(id => !Object.hasOwn(lot.sealed,id)) : lot.active;
|
||||||
|
assert.ok(actor);
|
||||||
|
game = act(game,actor,{type:'richeseBid',event,amount:method === 'silent' ? 0 : null,allyPayment:0});
|
||||||
|
}
|
||||||
|
assert.ok(player(game,f.f.richese).hand.some(card => card.id === f.f.targetCard));
|
||||||
|
assert.ok(!game.earlyRicheseBidPromises?.find(row => row.id === f.early.id)?.released);
|
||||||
|
completeCache(game,f.f,f.early.id,method,'first');
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('an opponent winning the Advanced Black Market preserves the respondent’s later cache Yes', () => {
|
||||||
|
const f = begin(), method:Method = 'silent';
|
||||||
|
let game = openMarket(f.game,f.f,method);
|
||||||
|
const event = game.richeseAuction!.event, spice = player(game,f.f.emperor).spice;
|
||||||
|
game = act(game,f.f.emperor,{type:'richeseBid',event,amount:0,allyPayment:0});
|
||||||
|
game = act(game,f.f.asker,{type:'richeseBid',event,amount:1,allyPayment:0});
|
||||||
|
game = act(game,f.f.richese,{type:'richeseBid',event,amount:0,allyPayment:0});
|
||||||
|
game = advance(game,state => player(state,f.f.asker).hand.some(card => card.id === f.f.targetCard));
|
||||||
|
assert.equal(player(game,f.f.emperor).spice,spice);
|
||||||
|
assert.ok(!game.earlyRicheseBidPromises?.find(row => row.id === f.early.id)?.released);
|
||||||
|
completeCache(game,f.f,f.early.id,method,'first');
|
||||||
|
});
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import { viewGame, type Action, type Game } from '../game/engine';
|
||||||
|
import {
|
||||||
|
actTruthtranceRichesePromises as act,
|
||||||
|
advanceTruthtranceRichesePromises as advance,
|
||||||
|
createTruthtranceRichesePromisesFixture as fixture,
|
||||||
|
nextTruthtranceRichesePromisesStep as nextStep,
|
||||||
|
passTruthRicheseFreshDiscard,
|
||||||
|
truthtranceRichesePromisesClean as clean,
|
||||||
|
truthtranceRichesePromisesInventory as inventory,
|
||||||
|
truthtranceRichesePromisesPlayer as player,
|
||||||
|
type TruthtranceRichesePromisesFixture,
|
||||||
|
} from './fixture-truthtrance-richese-promises';
|
||||||
|
|
||||||
|
/** Real Advanced public R/A/E starts. The second original Truthtrance and,
|
||||||
|
* in the two-turn case, one additional seller card move from the unopened
|
||||||
|
* deck; two later unopened land Spice cards are ordered. No wallet, phase,
|
||||||
|
* auction, promise, receipt or sale is assigned. */
|
||||||
|
function source(seller = false) {
|
||||||
|
const f = fixture({advanced:true}), game = structuredClone(f.earlySource);
|
||||||
|
const at = game.deck.findIndex(card => card.effect === 'truthtrance' && card.id !== f.truth);
|
||||||
|
assert.ok(at >= 0); const [second] = game.deck.splice(at,1);
|
||||||
|
player(game,f.asker).hand.push(second);
|
||||||
|
let sellerCard: string | undefined;
|
||||||
|
if (seller) {
|
||||||
|
const index = game.deck.findIndex(card => card.effect !== 'truthtrance'); assert.ok(index >= 0);
|
||||||
|
const [card] = game.deck.splice(index,1); sellerCard = card.id; player(game,f.richese).hand.push(card);
|
||||||
|
for (let position = 0; position < 2; position++) {
|
||||||
|
const from = game.spiceDeck.findIndex((card,index) => index >= position && 'territory' in card && !card.discovery);
|
||||||
|
assert.ok(from >= position);
|
||||||
|
const [card] = game.spiceDeck.splice(from,1); game.spiceDeck.splice(position,0,card);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.deepEqual(inventory(game),f.originalCards);
|
||||||
|
return {f,game,second:second.id,sellerCard};
|
||||||
|
}
|
||||||
|
|
||||||
|
function ask(game:Game, f:TruthtranceRichesePromisesFixture, card:string, target:string,
|
||||||
|
kind:'phaseAnyBid'|'earlyRicheseBid', minimum:number, answer:'yes'|'no') {
|
||||||
|
game = act(game,f.asker,{type:'card',card});
|
||||||
|
game = advance(game,state => state.truthtrance?.stage === 'ask');
|
||||||
|
game = act(game,f.asker,{type:'truthAsk',question:{kind,target,turn:game.turn,minimum}});
|
||||||
|
const view = viewGame(game,target);
|
||||||
|
const options = kind === 'phaseAnyBid' ? view.truthPhaseAnyBidAnswers : view.truthEarlyRicheseBidAnswers;
|
||||||
|
assert.ok(options?.includes(answer),`${kind} ${answer} must have its native witness`);
|
||||||
|
return passTruthRicheseFreshDiscard(act(game,target,{type:'truthAnswer',answer}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function market(game:Game, f:TruthtranceRichesePromisesFixture, card:string, method:'silent'|'onceAround') {
|
||||||
|
game = advance(game,state => state.decision?.kind === 'richeseBlackMarket');
|
||||||
|
assert.ok(player(game,f.richese).hand.some(item => item.id === card));
|
||||||
|
game = act(game,f.richese,{type:'decision',event:game.richeseBidding!.event,card,method,
|
||||||
|
...(method === 'onceAround' ? {direction:'clockwise'} : {})});
|
||||||
|
while (game.response) {
|
||||||
|
const actor = game.players.find(seat => !game.response!.passed.includes(seat.id)); assert.ok(actor);
|
||||||
|
game = act(game,actor.id,{type:'passResponse'});
|
||||||
|
}
|
||||||
|
assert.equal(game.richeseAuction?.source,'blackMarket');
|
||||||
|
assert.equal(game.richeseAuction?.method,method);
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test('Advanced current Black Market bid question cannot strand a waiting early cache Yes', () => {
|
||||||
|
const f = source();
|
||||||
|
let game = ask(f.game,f.f,f.f.truth,f.f.emperor,'earlyRicheseBid',6,'yes');
|
||||||
|
const early = game.earlyRicheseBidPromises?.find(row => row.player === f.f.emperor); assert.ok(early);
|
||||||
|
assert.equal(player(game,f.f.emperor).spice,10);
|
||||||
|
game = market(game,f.f,f.f.targetCard,'silent');
|
||||||
|
const lot = game.richeseAuction!, event = lot.event;
|
||||||
|
game = act(game,f.f.asker,{type:'card',card:f.second});
|
||||||
|
game = advance(game,state => state.truthtrance?.stage === 'ask');
|
||||||
|
const before = structuredClone(game);
|
||||||
|
const question = {kind:'richeseBid',target:f.f.emperor,turn:game.turn,event,minimum:6};
|
||||||
|
assert.throws(() => act(game,f.f.asker,{type:'truthAsk',question}),
|
||||||
|
'The separately asked current-lot promise awaits a three-ledger planner');
|
||||||
|
assert.deepEqual(game,before,'Rejected question cannot mutate the auction, question or cache receipt');
|
||||||
|
assert.ok(game.earlyRicheseBidPromises?.some(row => row.id === early.id && !row.boundEvent && !row.released));
|
||||||
|
assert.equal(player(game,f.f.emperor).spice,10);
|
||||||
|
assert.deepEqual(inventory(game),f.f.originalCards);
|
||||||
|
});
|
||||||
|
|
||||||
|
/** Drive the original live turn to the next Charity without inventing income.
|
||||||
|
* The borrowed stepper stops intentionally at Richese movement; end that own
|
||||||
|
* turn through its normal action. All auction/card and phase steps are real. */
|
||||||
|
function nextCharity(initial:Game): Game {
|
||||||
|
let game = initial;
|
||||||
|
for (let count = 0; count < 2600; count++) {
|
||||||
|
if (game.status === 'playing' && game.turn === 2 && game.phase === 2 && clean(game)) return game;
|
||||||
|
const next = nextStep(game);
|
||||||
|
let actor: string, action: Action;
|
||||||
|
if (next) { actor = next.actor; action = next.action; }
|
||||||
|
else {
|
||||||
|
assert.ok(clean(game) && game.phase === 5 && game.active,
|
||||||
|
`Native continuation needs a real action at ${game.turn}/${game.phase}/${game.decision?.kind}`);
|
||||||
|
actor = game.active; action = {type:'endMovement'};
|
||||||
|
}
|
||||||
|
game = act(game,actor,action);
|
||||||
|
}
|
||||||
|
throw Error('The genuine Advanced turn did not reach its next Charity');
|
||||||
|
}
|
||||||
|
|
||||||
|
void test('Advanced Once Around seller retains phase Yes after all pass and bids in the later ordinary lot', () => {
|
||||||
|
const f = source(true); assert.ok(f.sellerCard);
|
||||||
|
// Earn the sixth spice through a real prior Black Market sale: the Emperor
|
||||||
|
// buys the original Shield for one and both other seats decline.
|
||||||
|
let game = market(f.game,f.f,f.f.targetCard,'silent');
|
||||||
|
const firstEvent = game.richeseAuction!.event;
|
||||||
|
assert.equal(player(game,f.f.richese).spice,5);
|
||||||
|
game = act(game,f.f.emperor,{type:'richeseBid',event:firstEvent,amount:1,allyPayment:0});
|
||||||
|
game = act(game,f.f.asker,{type:'richeseBid',event:firstEvent,amount:0,allyPayment:0});
|
||||||
|
game = act(game,f.f.richese,{type:'richeseBid',event:firstEvent,amount:0,allyPayment:0});
|
||||||
|
game = advance(game,state => player(state,f.f.richese).spice === 6);
|
||||||
|
assert.ok(player(game,f.f.emperor).hand.some(card => card.id === f.f.targetCard));
|
||||||
|
game = nextCharity(game);
|
||||||
|
assert.equal(player(game,f.f.richese).spice,6,'The sixth spice was earned by the actual sale');
|
||||||
|
assert.ok(player(game,f.f.richese).hand.some(card => card.id === f.sellerCard));
|
||||||
|
game = ask(game,f.f,f.f.truth,f.f.richese,'phaseAnyBid',6,'yes');
|
||||||
|
game = ask(game,f.f,f.second,f.f.richese,'earlyRicheseBid',4,'no');
|
||||||
|
const phase = game.phaseAnyBidPromises?.find(row => row.player === f.f.richese && row.turn === game.turn);
|
||||||
|
const early = game.earlyRicheseBidPromises?.find(row => row.player === f.f.richese && row.turn === game.turn);
|
||||||
|
assert.ok(phase && early);
|
||||||
|
game = market(game,f.f,f.sellerCard,'onceAround');
|
||||||
|
const event = game.richeseAuction!.event;
|
||||||
|
while (game.richeseAuction?.event === event && !game.richeseAuction.outcome) {
|
||||||
|
const actor = game.richeseAuction.active; assert.ok(actor);
|
||||||
|
assert.notEqual(actor,f.f.richese,'The Once Around seller gets no turn when all buyers decline');
|
||||||
|
game = act(game,actor,{type:'richeseBid',event,amount:null,allyPayment:0});
|
||||||
|
}
|
||||||
|
const pending = game.phaseAnyBidPromises?.find(row => row.event === phase.event); assert.ok(pending);
|
||||||
|
assert.equal(!!pending.fulfilled,false); assert.equal(!!pending.released,false);
|
||||||
|
assert.equal(player(game,f.f.richese).spice,6);
|
||||||
|
assert.ok(player(game,f.f.richese).hand.some(card => card.id === f.sellerCard));
|
||||||
|
assert.ok(game.earlyRicheseBidPromises?.some(row => row.id === early.id && !row.boundEvent && !row.released));
|
||||||
|
const nextCache = game.richeseCache?.[0]?.id; assert.ok(nextCache,'The second turn uses an original remaining cache card');
|
||||||
|
game = advance(game,state => clean(state) && !!state.auction && state.auction.active === f.f.richese,
|
||||||
|
[],{position:'first',method:'silent',card:nextCache});
|
||||||
|
assert.ok(game.richeseBidPromises?.some(row => row.id === early.id && row.fulfilled));
|
||||||
|
const guide = viewGame(game,f.f.richese).phaseAnyBidGuide?.action; assert.ok(guide);
|
||||||
|
assert.equal(guide.type,'bid'); assert.equal(guide.amount,6);
|
||||||
|
game = act(game,f.f.richese,guide);
|
||||||
|
assert.ok(game.phaseAnyBidPromises?.some(row => row.event === phase.event && row.fulfilled));
|
||||||
|
assert.deepEqual(inventory(game),f.f.originalCards);
|
||||||
|
});
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import { viewGame, type Action, type Game } from '../game/engine';
|
||||||
|
import { botActions } from '../game/bots';
|
||||||
|
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||||
|
import {
|
||||||
|
actTruthtranceRichesePromises as act,
|
||||||
|
advanceTruthtranceRichesePromises as advance,
|
||||||
|
createTruthtranceRichesePromisesFixture as fixture,
|
||||||
|
passTruthRicheseFreshDiscard,
|
||||||
|
truthtranceRichesePromisesClean as clean,
|
||||||
|
truthtranceRichesePromisesInventory as inventory,
|
||||||
|
truthtranceRichesePromisesPlayer as player,
|
||||||
|
type TruthtranceRichesePromisesFixture,
|
||||||
|
} from './fixture-truthtrance-richese-promises';
|
||||||
|
|
||||||
|
type Method = 'normal' | 'onceAround' | 'silent';
|
||||||
|
type Early = 'yes' | 'no';
|
||||||
|
|
||||||
|
/** Genuine public Advanced R/A/E and native opening; one additional original
|
||||||
|
* Truthtrance moves from the unopened deck. The seller case moves two other
|
||||||
|
* original unopened cards into Richese's hand. No purse, phase, bid, answer,
|
||||||
|
* auction or commitment is manufactured. */
|
||||||
|
function source(seller = false) {
|
||||||
|
const f = fixture({advanced:true}), game = structuredClone(f.earlySource);
|
||||||
|
const at = game.deck.findIndex(card => card.effect === 'truthtrance' && card.id !== f.truth);
|
||||||
|
assert.ok(at >= 0); const [second] = game.deck.splice(at,1);
|
||||||
|
player(game,f.asker).hand.push(second);
|
||||||
|
if (seller) for (let i = 0; i < 2; i++) {
|
||||||
|
const index = game.deck.findIndex(card => card.effect !== 'truthtrance'); assert.ok(index >= 0);
|
||||||
|
const [card] = game.deck.splice(index,1); player(game,f.richese).hand.push(card);
|
||||||
|
}
|
||||||
|
assert.deepEqual(inventory(game),f.originalCards);
|
||||||
|
return {f,game,second:second.id};
|
||||||
|
}
|
||||||
|
|
||||||
|
function ask(game:Game, f:TruthtranceRichesePromisesFixture, card:string, target:string,
|
||||||
|
kind:'phaseAnyBid'|'earlyRicheseBid', minimum:number, answer:'yes'|'no') {
|
||||||
|
game = act(game,f.asker,{type:'card',card});
|
||||||
|
game = advance(game,state => state.truthtrance?.stage === 'ask');
|
||||||
|
game = act(game,f.asker,{type:'truthAsk',question:{kind,target,turn:game.turn,minimum}});
|
||||||
|
const view = viewGame(game,target);
|
||||||
|
const choices = kind === 'phaseAnyBid' ? view.truthPhaseAnyBidAnswers : view.truthEarlyRicheseBidAnswers;
|
||||||
|
assert.ok(choices?.includes(answer),`${kind} ${answer} needs a real funded completion`);
|
||||||
|
return passTruthRicheseFreshDiscard(act(game,target,{type:'truthAnswer',answer}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function begin(early:Early, seller = false) {
|
||||||
|
const f = source(seller), target = seller ? f.f.richese : f.f.emperor;
|
||||||
|
const phaseMinimum = seller ? 2 : 6, earlyMinimum = seller ? 3 : 4;
|
||||||
|
let game = ask(f.game,f.f,f.f.truth,target,'phaseAnyBid',phaseMinimum,'yes');
|
||||||
|
game = ask(game,f.f,f.second,target,'earlyRicheseBid',earlyMinimum,early);
|
||||||
|
const phase = game.phaseAnyBidPromises?.find(row => row.player === target); assert.ok(phase);
|
||||||
|
const cache = game.earlyRicheseBidPromises?.find(row => row.player === target); assert.ok(cache);
|
||||||
|
assert.deepEqual(inventory(game),f.f.originalCards);
|
||||||
|
return {f:f.f,game,target,phase,cache,phaseMinimum,earlyMinimum};
|
||||||
|
}
|
||||||
|
|
||||||
|
function open(game:Game,f:TruthtranceRichesePromisesFixture,method:Method) {
|
||||||
|
game = advance(game,state => state.decision?.kind === 'richeseBlackMarket');
|
||||||
|
assert.ok(player(game,f.richese).hand.some(card => card.id === f.targetCard));
|
||||||
|
game = act(game,f.richese,{type:'decision',event:game.richeseBidding!.event,
|
||||||
|
card:f.targetCard,method,...(method === 'onceAround' ? {direction:'clockwise'} : {})});
|
||||||
|
while (game.response) {
|
||||||
|
const actor = game.players.find(seat => !game.response!.passed.includes(seat.id)); assert.ok(actor);
|
||||||
|
game = act(game,actor.id,{type:'passResponse'});
|
||||||
|
}
|
||||||
|
assert.equal(game.richeseAuction?.source,'blackMarket');
|
||||||
|
assert.equal(game.richeseAuction?.method,method);
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
function reject(game:Game,actor:string,action:Action) {
|
||||||
|
const before = structuredClone(game);
|
||||||
|
assert.throws(() => act(game,actor,action));
|
||||||
|
assert.deepEqual(game,before,'An invalid guide keeps the standing lot and both commitments');
|
||||||
|
}
|
||||||
|
|
||||||
|
function passRemainder(game:Game,method:Method,event:string) {
|
||||||
|
while (game.richeseAuction?.event === event && !game.richeseAuction.outcome) {
|
||||||
|
const lot = game.richeseAuction;
|
||||||
|
const actor = method === 'silent' ? lot.eligible.find(id => !Object.hasOwn(lot.sealed,id)) : lot.active;
|
||||||
|
assert.ok(actor);
|
||||||
|
game = act(game,actor,{type:'richeseBid',event,amount:method === 'silent' ? 0 : null,allyPayment:0});
|
||||||
|
}
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const method of ['normal','onceAround','silent'] as const)
|
||||||
|
for (const early of ['yes','no'] as const) void test(
|
||||||
|
`Advanced ${method}: phase Yes and early ${early} share a funded Black Market guide`, () => {
|
||||||
|
const f = begin(early), before = player(f.game,f.target).spice;
|
||||||
|
assert.equal(before,10);
|
||||||
|
let game = open(f.game,f.f,method);
|
||||||
|
if (method !== 'silent')
|
||||||
|
game = advance(game,state => clean(state) && state.richeseAuction?.active === f.target);
|
||||||
|
const lot = game.richeseAuction!, guide = viewGame(game,f.target).phaseAnyBidGuide?.action;
|
||||||
|
assert.ok(guide,'A current native bid can satisfy the phase Yes');
|
||||||
|
assert.equal(guide.type,'richeseBid'); assert.equal(guide.event,lot.event);
|
||||||
|
assert.equal(guide.amount,6);
|
||||||
|
assert.equal(guide.phaseAnyBidPromiseEvent,f.phase.event);
|
||||||
|
assert.doesNotThrow(() => act(game,f.target,guide));
|
||||||
|
reject(game,f.target,{...guide,phaseAnyBidPromiseEvent:'stale-phase-event'});
|
||||||
|
reject(game,f.target,{...guide,event:'stale-market-event'});
|
||||||
|
if (early === 'yes')
|
||||||
|
reject(game,f.target,{type:'richeseBid',event:lot.event,amount:7,allyPayment:0});
|
||||||
|
for (const difficulty of DIFFICULTIES) {
|
||||||
|
const bot = viewGame(game,f.target); bot.players.find(seat => seat.id === f.target)!.bot = difficulty;
|
||||||
|
const action = botActions(bot)[0]; assert.deepEqual(action,guide,difficulty);
|
||||||
|
assert.doesNotThrow(() => act(game,f.target,action),difficulty);
|
||||||
|
}
|
||||||
|
const old = structuredClone(game);
|
||||||
|
game = act(game,f.target,guide);
|
||||||
|
assert.ok(game.phaseAnyBidPromises?.some(row => row.event === f.phase.event && row.fulfilled));
|
||||||
|
assert.ok(game.earlyRicheseBidPromises?.some(row => row.id === f.cache.id && !row.boundEvent && !row.released));
|
||||||
|
assert.equal(player(game,f.target).spice,before,'The market bid has not been paid early');
|
||||||
|
reject(game,f.target,guide);
|
||||||
|
if (method === 'silent') {
|
||||||
|
assert.equal(viewGame(game,f.f.asker).richeseAuction?.revealedBids,null);
|
||||||
|
assert.equal(viewGame(game,f.f.asker).richeseAuction?.ownBid,null);
|
||||||
|
}
|
||||||
|
assert.notDeepEqual(game,old);
|
||||||
|
game = passRemainder(game,method,lot.event);
|
||||||
|
game = advance(game,state => player(state,f.target).hand.some(card => card.id === f.f.targetCard));
|
||||||
|
assert.equal(player(game,f.target).spice,before-6);
|
||||||
|
assert.deepEqual(inventory(game),f.f.originalCards);
|
||||||
|
game = advance(game,state => clean(state) && state.richeseAuction?.source === 'cache' &&
|
||||||
|
state.richeseAuction.method === 'silent' && !state.richeseAuction.outcome,[],{position:'first',method:'silent'});
|
||||||
|
const cacheEvent = game.richeseAuction!.event;
|
||||||
|
assert.equal(game.earlyRicheseBidPromises?.find(row => row.id === f.cache.id)?.boundEvent,cacheEvent);
|
||||||
|
const cacheAction = early === 'yes' ? viewGame(game,f.target).richeseBidPromiseGuide?.action :
|
||||||
|
{type:'richeseBid',event:cacheEvent,amount:2,allyPayment:0};
|
||||||
|
assert.ok(cacheAction);
|
||||||
|
if (early === 'yes') assert.equal(cacheAction.amount,4);
|
||||||
|
game = act(game,f.target,cacheAction);
|
||||||
|
assert.ok(game.richeseBidPromises?.some(row => row.id === f.cache.id && row.fulfilled));
|
||||||
|
assert.deepEqual(inventory(game),f.f.originalCards);
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('Advanced Black Market seller self-retention does not consume the promised cache hand slot', () => {
|
||||||
|
const f = begin('yes',true);
|
||||||
|
let game = open(f.game,f.f,'silent');
|
||||||
|
const before = player(game,f.target).spice, hand = player(game,f.target).hand.map(card => card.id).sort();
|
||||||
|
assert.equal(before,5); assert.equal(hand.length,3);
|
||||||
|
const lot = game.richeseAuction!, guide = viewGame(game,f.target).phaseAnyBidGuide?.action;
|
||||||
|
assert.ok(guide); assert.equal(guide.event,lot.event); assert.equal(guide.amount,2);
|
||||||
|
game = act(game,f.target,guide);
|
||||||
|
game = passRemainder(game,'silent',lot.event);
|
||||||
|
assert.deepEqual(player(game,f.target).hand.map(card => card.id).sort(),hand);
|
||||||
|
assert.equal(player(game,f.target).spice,before-2);
|
||||||
|
assert.ok(game.phaseAnyBidPromises?.some(row => row.event === f.phase.event && row.fulfilled));
|
||||||
|
assert.ok(game.earlyRicheseBidPromises?.some(row => row.id === f.cache.id && !row.released));
|
||||||
|
game = advance(game,state => clean(state) && state.richeseAuction?.source === 'cache' &&
|
||||||
|
state.richeseAuction.method === 'silent' && !state.richeseAuction.outcome,[],{position:'first',method:'silent'});
|
||||||
|
const cache = viewGame(game,f.target).richeseBidPromiseGuide?.action; assert.ok(cache);
|
||||||
|
assert.equal(cache.amount,3);
|
||||||
|
game = act(game,f.target,cache);
|
||||||
|
assert.ok(game.richeseBidPromises?.some(row => row.id === f.cache.id && row.fulfilled));
|
||||||
|
assert.deepEqual(inventory(game),f.f.originalCards);
|
||||||
|
});
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import { viewGame, type Game } from '../game/engine';
|
||||||
|
import {
|
||||||
|
actTruthtranceRichesePromises as act,
|
||||||
|
advanceTruthtranceRichesePromises as advance,
|
||||||
|
createTruthtranceRichesePromisesFixture as fixture,
|
||||||
|
passTruthRicheseFreshDiscard,
|
||||||
|
truthtranceRichesePromisesInventory as inventory,
|
||||||
|
truthtranceRichesePromisesPlayer as player,
|
||||||
|
type TruthtranceRichesePromisesFixture,
|
||||||
|
} from './fixture-truthtrance-richese-promises';
|
||||||
|
|
||||||
|
/** Real public Advanced R/A/E setup and real native Black Market. Two original
|
||||||
|
* cards move from unopened zones: the second Truthtrance to Atreides, Semuta
|
||||||
|
* to Richese. Richese actually reclaims the first discarded Truthtrance with
|
||||||
|
* Semuta to ask the third question; no extra physical card is invented. */
|
||||||
|
function source() {
|
||||||
|
const f = fixture({advanced:true}), game = structuredClone(f.earlySource);
|
||||||
|
const truthAt = game.deck.findIndex(card => card.effect === 'truthtrance' && card.id !== f.truth);
|
||||||
|
assert.ok(truthAt >= 0); const [second] = game.deck.splice(truthAt,1);
|
||||||
|
player(game,f.asker).hand.push(second);
|
||||||
|
const semutaAt = game.richeseCache!.findIndex(card => card.effect === 'semutaDrug');
|
||||||
|
assert.ok(semutaAt >= 0); const [semuta] = game.richeseCache!.splice(semutaAt,1);
|
||||||
|
player(game,f.richese).hand.push(semuta);
|
||||||
|
assert.deepEqual(inventory(game),f.originalCards);
|
||||||
|
return {f,game,second:second.id,semuta:semuta.id};
|
||||||
|
}
|
||||||
|
|
||||||
|
function ask(game:Game, f:TruthtranceRichesePromisesFixture, asker:string, card:string,
|
||||||
|
kind:'phaseAnyBid'|'earlyRicheseBid', minimum:number, answer:'yes'|'no', claim = false) {
|
||||||
|
game = act(game,asker,{type:'card',card});
|
||||||
|
game = advance(game,state => state.truthtrance?.stage === 'ask');
|
||||||
|
game = act(game,asker,{type:'truthAsk',question:{kind,target:f.emperor,turn:game.turn,minimum}});
|
||||||
|
const view = viewGame(game,f.emperor);
|
||||||
|
const options = kind === 'phaseAnyBid' ? view.truthPhaseAnyBidAnswers : view.truthEarlyRicheseBidAnswers;
|
||||||
|
assert.ok(options?.includes(answer),`${kind} ${answer} must retain its native witness`);
|
||||||
|
game = act(game,f.emperor,{type:'truthAnswer',answer});
|
||||||
|
if (!claim) return passTruthRicheseFreshDiscard(game);
|
||||||
|
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
|
||||||
|
assert.equal(viewGame(game,f.richese).semutaReaction?.canCommit,true);
|
||||||
|
game = act(game,f.richese,{type:'semutaCommit',event:pending.batch.event});
|
||||||
|
assert.equal(game.pendingTreacheryDiscard,null);
|
||||||
|
assert.ok(player(game,f.richese).hand.some(item => item.id === card));
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test('Advanced unresolved Black Market releases only the phase Yes made impossible by an external shortfall', () => {
|
||||||
|
const s = source();
|
||||||
|
let game = ask(s.game,s.f,s.f.asker,s.f.truth,'phaseAnyBid',4,'yes',true);
|
||||||
|
assert.ok(game.discard.some(card => card.id === s.semuta));
|
||||||
|
game = ask(game,s.f,s.f.asker,s.second,'phaseAnyBid',8,'yes');
|
||||||
|
game = ask(game,s.f,s.f.richese,s.f.truth,'earlyRicheseBid',4,'no');
|
||||||
|
assert.equal(player(game,s.f.emperor).spice,10);
|
||||||
|
const phase4 = game.phaseAnyBidPromises?.find(row => row.player === s.f.emperor && row.minimum === 4);
|
||||||
|
const phase8 = game.phaseAnyBidPromises?.find(row => row.player === s.f.emperor && row.minimum === 8);
|
||||||
|
const early = game.earlyRicheseBidPromises?.find(row => row.player === s.f.emperor);
|
||||||
|
assert.ok(phase4 && phase8 && early && !early.answer);
|
||||||
|
assert.deepEqual(inventory(game),s.f.originalCards);
|
||||||
|
game = advance(game,state => state.decision?.kind === 'richeseBlackMarket');
|
||||||
|
game = act(game,s.f.richese,{type:'decision',event:game.richeseBidding!.event,
|
||||||
|
card:s.f.targetCard,method:'silent'});
|
||||||
|
while (game.response) {
|
||||||
|
const actor = game.players.find(seat => !game.response!.passed.includes(seat.id)); assert.ok(actor);
|
||||||
|
game = act(game,actor.id,{type:'passResponse'});
|
||||||
|
}
|
||||||
|
assert.equal(game.richeseAuction?.source,'blackMarket');
|
||||||
|
const event = game.richeseAuction!.event;
|
||||||
|
// Controlled external-loss supplement: the three answers and the actual
|
||||||
|
// market are native; this models another effect reducing the target's cash
|
||||||
|
// before a different player's real sealed decline. No card/receipt changes.
|
||||||
|
game = structuredClone(game);
|
||||||
|
player(game,s.f.emperor).spice = 5;
|
||||||
|
const before = structuredClone(game), actor = s.f.asker;
|
||||||
|
assert.notEqual(actor,s.f.emperor);
|
||||||
|
game = act(game,actor,{type:'richeseBid',event,amount:0,allyPayment:0});
|
||||||
|
assert.equal(player(before,s.f.emperor).spice,5);
|
||||||
|
const lower = game.phaseAnyBidPromises?.find(row => row.event === phase4.event);
|
||||||
|
const higher = game.phaseAnyBidPromises?.find(row => row.event === phase8.event);
|
||||||
|
assert.ok(lower && higher);
|
||||||
|
assert.equal(!!lower.fulfilled,false); assert.equal(!!lower.released,false,
|
||||||
|
'The affordable four-spice Black Market declaration remains available');
|
||||||
|
assert.equal(!!higher.fulfilled,false); assert.equal(!!higher.released,true,
|
||||||
|
'Only the independently impossible eight-spice answer releases');
|
||||||
|
assert.ok(game.earlyRicheseBidPromises?.some(row => row.id === early.id && !row.released && !row.boundEvent));
|
||||||
|
assert.equal(game.richeseAuction?.event,event);
|
||||||
|
assert.equal(viewGame(game,s.f.richese).richeseAuction?.revealedBids,null);
|
||||||
|
const guide = viewGame(game,s.f.emperor).phaseAnyBidGuide?.action; assert.ok(guide);
|
||||||
|
assert.equal(guide.type,'richeseBid'); assert.equal(guide.event,event); assert.equal(guide.amount,4);
|
||||||
|
game = act(game,s.f.emperor,guide);
|
||||||
|
assert.ok(game.phaseAnyBidPromises?.some(row => row.event === phase4.event && row.fulfilled));
|
||||||
|
assert.ok(game.phaseAnyBidPromises?.some(row => row.event === phase8.event && row.released));
|
||||||
|
assert.deepEqual(inventory(game),s.f.originalCards);
|
||||||
|
});
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import { viewGame, type Game } from '../game/engine';
|
||||||
|
import {
|
||||||
|
actTruthtranceRichesePromises as act,
|
||||||
|
advanceTruthtranceRichesePromises as advance,
|
||||||
|
createTruthtranceRichesePromisesFixture as fixture,
|
||||||
|
passTruthRicheseFreshDiscard,
|
||||||
|
truthtranceRichesePromisesClean as clean,
|
||||||
|
truthtranceRichesePromisesInventory as inventory,
|
||||||
|
truthtranceRichesePromisesPlayer as player,
|
||||||
|
} from './fixture-truthtrance-richese-promises';
|
||||||
|
|
||||||
|
/** Public Advanced Richese/Atreides/Emperor setup. The original Semuta moves
|
||||||
|
* from cache to its owner, and the original second Truthtrance moves from the
|
||||||
|
* unopened deck to Atreides. No answer, purse, auction or reaction is made up. */
|
||||||
|
function source(two: boolean) {
|
||||||
|
const f = fixture({advanced:true});
|
||||||
|
const game = structuredClone(f.earlySource);
|
||||||
|
assert.equal(game.semutaAdvancedOrdinaryPreview,true);
|
||||||
|
const cache = game.richeseCache!;
|
||||||
|
const semutaAt = cache.findIndex(card => card.effect === 'semutaDrug'); assert.ok(semutaAt >= 0);
|
||||||
|
const [semuta] = cache.splice(semutaAt,1); player(game,f.richese).hand.push(semuta);
|
||||||
|
let second: string | undefined;
|
||||||
|
if (two) {
|
||||||
|
const at = game.deck.findIndex(card => card.effect === 'truthtrance' && card.id !== f.truth); assert.ok(at >= 0);
|
||||||
|
const [card] = game.deck.splice(at,1); player(game,f.asker).hand.push(card); second = card.id;
|
||||||
|
}
|
||||||
|
assert.deepEqual(inventory(game),f.originalCards);
|
||||||
|
return {f,game,second,semuta:semuta.id};
|
||||||
|
}
|
||||||
|
|
||||||
|
function parent(game: Game) {
|
||||||
|
return structuredClone({turn:game.turn,phase:game.phase,active:game.active,ready:game.ready,order:game.order,
|
||||||
|
charityOrder:game.charityOrder,auction:game.auction,richeseAuction:game.richeseAuction,
|
||||||
|
richeseBidding:game.richeseBidding,richeseFunding:game.richeseFunding,aid:game.aid});
|
||||||
|
}
|
||||||
|
|
||||||
|
function reachQuestions(game: Game, asker: string, card: string, second?: string): Game {
|
||||||
|
game = act(game,asker,{type:'card',card,...(second ? {cards:[second]} : {})});
|
||||||
|
while (game.truthtrance?.stage === 'priority') {
|
||||||
|
const actor = game.players.find(seat => !game.truthtrance!.passed.includes(seat.id)); assert.ok(actor);
|
||||||
|
game = act(game,actor.id,{type:'truthPass'});
|
||||||
|
}
|
||||||
|
assert.equal(game.truthtrance?.stage,'ask');
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
function settle(game: Game, owner: string, claim: boolean): Game {
|
||||||
|
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
|
||||||
|
assert.equal(viewGame(game,owner).semutaReaction?.canCommit,true);
|
||||||
|
return claim ? act(game,owner,{type:'semutaCommit',event:pending.batch.event}) : passTruthRicheseFreshDiscard(game);
|
||||||
|
}
|
||||||
|
|
||||||
|
function bidRealCache(game: Game, f: ReturnType<typeof fixture>, earlyId: string, withPhase: boolean) {
|
||||||
|
game = advance(game,state => clean(state) && !!state.richeseAuction &&
|
||||||
|
state.richeseAuction.source === 'cache' && state.richeseAuction.method === 'silent' &&
|
||||||
|
!state.richeseAuction.outcome,[],{position:'first',method:'silent'});
|
||||||
|
const lot = game.richeseAuction!, card = lot.cardId;
|
||||||
|
assert.equal(game.earlyRicheseBidPromises?.find(row => row.id === earlyId)?.boundEvent,lot.event);
|
||||||
|
assert.equal(game.richeseBidPromises?.find(row => row.id === earlyId)?.event,lot.event);
|
||||||
|
const view = viewGame(game,f.emperor);
|
||||||
|
const guide = withPhase ? view.phaseAnyBidGuide?.action : view.richeseBidPromiseGuide?.action;
|
||||||
|
assert.ok(guide); assert.equal(guide.type,'richeseBid'); assert.equal(guide.event,lot.event);
|
||||||
|
assert.equal(guide.amount,4);
|
||||||
|
const before = player(game,f.emperor).spice;
|
||||||
|
game = act(game,f.emperor,guide);
|
||||||
|
assert.equal(player(game,f.emperor).spice,before,'A sealed declaration does not prepay');
|
||||||
|
assert.ok(game.richeseBidPromises?.some(row => row.id === earlyId && row.fulfilled));
|
||||||
|
if (withPhase) assert.ok(game.phaseAnyBidPromises?.some(row => row.player === f.emperor && row.fulfilled));
|
||||||
|
game = advance(game,state => player(state,f.emperor).hand.some(item => item.id === card),[],
|
||||||
|
{position:'first',method:'silent'});
|
||||||
|
assert.deepEqual(inventory(game),f.originalCards);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const claim of [false,true]) void test(
|
||||||
|
`Advanced early cache Yes Semuta ${claim ? 'claim' : 'pass'} preserves the physical future bid`, () => {
|
||||||
|
const s = source(false), original = parent(s.game);
|
||||||
|
let game = reachQuestions(s.game,s.f.asker,s.f.truth);
|
||||||
|
game = act(game,s.f.asker,{type:'truthAsk',question:{kind:'earlyRicheseBid',
|
||||||
|
target:s.f.emperor,turn:game.turn,minimum:4}});
|
||||||
|
assert.ok(viewGame(game,s.f.emperor).truthEarlyRicheseBidAnswers?.includes('yes'));
|
||||||
|
game = act(game,s.f.emperor,{type:'truthAnswer',answer:'yes'});
|
||||||
|
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
|
||||||
|
assert.equal(pending.continuation.kind,'truthtranceDiscard');
|
||||||
|
assert.equal(pending.batch.entries[0].card.id,s.f.truth);
|
||||||
|
const receipt = game.earlyRicheseBidPromises?.find(row => row.player === s.f.emperor); assert.ok(receipt);
|
||||||
|
assert.equal(receipt.boundEvent,undefined);
|
||||||
|
assert.deepEqual(parent(game),original);
|
||||||
|
const tampered = structuredClone(game); tampered.earlyRicheseBidPromises![0].minimum++;
|
||||||
|
assert.throws(() => act(tampered,s.f.richese,{type:'semutaCommit',event:pending.batch.event}),
|
||||||
|
'A standalone early answer is bound to its Semuta continuation');
|
||||||
|
game = settle(game,s.f.richese,claim);
|
||||||
|
assert.equal(game.pendingTreacheryDiscard,null); assert.equal(game.truthtrance,null);
|
||||||
|
assert.equal(player(game,s.f.richese).hand.some(card => card.id === s.f.truth),claim);
|
||||||
|
assert.equal(game.discard.some(card => card.id === s.semuta),claim);
|
||||||
|
assert.deepEqual(parent(game),original);
|
||||||
|
assert.deepEqual(inventory(game),s.f.originalCards);
|
||||||
|
bidRealCache(game,s.f,receipt.id,false);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const first of ['phase','early'] as const) for (const claim of [false,true]) void test(
|
||||||
|
`Advanced ${first} first: joint early and phase Yes survive Semuta ${claim ? 'claim' : 'pass'}`, () => {
|
||||||
|
const s = source(true), original = parent(s.game); assert.ok(s.second);
|
||||||
|
const phase = {kind:'phaseAnyBid',target:s.f.emperor,turn:s.game.turn,minimum:3};
|
||||||
|
const early = {kind:'earlyRicheseBid',target:s.f.emperor,turn:s.game.turn,minimum:4};
|
||||||
|
let game = reachQuestions(s.game,s.f.asker,s.f.truth,s.second);
|
||||||
|
assert.deepEqual(game.truthtrance?.queue.map(row => row.card),[s.f.truth,s.second]);
|
||||||
|
game = act(game,s.f.asker,{type:'truthAsk',question:first === 'phase' ? phase : early});
|
||||||
|
game = act(game,s.f.emperor,{type:'truthAnswer',answer:'yes'});
|
||||||
|
assert.ok(game.pendingTreacheryDiscard?.reaction,'First actual Truth discard has its own Semuta offer');
|
||||||
|
game = passTruthRicheseFreshDiscard(game);
|
||||||
|
assert.deepEqual(game.truthtrance?.queue.map(row => row.card),[s.second]);
|
||||||
|
game = act(game,s.f.asker,{type:'truthAsk',question:first === 'phase' ? early : phase});
|
||||||
|
game = act(game,s.f.emperor,{type:'truthAnswer',answer:'yes'});
|
||||||
|
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
|
||||||
|
assert.equal(pending.continuation.kind,'truthtranceDiscard');
|
||||||
|
assert.equal(pending.continuation.jointEarlyPhaseBid,true);
|
||||||
|
assert.equal(pending.batch.entries[0].card.id,s.second);
|
||||||
|
const earlyReceipt = game.earlyRicheseBidPromises?.find(row => row.player === s.f.emperor); assert.ok(earlyReceipt);
|
||||||
|
const earlyPromises = structuredClone(game.earlyRicheseBidPromises), phasePromises = structuredClone(game.phaseAnyBidPromises);
|
||||||
|
assert.deepEqual(parent(game),original);
|
||||||
|
for (const family of ['phaseAnyBidPromises','earlyRicheseBidPromises'] as const) {
|
||||||
|
const tampered = structuredClone(game); tampered[family]![0].minimum++;
|
||||||
|
assert.throws(() => act(tampered,s.f.richese,{type:'semutaCommit',event:pending.batch.event}),
|
||||||
|
`The joint completed answer binds ${family}`);
|
||||||
|
}
|
||||||
|
game = settle(game,s.f.richese,claim);
|
||||||
|
assert.equal(game.pendingTreacheryDiscard,null); assert.equal(game.truthtrance,null);
|
||||||
|
assert.equal(player(game,s.f.richese).hand.some(card => card.id === s.second),claim);
|
||||||
|
assert.equal(game.discard.some(card => card.id === s.semuta),claim);
|
||||||
|
assert.deepEqual(game.earlyRicheseBidPromises,earlyPromises);
|
||||||
|
assert.deepEqual(game.phaseAnyBidPromises,phasePromises);
|
||||||
|
assert.deepEqual(parent(game),original);
|
||||||
|
assert.deepEqual(inventory(game),s.f.originalCards);
|
||||||
|
bidRealCache(game,s.f,earlyReceipt.id,true);
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('Advanced early cache Unknown keeps the Truthtrance and opens no Semuta discard', () => {
|
||||||
|
const s = source(false);
|
||||||
|
let game = reachQuestions(s.game,s.f.asker,s.f.truth);
|
||||||
|
game = act(game,s.f.asker,{type:'truthAsk',question:{kind:'earlyRicheseBid',
|
||||||
|
target:s.f.emperor,turn:game.turn,minimum:99}});
|
||||||
|
assert.ok(viewGame(game,s.f.emperor).truthEarlyRicheseBidAnswers?.includes('unknown'));
|
||||||
|
game = act(game,s.f.emperor,{type:'truthAnswer',answer:'unknown'});
|
||||||
|
assert.ok(game.pendingTreacheryDiscard == null);
|
||||||
|
assert.ok(player(game,s.f.asker).hand.some(card => card.id === s.f.truth));
|
||||||
|
assert.equal(game.earlyRicheseBidPromises?.length ?? 0,0);
|
||||||
|
assert.deepEqual(inventory(game),s.f.originalCards);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user