Support mixed Truthtrance questions in Richese auctions
Verify and publish checkpoint container / container (push) Canceled after 0s
Verify and publish checkpoint container / container (push) Canceled after 0s
This commit is contained in:
1 parent
1f3bc349ba
commit
6ce9a4b4a7
16 files changed
+504
-10
No files matched your search
+62
-1
@@ -63,6 +63,7 @@ import { AllianceExpressionPromiseError, allianceExpressionOutcomes, findAllianc
|
||||
type AllianceExpression, type AllianceExpressionClaim, type AllianceExpressionPromise } from './alliance-expression-promises';
|
||||
import type { AllianceActionClaim, MixedAllianceClaim } from './mixed-alliance-question';
|
||||
import { mixedBidMinimum, type MixedBidClaim } from './mixed-bid-question';
|
||||
import { mixedRicheseBidResidual, type MixedRicheseBidClaim } from './mixed-richese-bid-question';
|
||||
import type { RevivalActionClaim, MixedRevivalClaim } from './mixed-revival-question';
|
||||
import type { BribePaymentClaim, MixedBribeClaim } from './mixed-bribe-question';
|
||||
import { compileMixedActionExpression, MixedActionQuestionError, type CompiledMixedAction } from './mixed-action-question';
|
||||
@@ -2507,6 +2508,10 @@ export type Game = {
|
||||
mixedBidQuestions?: (MixedBidClaim & {
|
||||
event: string; player: string; asker: string; answer: boolean; binding: boolean;
|
||||
})[];
|
||||
/** Original aggregate linked by ID to its native Richese bid obligation. */
|
||||
mixedRicheseBidQuestions?: (MixedRicheseBidClaim & {
|
||||
id: string; player: string; asker: string; answer: boolean; binding: boolean;
|
||||
})[];
|
||||
revivalPromises?: RevivalPromise[];
|
||||
leaderRevivalPromises?: LeaderRevivalPromise[];
|
||||
gholaLeaderPromises?: GholaLeaderPromise[];
|
||||
@@ -8031,6 +8036,9 @@ function truthtranceDiscardSignature(g: Game, next: TruthDiscardContinuation) {
|
||||
...(next.record.question.kind === 'mixedBid' ? {
|
||||
mixedBidQuestions: g.mixedBidQuestions, bidPromises: g.bidPromises,
|
||||
} : {}),
|
||||
...(next.record.question.kind === 'mixedRicheseBid' ? {
|
||||
mixedRicheseBidQuestions: g.mixedRicheseBidQuestions, richeseBidPromises: g.richeseBidPromises,
|
||||
} : {}),
|
||||
...(next.record.question.kind === 'mixedRevival' ? {
|
||||
mixedRevivalQuestions: g.mixedRevivalQuestions, revivalExpressionPromises: g.revivalExpressionPromises,
|
||||
} : {}),
|
||||
@@ -18573,6 +18581,49 @@ function bindRicheseBidTruth(g: Game,p: Player,claim: RicheseBidClaim,answer: bo
|
||||
'Choose an answer compatible with this Richese auction bid.');
|
||||
(g.richeseBidPromises ??= []).push({...claim,id:crypto.randomUUID(),player:p.id,asker,answer});
|
||||
}
|
||||
function compileMixedRicheseBid(g: Game, p: Player, claim: MixedRicheseBidClaim, answer: boolean) {
|
||||
const compiled = compileMixedActionExpression(claim.mixed,
|
||||
fact => truthFactAnswer(p, fact, truthKnowledgeOf(g, p)), answer);
|
||||
return compiled.kind === 'constant' ? {constant:compiled.value} :
|
||||
{residual:mixedRicheseBidResidual(claim,compiled)};
|
||||
}
|
||||
function mixedRicheseBidTruthAnswers(g: Game, p: Player, claim: MixedRicheseBidClaim): TruthAnswer[] {
|
||||
const lot = g.richeseAuction;
|
||||
if (!richeseBidWindow(g) || !lot || claim.turn !== g.turn || claim.event !== lot.event ||
|
||||
!lot.eligible.includes(p.id) || lot.acted.includes(p.id) ||
|
||||
!richeseBidFitsHand(lot.source,lot.owner,p.id,p.hand.length,handLimit(p))) return [];
|
||||
const answers: TruthAnswer[] = [];
|
||||
for (const answer of [true,false]) {
|
||||
const compiled = compileMixedRicheseBid(g,p,claim,answer);
|
||||
if (compiled.constant !== undefined ? compiled.constant === answer :
|
||||
richeseBidTruthAnswers(g,p,compiled.residual!).includes(answer ? 'yes' : 'no'))
|
||||
answers.push(answer ? 'yes' : 'no');
|
||||
}
|
||||
return answers.length ? answers : ['unknown'];
|
||||
}
|
||||
function bindMixedRicheseBidTruth(g: Game,p: Player,claim: MixedRicheseBidClaim,answer: boolean,asker: string) {
|
||||
requireRule(mixedRicheseBidTruthAnswers(g,p,claim).includes(answer ? 'yes' : 'no'),
|
||||
'Choose a mixed answer compatible with this Richese auction.');
|
||||
const compiled = compileMixedRicheseBid(g,p,claim,answer);
|
||||
let id: string;
|
||||
if (compiled.residual) {
|
||||
bindRicheseBidTruth(g,p,compiled.residual,answer,asker);
|
||||
id = g.richeseBidPromises!.at(-1)!.id;
|
||||
} else {
|
||||
requireRule(compiled.constant === answer, 'Retain the truthful whole mixed-bid answer.');
|
||||
id = crypto.randomUUID();
|
||||
}
|
||||
(g.mixedRicheseBidQuestions ??= []).push({turn:claim.turn,event:claim.event,
|
||||
mixed:structuredClone(claim.mixed),id,player:p.id,asker,answer,binding:!!compiled.residual});
|
||||
}
|
||||
function projectedMixedRicheseBidPromises(g: Game, player: string) {
|
||||
return (g.mixedRicheseBidQuestions ?? []).filter(row => row.player === player).map(row => {
|
||||
const bound = g.richeseBidPromises?.find(promise => promise.id === row.id);
|
||||
return {id:row.id,turn:row.turn,event:row.event,player:row.player,asker:row.asker,
|
||||
mixed:structuredClone(row.mixed),answer:row.answer,
|
||||
fulfilled:!row.binding || bound?.fulfilled === true,released:bound?.released === true};
|
||||
});
|
||||
}
|
||||
function richeseBidIntegrity(g: Game) {
|
||||
richeseBidRule(() => validateRicheseBidPromises(g.richeseBidPromises ?? [],g.players.map(row => row.id)));
|
||||
}
|
||||
@@ -45363,6 +45414,8 @@ function applyActionInner(
|
||||
bindRevival: bindRevivalTruth,
|
||||
mixedBidAnswers: mixedBidTruthAnswers,
|
||||
bindMixedBid: bindMixedBidTruth,
|
||||
mixedRicheseBidAnswers: mixedRicheseBidTruthAnswers,
|
||||
bindMixedRicheseBid: bindMixedRicheseBidTruth,
|
||||
bidAnswers: bidTruthAnswers,
|
||||
bindBid: bindBidTruth,
|
||||
charityAnswers: charityTruthAnswers,
|
||||
@@ -49848,11 +49901,19 @@ export function viewGame(state: Game, id: string, now?: number) {
|
||||
}).map(player => player.id) : [],
|
||||
truthRicheseBidAnswers: g.truthtrance?.stage === 'answer' && g.truthtrance.question?.target === id &&
|
||||
g.truthtrance.question.kind === 'richeseBid' ? richeseBidTruthAnswers(g,me,g.truthtrance.question) : null,
|
||||
truthMixedRicheseBidTargets: richeseBidWindow(g) ? g.players.filter(player => {
|
||||
const lot = g.richeseAuction!;
|
||||
return lot.eligible.includes(player.id) && !lot.acted.includes(player.id);
|
||||
}).map(player => player.id) : [],
|
||||
truthMixedRicheseBidAnswers: g.truthtrance?.stage === 'answer' && g.truthtrance.question?.target === id &&
|
||||
g.truthtrance.question.kind === 'mixedRicheseBid' ? mixedRicheseBidTruthAnswers(g,me,g.truthtrance.question) : null,
|
||||
mixedRicheseBidPromises: projectedMixedRicheseBidPromises(g,id),
|
||||
truthEarlyRicheseBidTargets: earlyRicheseBidWindow(g) ? g.players.map(player => player.id) : [],
|
||||
truthEarlyRicheseBidAnswers: g.truthtrance?.stage === 'answer' && g.truthtrance.question?.target === id &&
|
||||
g.truthtrance.question.kind === 'earlyRicheseBid' ? earlyRicheseBidTruthAnswers(g,me,g.truthtrance.question) : null,
|
||||
ownEarlyRicheseBidPromises: (g.earlyRicheseBidPromises ?? []).filter(row => row.player === id).map(row => ({...row})),
|
||||
richeseBidPromises: (g.richeseBidPromises ?? []).filter(row => row.player === id).map(row => ({...row})),
|
||||
richeseBidPromises: (g.richeseBidPromises ?? []).filter(row => row.player === id &&
|
||||
!g.mixedRicheseBidQuestions?.some(question => question.id === row.id)).map(row => ({...row})),
|
||||
richeseBidPromiseGuide: projectedRicheseBidGuide(g,id),
|
||||
truthPhaseBidTargets: phaseBidQuestionWindow(g) ? g.players.map(player => player.id) : [],
|
||||
truthPhaseBidAnswers: g.truthtrance?.stage === 'answer' && g.truthtrance.question?.target === id &&
|
||||
|
||||
Reference in new issue
Block a user