Allow recovered Sapho at Testing Station
Verify and publish checkpoint container / container (push) Successful in 11m20s

This commit is contained in:
Quintine committed 2026-11-16 19:50:58 +11:00
1 parent 1ff520a9fc
commit 05f7fc8f20
12 files changed
+371 -33

No files matched your search

+14
View File
@@ -17,6 +17,20 @@ open mode gates.
## Current checkpoint and work ## Current checkpoint and work
**Recovered Sapho at the Testing Station — 16 November. Prototyped /
Partial.** In supported Basic and Advanced Semuta/Discovery previews, an
occupant who recovers the discarded physical Juice of Sapho may reorder the
two pending Testing Station adjustments again. The neutral priority reopens
after the discard reaction; both adjustments and the original storm remain.
Seven related unit files pass 30 cases. The online ordering is provisional;
other modules, complete games and deployed
acceptance remain open.
[Scope](DISCOVERY_PROTOTYPE.md#recovered-sapho-at-the-testing-station--16-november-2026).
The next scoped bid interaction is an early Richese-cache answer combined with
an all-auction answer. It needs a two-stage funded and hand-space forecast before
the existing guards can be relaxed; a local, unverified test draft is retained
under ignored `work/prototype-drafts/` when available.
**Joint all-auction and ordinary bid answers — 16 November. Prototyped / **Joint all-auction and ordinary bid answers — 16 November. Prototyped /
Partial.** Current ordinary and all-auction Truthtrance bid answers can Partial.** Current ordinary and all-auction Truthtrance bid answers can
coexist in either order, including mixed factual questions. A shared guide coexist in either order, including mixed factual questions. A shared guide
+23 -5
View File
@@ -68,6 +68,24 @@ shipment. The original paired Ecaz/Moritani entry is also recognized. The
provisional ordering, controlled fixture staging and remaining combinations are provisional ordering, controlled fixture staging and remaining combinations are
recorded in [the entry contract](MORITANI_ENTRY_TIMING.md#great-maker-sneak-arrivals--29-october-2026). recorded in [the entry contract](MORITANI_ENTRY_TIMING.md#great-maker-sneak-arrivals--29-october-2026).
## Recovered Sapho at the Testing Station — 16 November 2026
**Prototyped / Partial.** In supported Basic and Advanced Semuta/Discovery
previews, a Testing Station occupant can recover the physical Juice of Sapho
and use it again to change their pending position before either occupant acts.
After a fresh Sapho discard reaction, both occupants receive a neutral priority
independent of private hands; completed choices, the original storm and physical
card custody are preserved. Each use binds a new event and preceding ordering;
older unmarked discard continuations retain their prior timing and signatures.
This composes the provisional online priority and printed Sapho effect; it is
not a publisher ruling. Other module combinations, full games and deployed
acceptance remain open. [Basic and Advanced replay cases](../tests/sapho-testing-station-replay.test.ts)
use public starts and disclosed conserved staging of the station, forces and
cards. [Ordering cases](../tests/discovery-storm-sapho-quote.test.ts) cover
the event chain, stale actions and refusal after a choice. [Compatibility
cases](../tests/sapho-testing-station-replay-compat.test.ts) cover an old pending
discard and all four bot difficulties. Seven related unit files pass 30 cases.
## Sapho at Ecological Testing Station — 29 October 2026 ## Sapho at Ecological Testing Station — 29 October 2026
**Prototyped / Partial.** Before either of two original occupants chooses, **Prototyped / Partial.** Before either of two original occupants chooses,
@@ -75,8 +93,8 @@ an eligible holder can discard Juice of Sapho to change its own choice to
first or last. The original physical storm order, source and token are retained; first or last. The original physical storm order, source and token are retained;
both occupants still adjust the cumulative distance once. The reordered frame both occupants still adjust the cumulative distance once. The reordered frame
has a new event and a signed record of the original order. Unchanged frames has a new event and a signed record of the original order. Unchanged frames
retain their original signatures. A position already held, a completed choice, retain their original signatures. A position already held or a completed choice
and another use after a recovered Sapho are not offered in this first version. cannot be selected. Recovered Sapho replay is described above.
In the supported Semuta/Discovery profile, the committed reorder pauses for In the supported Semuta/Discovery profile, the committed reorder pauses for
the neutral discard reaction; claim or pass resumes the same next station the neutral discard reaction; claim or pass resumes the same next station
choice. The ordering is a provisional online interpretation of Sapho's choice. The ordering is a provisional online interpretation of Sapho's
@@ -85,9 +103,9 @@ New two-occupant Station decisions with Richese seated open a neutral shared
priority before either adjustment. Each occupant may continue or use its own priority before either adjustment. Each occupant may continue or use its own
eligible Sapho; an automated occupant passes without consuming the original eligible Sapho; an automated occupant passes without consuming the original
station choice. The window is independent of private card custody and closes station choice. The window is independent of private card custody and closes
when both pass or Sapho is used. Already-open unstamped choices retain their when both pass or Sapho is used. Fresh Semuta reactions reopen the shared
existing timing. Replay of a recovered Sapho and broader combinations remain priority; already-open unstamped continuations retain their existing timing.
unfinished. Broader combinations remain unfinished.
13 September 2026. The connected Discovery batches are **Prototyped**, with 13 September 2026. The connected Discovery batches are **Prototyped**, with
partial rules coverage. It connects physical components, real actions, private partial rules coverage. It connects physical components, real actions, private
+7
View File
@@ -1,5 +1,12 @@
# Rule decision index # Rule decision index
## Recovered Sapho at the Testing Station — 16 November 2026
The provisional two-occupant ordering permits a second physical Sapho play
after Semuta recovery, before either adjustment. A fresh neutral priority
preserves the original storm and both occupants' choices.
[Scope](DISCOVERY_PROTOTYPE.md#recovered-sapho-at-the-testing-station--16-november-2026).
## Joint phase-wide and ordinary bid answers — 16 November 2026 ## Joint phase-wide and ordinary bid answers — 16 November 2026
Current ordinary and all-auction phase bid answers share the native bid; Current ordinary and all-auction phase bid answers share the native bid;
+50 -25
View File
@@ -16,6 +16,13 @@ export type StormMovementSource = {
distance: number; distance: number;
signature: string; signature: string;
}; };
type SaphoStationReceipt = {
event: string;
nextEvent: string;
originalOrder: string[];
holder: string;
mode: 'first' | 'last';
};
export type DiscoveryStorm = { export type DiscoveryStorm = {
event: string; event: string;
turn: number; turn: number;
@@ -30,14 +37,10 @@ export type DiscoveryStorm = {
order: string[]; order: string[];
choices: { owner: string; delta: -1 | 0 | 1 }[]; choices: { owner: string; delta: -1 | 0 | 1 }[];
}; };
/** One provisional Sapho reorder, bound to the original physical order. */ /** Latest provisional reorder. Earlier saved single-use receipts keep this shape. */
sapho?: { sapho?: SaphoStationReceipt;
event: string; /** Earlier receipts, present only after an actual subsequent physical play. */
nextEvent: string; saphoHistory?: SaphoStationReceipt[];
originalOrder: string[];
holder: string;
mode: 'first' | 'last';
};
}; };
export type DiscoveryStormContext = Pick< export type DiscoveryStormContext = Pick<
Game, Game,
@@ -94,6 +97,7 @@ export function discoveryStormSignature(
]; ];
if (frame.queue) values.push(frame.queue.order, frame.queue.choices); if (frame.queue) values.push(frame.queue.order, frame.queue.choices);
if (frame.sapho) values.push(frame.sapho); if (frame.sapho) values.push(frame.sapho);
if (frame.saphoHistory) values.push(frame.saphoHistory);
return JSON.stringify(values); return JSON.stringify(values);
} }
export function discoveryStormDistance(frame: DiscoveryStorm): number { export function discoveryStormDistance(frame: DiscoveryStorm): number {
@@ -174,7 +178,9 @@ export function validateDiscoveryStorm(
record(frame) && record(frame) &&
Object.keys(frame).sort().join(',') === (frame.queue Object.keys(frame).sort().join(',') === (frame.queue
? (frame.sapho ? (frame.sapho
? 'base,delta,event,from,owner,queue,sapho,signature,stage,token,turn' ? (frame.saphoHistory
? 'base,delta,event,from,owner,queue,sapho,saphoHistory,signature,stage,token,turn'
: 'base,delta,event,from,owner,queue,sapho,signature,stage,token,turn')
: 'base,delta,event,from,owner,queue,signature,stage,token,turn') : 'base,delta,event,from,owner,queue,signature,stage,token,turn')
: 'base,delta,event,from,owner,signature,stage,token,turn') && : 'base,delta,event,from,owner,signature,stage,token,turn') &&
typeof frame.event === 'string' && typeof frame.event === 'string' &&
@@ -223,18 +229,33 @@ export function validateDiscoveryStorm(
need(distance >= 0 && distance <= 40, 'Every station choice must retain a legal current distance.'); need(distance >= 0 && distance <= 40, 'Every station choice must retain a legal current distance.');
} }
if (frame.sapho) { if (frame.sapho) {
const sapho = frame.sapho; need(frame.saphoHistory === undefined ||
need(record(sapho) && Object.keys(sapho).sort().join(',') === 'event,holder,mode,nextEvent,originalOrder' && Array.isArray(frame.saphoHistory) && frame.saphoHistory.length > 0,
typeof sapho.event === 'string' && sapho.event.length > 0 && 'The station must retain its preceding Sapho orderings.');
typeof sapho.nextEvent === 'string' && sapho.nextEvent.length > 0 && sapho.nextEvent !== sapho.event && const receipts = [...(frame.saphoHistory ?? []), frame.sapho];
Array.isArray(sapho.originalOrder) && sapho.originalOrder.length === 2 && const events = new Set<string>();
new Set(sapho.originalOrder).size === 2 && let previous: SaphoStationReceipt | undefined;
sapho.originalOrder.every(id => typeof id === 'string' && g.players.some(p => p.id === id)) && for (const sapho of receipts) {
sapho.originalOrder.includes(sapho.holder) && ['first', 'last'].includes(sapho.mode) && need(record(sapho) && Object.keys(sapho).sort().join(',') === 'event,holder,mode,nextEvent,originalOrder' &&
(sapho.mode === 'first' ? sapho.originalOrder[1] === sapho.holder : sapho.originalOrder[0] === sapho.holder) && typeof sapho.event === 'string' && sapho.event.length > 0 &&
JSON.stringify(queue.order) === JSON.stringify([...sapho.originalOrder].reverse()) && typeof sapho.nextEvent === 'string' && sapho.nextEvent.length > 0 && sapho.nextEvent !== sapho.event &&
frame.event === (queue.choices.length ? `${sapho.nextEvent}:1` : sapho.nextEvent), Array.isArray(sapho.originalOrder) && sapho.originalOrder.length === 2 &&
'The station must retain the original Sapho ordering and event.'); new Set(sapho.originalOrder).size === 2 &&
sapho.originalOrder.every(id => typeof id === 'string' && g.players.some(p => p.id === id)) &&
sapho.originalOrder.includes(sapho.holder) && ['first', 'last'].includes(sapho.mode) &&
(sapho.mode === 'first' ? sapho.originalOrder[1] === sapho.holder : sapho.originalOrder[0] === sapho.holder) &&
(!previous || sapho.event === previous.nextEvent &&
JSON.stringify(sapho.originalOrder) === JSON.stringify([...previous.originalOrder].reverse())) &&
!events.has(sapho.nextEvent),
'The station must retain each original Sapho ordering and event.');
events.add(sapho.event);
events.add(sapho.nextEvent);
previous = sapho;
}
const latest = frame.sapho;
need(JSON.stringify(queue.order) === JSON.stringify([...latest.originalOrder].reverse()) &&
frame.event === (queue.choices.length ? `${latest.nextEvent}:1` : latest.nextEvent),
'The station must retain the latest Sapho ordering and event.');
} }
} }
need( need(
@@ -275,7 +296,8 @@ export function validateDiscoveryStorm(
if (frame.stage === 'choose') { if (frame.stage === 'choose') {
const occupants = stationOccupants(g); const occupants = stationOccupants(g);
need( need(
JSON.stringify(occupants) === JSON.stringify(frame.sapho?.originalOrder ?? frame.queue?.order ?? [frame.owner]) && JSON.stringify(occupants) === JSON.stringify(frame.saphoHistory?.[0]?.originalOrder ??
frame.sapho?.originalOrder ?? frame.queue?.order ?? [frame.owner]) &&
g.stormPending === discoveryStormDistance(frame), g.stormPending === discoveryStormDistance(frame),
'The station choice no longer belongs to its original occupant and storm.', 'The station choice no longer belongs to its original occupant and storm.',
); );
@@ -294,12 +316,12 @@ export function discoveryStormSaphoModes(
holder: string, holder: string,
): Array<'first' | 'last'> { ): Array<'first' | 'last'> {
validateDiscoveryStorm(g, frame); validateDiscoveryStorm(g, frame);
if (frame.stage !== 'choose' || !frame.queue || frame.queue.choices.length || frame.sapho) return []; if (frame.stage !== 'choose' || !frame.queue || frame.queue.choices.length) return [];
const index = frame.queue.order.indexOf(holder); const index = frame.queue.order.indexOf(holder);
return index === 0 ? ['last'] : index === 1 ? ['first'] : []; return index === 0 ? ['last'] : index === 1 ? ['first'] : [];
} }
/** Bind a single meaningful reorder and invalidate all old station actions. */ /** Bind each meaningful physical play to a fresh event; choices never replay. */
export function reorderDiscoveryStorm( export function reorderDiscoveryStorm(
g: DiscoveryStormContext, g: DiscoveryStormContext,
frame: DiscoveryStorm, frame: DiscoveryStorm,
@@ -307,7 +329,9 @@ export function reorderDiscoveryStorm(
): DiscoveryStorm { ): DiscoveryStorm {
const modes = discoveryStormSaphoModes(g, frame, input.holder); const modes = discoveryStormSaphoModes(g, frame, input.holder);
need(input.event === frame.event && modes.includes(input.mode) && need(input.event === frame.event && modes.includes(input.mode) &&
typeof input.nextEvent === 'string' && input.nextEvent.length > 0 && input.nextEvent !== frame.event, typeof input.nextEvent === 'string' && input.nextEvent.length > 0 && input.nextEvent !== frame.event &&
![...(frame.saphoHistory ?? []), ...(frame.sapho ? [frame.sapho] : [])]
.some(receipt => receipt.event === input.nextEvent || receipt.nextEvent === input.nextEvent),
'Choose an available Sapho ordering for the current station event.'); 'Choose an available Sapho ordering for the current station event.');
const originalOrder = [...frame.queue!.order]; const originalOrder = [...frame.queue!.order];
const order = [...originalOrder].reverse(); const order = [...originalOrder].reverse();
@@ -315,6 +339,7 @@ export function reorderDiscoveryStorm(
...frame, event: input.nextEvent, owner: order[0], ...frame, event: input.nextEvent, owner: order[0],
queue: {order, choices: []}, queue: {order, choices: []},
sapho: {event: frame.event, nextEvent: input.nextEvent, originalOrder, holder: input.holder, mode: input.mode}, sapho: {event: frame.event, nextEvent: input.nextEvent, originalOrder, holder: input.holder, mode: input.mode},
...(frame.sapho ? {saphoHistory:[...(frame.saphoHistory ?? []), frame.sapho]} : {}),
signature: '', signature: '',
}; };
next.signature = discoveryStormSignature(next); next.signature = discoveryStormSignature(next);
+8
View File
@@ -1829,6 +1829,8 @@ export type Game = {
card: string; card: string;
event: string; event: string;
mode: 'first' | 'last'; mode: 'first' | 'last';
/** New reactions reopen the neutral order window after the discard. */
stationReplayPriority?: true;
resume: NonNullable<Game['pendingNullentropy']>['resume']; resume: NonNullable<Game['pendingNullentropy']>['resume'];
stateSignature: string; stateSignature: string;
} }
@@ -6695,6 +6697,7 @@ type SaphoStationDiscardContinuation = Extract<
>; >;
function saphoStationDiscardSignature(g: Game, c: SaphoStationDiscardContinuation) { function saphoStationDiscardSignature(g: Game, c: SaphoStationDiscardContinuation) {
return JSON.stringify({player:c.player, card:c.card, event:c.event, mode:c.mode, return JSON.stringify({player:c.player, card:c.card, event:c.event, mode:c.mode,
...(c.stationReplayPriority ? {stationReplayPriority:true} : {}),
parent:nullentropyParentSignature(g,c.resume,c.event), turn:g.turn, phase:g.phase, parent:nullentropyParentSignature(g,c.resume,c.event), turn:g.turn, phase:g.phase,
order:g.order, ready:g.ready, storm:g.storm, stormPending:g.stormPending, order:g.order, ready:g.ready, storm:g.storm, stormPending:g.stormPending,
source:g.stormMovementSource, station:g.ecologicalStorm, discoveries:g.discoveries, source:g.stormMovementSource, station:g.ecologicalStorm, discoveries:g.discoveries,
@@ -10006,6 +10009,7 @@ function semutaOfferSupported(
if (continuation.kind === 'saphoStationDiscard') { if (continuation.kind === 'saphoStationDiscard') {
const frame = g.ecologicalStorm, decision = continuation.resume.decision, receipt = frame?.sapho; const frame = g.ecologicalStorm, decision = continuation.resume.decision, receipt = frame?.sapho;
return g.semutaPreview === true && g.discoveryEnabled === true && !!g.discoveries && return g.semutaPreview === true && g.discoveryEnabled === true && !!g.discoveries &&
(continuation.stationReplayPriority === undefined || continuation.stationReplayPriority === true) &&
discoveryModeSupported(g) && g.status === 'playing' && g.phase === 0 && discoveryModeSupported(g) && g.status === 'playing' && g.phase === 0 &&
frame?.stage === 'choose' && frame.queue?.choices.length === 0 && frame?.stage === 'choose' && frame.queue?.choices.length === 0 &&
receipt?.event === continuation.event && receipt.holder === continuation.player && receipt?.event === continuation.event && receipt.holder === continuation.player &&
@@ -10856,6 +10860,9 @@ function finishTreacheryDiscard(g: Game, claim?: { player: string; card: string
g.decision = next.resume.decision; g.decision = next.resume.decision;
g.pendingKarama = next.resume.pendingKarama; g.pendingKarama = next.resume.pendingKarama;
g.phaseOpening = next.resume.phaseOpening; g.phaseOpening = next.resume.phaseOpening;
if (next.stationReplayPriority && g.ecologicalStorm?.stage === 'choose' &&
g.ecologicalStorm.queue?.choices.length === 0)
g.saphoStationPriority = {event:g.ecologicalStorm.event,passed:[]};
} else if (next.kind === 'saphoMovementDiscard') { } else if (next.kind === 'saphoMovementDiscard') {
g.response = next.resume.response; g.response = next.resume.response;
g.decision = next.resume.decision; g.decision = next.resume.decision;
@@ -30982,6 +30989,7 @@ function playSapho(g: Game, p: Player, action: Action) {
if (g.semutaPreview) { if (g.semutaPreview) {
const continuation: SaphoStationDiscardContinuation = { const continuation: SaphoStationDiscardContinuation = {
kind:'saphoStationDiscard', player:p.id, card:used.id, event:option.event, mode:option.mode, kind:'saphoStationDiscard', player:p.id, card:used.id, event:option.event, mode:option.mode,
stationReplayPriority:true,
resume:{response:g.response, decision:g.decision, pendingKarama:g.pendingKarama, phaseOpening:g.phaseOpening}, resume:{response:g.response, decision:g.decision, pendingKarama:g.pendingKarama, phaseOpening:g.phaseOpening},
stateSignature:'', stateSignature:'',
}; };
+1 -1
View File
@@ -516,7 +516,7 @@ export const RULE_TOPICS: RuleTopic[] = [
'In a fresh Richese battle, use unreserved Sapho at a clean boundary before both combatants finish final battle actions, including after sealed plans and revealed declarations. Habbanya still precedes ordinary aggressor tie priority. Participants, plans, promises, weapon choices and votes do not swap or replay. Older battles retain their pre-plan opportunity.', 'In a fresh Richese battle, use unreserved Sapho at a clean boundary before both combatants finish final battle actions, including after sealed plans and revealed declarations. Habbanya still precedes ordinary aggressor tie priority. Participants, plans, promises, weapon choices and votes do not swap or replay. Older battles retain their pre-plan opportunity.',
'When two or more players declared Truthtrance in a supported clean parent, each queued holder may continue or use their held Sapho to move their entire pending question group first or last. Physical storm order and each holder’s card order stay unchanged. Supported Semuta claim/pass restores the same question queue, including the selected Homeworld, Leader Skills and Discovery profiles. Clean ordinary auction lots also preserve their standing bid and remaining clock. Richese cache Once Around and Silent lots and Advanced Black Market lots preserve their original bidding and funding. Fresh Advanced CHOAM-only Richese games offer Semuta on this Sapho discard and supported definite factual or bid-question Truthtrance discards in those auctions. Other question families and combinations remain unfinished.', 'When two or more players declared Truthtrance in a supported clean parent, each queued holder may continue or use their held Sapho to move their entire pending question group first or last. Physical storm order and each holder’s card order stay unchanged. Supported Semuta claim/pass restores the same question queue, including the selected Homeworld, Leader Skills and Discovery profiles. Clean ordinary auction lots also preserve their standing bid and remaining clock. Richese cache Once Around and Silent lots and Advanced Black Market lots preserve their original bidding and funding. Fresh Advanced CHOAM-only Richese games offer Semuta on this Sapho discard and supported definite factual or bid-question Truthtrance discards in those auctions. Other question families and combinations remain unfinished.',
'During a clean native Extortion payer decision, use Sapho to take your optional choice first/last among unanswered non-Moritani players. Earlier declines, collected bank5 and the one-payment3 limit remain. The next payer event changes even when that player stays next. You may decline instead of paying.', 'During a clean native Extortion payer decision, use Sapho to take your optional choice first/last among unanswered non-Moritani players. Earlier declines, collected bank5 and the one-payment3 limit remain. The next payer event changes even when that player stays next. You may decline instead of paying.',
'Before either of two Ecological Testing Station occupants chooses, use Sapho to take your adjustment first or last if that changes the order. Fresh choices with Richese seated give both occupants a shared opportunity to use an available order change or continue; an automated occupant cannot advance the station choice while another player is deciding. Each occupant still adjusts the cumulative storm distance once. Physical storm order and its original source stay unchanged. In supported Semuta games, claim or pass resumes the same next choice. Replay of a recovered Sapho remains unfinished; this online priority is provisional.', 'Before either of two Ecological Testing Station occupants chooses, use Sapho to take your adjustment first or last if that changes the order. Fresh choices with Richese seated give both occupants a shared opportunity to use an available order change or continue; an automated occupant cannot advance the station choice while another player is deciding. Each occupant still adjusts the cumulative storm distance once. Physical storm order and its original source stay unchanged. In supported Semuta games, claim or pass reopens the shared opportunity; an occupant may use a recovered Sapho again before either choice. This online priority is provisional.',
'During ordered Advanced Charity, take your remaining turn first or last, then discard Sapho. An accepted current claim provisionally protects that actor while another holder reorders only later unstarted turns. At a clean boundary, the holder may pause its own claimed turn and resume last without repeating the claim or payment. Completed turns stay closed and physical First Player order is unchanged. Basic and older concurrent phases have no ordered scope.', 'During ordered Advanced Charity, take your remaining turn first or last, then discard Sapho. An accepted current claim provisionally protects that actor while another holder reorders only later unstarted turns. At a clean boundary, the holder may pause its own claimed turn and resume last without repeating the claim or payment. Completed turns stay closed and physical First Player order is unchanged. Basic and older concurrent phases have no ordered scope.',
'During ordered Advanced Revival, take your unfinished opportunity first or last, then discard Sapho. If another player has started, provisional queued timing lets that player finish unchanged. At a clean boundary, you may instead pause your own started turn and resume last, retaining used allowances. Pending requests must finish first. Completed turns and already-held positions cannot be repeated. Basic and older concurrent Revival phases have no ordered scope.', 'During ordered Advanced Revival, take your unfinished opportunity first or last, then discard Sapho. If another player has started, provisional queued timing lets that player finish unchanged. At a clean boundary, you may instead pause your own started turn and resume last, retaining used allowances. Pending requests must finish first. Completed turns and already-held positions cannot be repeated. Basic and older concurrent Revival phases have no ordered scope.',
'When two or more players declare simultaneous Truthtrances in a quiet unrevealed battle, their public question-order window can use Sapho to move the holder’s group first or last. The current battle and committed plans remain in place. In the supported Basic Semuta preview, the discard and any exchange finish before the reordered questions resume.', 'When two or more players declare simultaneous Truthtrances in a quiet unrevealed battle, their public question-order window can use Sapho to move the holder’s group first or last. The current battle and committed plans remain in place. In the supported Basic Semuta preview, the discard and any exchange finish before the reordered questions resume.',
+55 -2
View File
@@ -36,7 +36,9 @@ for (const mode of ['first', 'last'] as const) void test(
assert.equal(frame.owner, frame.queue!.order[0]); assert.equal(frame.owner, frame.queue!.order[0]);
assert.deepEqual(frame.sapho, {event: original.event, nextEvent: 'sapho-fresh-event', assert.deepEqual(frame.sapho, {event: original.event, nextEvent: 'sapho-fresh-event',
originalOrder: original.queue!.order, holder, mode}); originalOrder: original.queue!.order, holder, mode});
assert.deepEqual(discoveryStormSaphoModes(game, frame, holder), []); // The helper quotes the current order; the engine separately requires
// that a later player physically reacquire the spent Sapho card.
assert.deepEqual(discoveryStormSaphoModes(game, frame, holder), [mode === 'first' ? 'last' : 'first']);
assert.throws(() => chooseDiscoveryStorm(game, frame, frame.owner, original.event, 0)); assert.throws(() => chooseDiscoveryStorm(game, frame, frame.owner, original.event, 0));
let next = chooseDiscoveryStorm(game, frame, frame.owner, frame.event, 0); let next = chooseDiscoveryStorm(game, frame, frame.owner, frame.event, 0);
assert.equal(next.event, 'sapho-fresh-event:1'); assert.equal(next.event, 'sapho-fresh-event:1');
@@ -64,7 +66,7 @@ void test('stale, ineffective, replayed and tampered station reorder requests fa
const reordered = reorderDiscoveryStorm(game, frame, const reordered = reorderDiscoveryStorm(game, frame,
{holder: first, event: frame.event, mode: 'last', nextEvent: 'fresh'}); {holder: first, event: frame.event, mode: 'last', nextEvent: 'fresh'});
assert.throws(() => reorderDiscoveryStorm(game, reordered, assert.throws(() => reorderDiscoveryStorm(game, reordered,
{holder: second, event: 'fresh', mode: 'last', nextEvent: 'again'})); {holder: second, event: 'fresh', mode: 'first', nextEvent: 'again'}));
const changed = structuredClone(reordered); const changed = structuredClone(reordered);
changed.sapho!.originalOrder.reverse(); changed.sapho!.originalOrder.reverse();
changed.signature = discoveryStormSignature(changed); changed.signature = discoveryStormSignature(changed);
@@ -72,3 +74,54 @@ void test('stale, ineffective, replayed and tampered station reorder requests fa
const afterFirst = chooseDiscoveryStorm(game, frame, first, frame.event, 0); const afterFirst = chooseDiscoveryStorm(game, frame, first, frame.event, 0);
assert.deepEqual(discoveryStormSaphoModes(game, afterFirst, second), []); assert.deepEqual(discoveryStormSaphoModes(game, afterFirst, second), []);
}); });
void test('recovered Sapho reorders keep a linked event and order history without replaying choices', () => {
const game = source(), original = structuredClone(game.ecologicalStorm!);
const [first, second] = original.queue!.order;
const one = reorderDiscoveryStorm(game, original,
{holder:first, event:original.event, mode:'last', nextEvent:'first-reorder'});
const oneBefore = structuredClone(one);
const two = reorderDiscoveryStorm(game, one,
{holder:second, event:one.event, mode:'last', nextEvent:'second-reorder'});
assert.deepEqual(one, oneBefore);
assert.deepEqual(two.queue!.order, original.queue!.order);
assert.deepEqual(two.saphoHistory, [one.sapho]);
assert.deepEqual(two.sapho, {event:'first-reorder', nextEvent:'second-reorder',
originalOrder:one.queue!.order, holder:second, mode:'last'});
assert.equal(two.owner, first);
assert.equal(two.queue!.choices.length, 0);
validateDiscoveryStorm(game, two);
const three = reorderDiscoveryStorm(game, two,
{holder:first, event:two.event, mode:'last', nextEvent:'third-reorder'});
assert.deepEqual(three.saphoHistory, [one.sapho, two.sapho]);
assert.deepEqual(three.queue!.order, [...original.queue!.order].reverse());
validateDiscoveryStorm(game, three);
for (const input of [
{holder:second, event:one.event, mode:'last' as const, nextEvent:'unused'},
{holder:first, event:two.event, mode:'last' as const, nextEvent:original.event},
{holder:first, event:two.event, mode:'last' as const, nextEvent:one.event},
]) assert.throws(() => reorderDiscoveryStorm(game, two, input));
for (const mutate of [
(changed:typeof three) => { changed.saphoHistory![0].nextEvent = 'broken-chain'; },
(changed:typeof three) => { changed.saphoHistory![1].originalOrder.reverse(); },
(changed:typeof three) => { changed.sapho!.event = one.sapho!.event; },
(changed:typeof three) => { changed.sapho!.nextEvent = one.sapho!.event; },
]) {
const changed = structuredClone(three);
mutate(changed);
changed.signature = discoveryStormSignature(changed);
assert.throws(() => validateDiscoveryStorm(game, changed));
}
const afterFirst = chooseDiscoveryStorm(game, three, three.owner, three.event, 0);
assert.deepEqual(discoveryStormSaphoModes(game, afterFirst, afterFirst.owner), []);
assert.throws(() => reorderDiscoveryStorm(game, afterFirst,
{holder:afterFirst.owner, event:afterFirst.event, mode:'first', nextEvent:'too-late'}));
const afterSecond = chooseDiscoveryStorm(game, afterFirst, afterFirst.owner, afterFirst.event, 0);
assert.deepEqual(afterSecond.queue!.choices.map(choice => choice.owner), three.queue!.order);
assert.deepEqual(afterSecond.saphoHistory, three.saphoHistory);
validateDiscoveryStorm(game, afterSecond);
});
@@ -80,6 +80,8 @@ for (const advanced of [false, true]) void test(
for (const player of game.players) game = applyAction(game, player.id, {type:'semutaPass', event:discardEvent}); for (const player of game.players) game = applyAction(game, player.id, {type:'semutaPass', event:discardEvent});
assert.equal(game.decision?.player, f.holder); assert.equal(game.decision?.player, f.holder);
assert.equal(game.discard.filter(card => card.id === CARD).length, 1); assert.equal(game.discard.filter(card => card.id === CARD).length, 1);
for (const occupant of game.ecologicalStorm!.queue!.order)
game = applyAction(game, occupant, {type:'saphoStationPass',event:game.ecologicalStorm!.event});
for (const delta of [1, -1]) { for (const delta of [1, -1]) {
const actor = game.ecologicalStorm!.owner; const actor = game.ecologicalStorm!.owner;
const action = discoveryStormActions(viewGame(game, actor)).find(row => row.delta === delta); const action = discoveryStormActions(viewGame(game, actor)).find(row => row.delta === delta);
@@ -0,0 +1,89 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { applyAction, createGame, joinGame, newPlayer, viewGame, type Game } from '../game/engine';
import { botActions } from '../game/bots';
import { DIFFICULTIES } from '../game/bot-profiles';
import { DISCOVERY_CARD_PLACEMENTS, validateDiscoveryState } from '../game/discoveries';
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
import { advanceTestingStationContest } from './fixture-testing-station-contest';
import { moveSemutaEmperorCard } from './fixture-semuta-emperor-share';
import { reactSemutaSpecial } from './fixture-semuta-special-karama';
const SAPHO = 'richese-juice-of-sapho';
const STATION = 'ecological-testing-station';
const seat = (game: Game, id: string) => {
const player = game.players.find(row => row.id === id); assert.ok(player); return player;
};
/** Public setup followed by a controlled physical Station placement, reserve
* counters and conserved original Sapho/Semuta transfers. The pending discard
* is produced by the real card action and native Station queue. */
function pendingStationDiscard() {
let game = createGame('SAPHOSTATIONCOMPAT', newPlayer('richese', 'Richese', 'richese'), false, ['choam']);
for (const faction of ['atreides', 'emperor'] as const)
joinGame(game, newPlayer(faction, faction, faction));
game = applyAction(game, game.host, {type:'moduleOption', module:'discoveries', enabled:true});
for (const player of game.players) game = applyAction(game, player.id, {type:'ready'});
game = applyAction(game, game.host, {type:'start'});
game = advanceTestingStationContest(game, state => state.status === 'playing');
const token = game.discoveries!.tokens.find(row => row.face === STATION);
assert.ok(token && token.status === 'supply');
const placement = Object.values(DISCOVERY_CARD_PLACEMENTS).find(row => row.type === token.type);
assert.ok(placement);
Object.assign(token, {status:'placed', territory:placement.territory, sector:placement.sector, revealedTurn:game.turn});
validateDiscoveryState(game.discoveries!);
for (const id of ['richese', 'emperor']) {
const player = seat(game, id); assert.ok(player.reserves > 0);
player.reserves--;
player.forces[`${STATION}:0`] = (player.forces[`${STATION}:0`] ?? 0) + 1;
while (player.hand.length >= 4) game.deck.push(player.hand.pop()!);
}
moveSemutaEmperorCard(game, SAPHO, 'emperor');
moveSemutaEmperorCard(game, SEMUTA_DRUG_ID, 'richese');
game = advanceTestingStationContest(game, state => state.decision?.kind === 'ecologicalStorm');
const option = viewGame(game, 'emperor').saphoOptions.find(row => row.scope === 'testingStation');
assert.ok(option);
game = applyAction(game, 'emperor', {type:'card', card:SAPHO, scope:option.scope,
event:option.event, mode:option.mode});
assert.equal(game.pendingTreacheryDiscard?.continuation.kind, 'saphoStationDiscard');
return game;
}
void test('legacy saved pending Sapho discard resumes without installing the new replay-priority window', () => {
const game = pendingStationDiscard();
const pending = game.pendingTreacheryDiscard; assert.ok(pending);
const continuation = pending.continuation;
assert.equal(continuation.kind, 'saphoStationDiscard');
if (continuation.kind !== 'saphoStationDiscard') throw Error('Expected the station continuation');
assert.equal(continuation.stationReplayPriority, true);
// The old signature has exactly the same ordered JSON fields except the
// new optional marker; no historic station frame or pending parent changes.
const signature = JSON.parse(continuation.stateSignature) as Record<string, unknown>;
delete signature.stationReplayPriority;
delete continuation.stationReplayPriority;
continuation.stateSignature = JSON.stringify(signature);
const resumed = reactSemutaSpecial(game, 'richese', true);
assert.equal(resumed.pendingTreacheryDiscard, null);
assert.equal(resumed.saphoStationPriority, undefined);
assert.equal(resumed.decision?.kind, 'ecologicalStorm');
assert.ok(seat(resumed, 'richese').hand.some(card => card.id === SAPHO));
assert.ok(viewGame(resumed, 'richese').saphoOptions.some(row => row.scope === 'testingStation'));
});
void test('all minimal bot profiles legally pass each reopened Station priority', () => {
const game = reactSemutaSpecial(pendingStationDiscard(), 'richese', true);
assert.ok(game.saphoStationPriority);
const order = game.ecologicalStorm!.queue!.order;
for (const occupant of order) for (const difficulty of DIFFICULTIES) {
const bot = viewGame(game, occupant);
bot.players.find(row => row.id === occupant)!.bot = difficulty;
const action = botActions(bot)[0];
assert.deepEqual(action, {type:'saphoStationPass', event:game.saphoStationPriority.event});
let resumed = applyAction(game, occupant, action);
const other = order.find(id => id !== occupant); assert.ok(other);
resumed = applyAction(resumed, other, {type:'saphoStationPass', event:game.saphoStationPriority.event});
assert.equal(resumed.saphoStationPriority, undefined);
assert.equal(resumed.decision?.kind, 'ecologicalStorm');
assert.equal(resumed.ecologicalStorm?.queue?.choices.length, 0);
}
});
+117
View File
@@ -0,0 +1,117 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { applyAction, createGame, joinGame, newPlayer, viewGame, type Action, type Game } from '../game/engine';
import { DISCOVERY_CARD_PLACEMENTS, validateDiscoveryState } from '../game/discoveries';
import { discoveryStormActions } from '../game/discovery-storm-options';
import { discoveryStormDistance } from '../game/discovery-storm';
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
import { advanceTestingStationContest } from './fixture-testing-station-contest';
import { moveSemutaEmperorCard } from './fixture-semuta-emperor-share';
import { reactSemutaSpecial } from './fixture-semuta-special-karama';
const SAPHO = 'richese-juice-of-sapho';
const STATION = 'ecological-testing-station';
const seat = (game: Game, id: string) => {
const player = game.players.find(candidate => candidate.id === id);
assert.ok(player); return player;
};
const inventory = (game: Game) => [...game.deck, ...game.discard, ...(game.richeseCache ?? []),
...(game.richeseRemoved ?? []), ...game.players.flatMap(player => player.hand)].map(card => card.id).sort();
/** Public lobby and original faction setup, then a controlled physical Station
* placement and two real reserve counters. Sapho and Semuta are moved from their
* existing physical zones. The station queue and Storm are reached by normal
* actions; no completed choice, reaction, receipt or replay is fabricated. */
function fixture(advanced: boolean) {
let game = createGame('SAPHOSTATIONREPLAY', newPlayer('richese', 'Richese', 'richese'), advanced, ['choam']);
for (const faction of ['atreides', 'emperor'] as const)
joinGame(game, newPlayer(faction, faction, faction));
game = applyAction(game, game.host, {type:'moduleOption', module:'discoveries', enabled:true});
for (const player of game.players) game = applyAction(game, player.id, {type:'ready'});
game = applyAction(game, game.host, {type:'start', ...(advanced ? {advancedPreview:true} : {})});
game = advanceTestingStationContest(game, state => state.status === 'playing');
assert.equal(game.phase, 0);
const beforeCards = inventory(game);
assert.equal(beforeCards.filter(card => card === SAPHO).length, 1);
assert.equal(beforeCards.filter(card => card === SEMUTA_DRUG_ID).length, 1);
const token = game.discoveries!.tokens.find(candidate => candidate.face === STATION);
assert.ok(token && token.status === 'supply');
const placement = Object.values(DISCOVERY_CARD_PLACEMENTS).find(candidate => candidate.type === token.type);
assert.ok(placement);
Object.assign(token, {status:'placed', territory:placement.territory, sector:placement.sector, revealedTurn:game.turn});
validateDiscoveryState(game.discoveries!);
for (const id of ['richese', 'emperor']) {
const player = seat(game, id); assert.ok(player.reserves > 0);
player.reserves--;
player.forces[`${STATION}:0`] = (player.forces[`${STATION}:0`] ?? 0) + 1;
}
for (const id of ['richese', 'emperor']) {
const player = seat(game, id);
while (player.hand.length >= 4) game.deck.push(player.hand.pop()!);
}
moveSemutaEmperorCard(game, SAPHO, 'emperor');
moveSemutaEmperorCard(game, SEMUTA_DRUG_ID, 'richese');
assert.deepEqual(inventory(game), beforeCards);
game = advanceTestingStationContest(game, state => state.decision?.kind === 'ecologicalStorm');
assert.equal(game.semutaPreview, true);
assert.deepEqual(game.ecologicalStorm!.queue!.order, game.order.filter(id => id === 'richese' || id === 'emperor'));
return {game, beforeCards};
}
function option(game: Game, holder: string) {
const result = viewGame(game, holder).saphoOptions.find(choice => choice.scope === 'testingStation');
assert.ok(result, `${holder} must have a legal physical Sapho order`);
return {type:'card', card:SAPHO, scope:result.scope, event:result.event, mode:result.mode} as Action;
}
for (const advanced of [false, true]) void test(
`${advanced ? 'Advanced' : 'Basic'} recovered Sapho can reorder the same Station a second time`, () => {
const f = fixture(advanced);
let game = f.game;
const originalOrder = [...game.ecologicalStorm!.queue!.order];
const originalEvent = game.ecologicalStorm!.event;
const base = game.stormPending!;
const firstAction = option(game, 'emperor');
game = applyAction(game, 'emperor', firstAction);
const firstReceipt = structuredClone(game.ecologicalStorm!.sapho);
assert.ok(firstReceipt);
assert.deepEqual(game.ecologicalStorm!.queue!.order, [...originalOrder].reverse());
assert.equal(game.pendingTreacheryDiscard?.batch.cause, 'sapho:station');
assert.equal(game.pendingTreacheryDiscard?.continuation.kind, 'saphoStationDiscard');
game = reactSemutaSpecial(game, 'richese', true);
assert.ok(seat(game, 'richese').hand.some(card => card.id === SAPHO));
assert.ok(!seat(game, 'richese').hand.some(card => card.id === SEMUTA_DRUG_ID));
assert.equal(game.ecologicalStorm!.queue!.choices.length, 0);
const secondAction = option(game, 'richese');
assert.notEqual(secondAction.event, originalEvent);
const secondEvent = secondAction.event;
game = applyAction(game, 'richese', secondAction);
assert.deepEqual(game.ecologicalStorm!.queue!.order, originalOrder);
assert.deepEqual(game.ecologicalStorm!.saphoHistory, [firstReceipt]);
assert.equal(game.ecologicalStorm!.sapho?.event, secondEvent);
assert.equal(game.ecologicalStorm!.sapho?.holder, 'richese');
assert.equal(game.pendingTreacheryDiscard?.batch.cause, 'sapho:station');
game = reactSemutaSpecial(game, 'richese', false);
assert.equal(game.pendingTreacheryDiscard, null);
assert.equal(game.saphoStationPriority?.event, game.ecologicalStorm!.event);
assert.equal(game.discard.filter(card => card.id === SAPHO).length, 1);
assert.equal(game.discard.filter(card => card.id === SEMUTA_DRUG_ID).length, 1);
const stale = structuredClone(game);
assert.throws(() => applyAction(game, 'richese', secondAction));
assert.deepEqual(game, stale);
for (const occupant of game.ecologicalStorm!.queue!.order)
game = applyAction(game, occupant, {type:'saphoStationPass', event:game.ecologicalStorm!.event});
const firstDelta = base < 40 ? 1 : -1;
for (const delta of [firstDelta, -firstDelta]) {
const actor = game.ecologicalStorm!.owner;
const choice = discoveryStormActions(viewGame(game, actor)).find(candidate => candidate.delta === delta);
assert.ok(choice);
game = applyAction(game, actor, choice);
}
assert.equal(game.ecologicalStorm!.stage, 'complete');
assert.deepEqual(game.ecologicalStorm!.queue!.choices.map(choice => choice.owner), originalOrder);
assert.equal(discoveryStormDistance(game.ecologicalStorm!), base);
assert.equal(game.phase, 1);
assert.deepEqual(inventory(game), f.beforeCards);
},
);
@@ -84,6 +84,8 @@ for (const advanced of [false, true]) for (const mixed of [false, true])
assert.equal(game.decision?.player, f.holder); assert.equal(game.decision?.player, f.holder);
assert.equal(player(game, 'richese').hand.some(card => card.id === SAPHO), claim); assert.equal(player(game, 'richese').hand.some(card => card.id === SAPHO), claim);
assert.equal(player(game, 'richese').hand.some(card => card.id === SEMUTA_DRUG_ID), !claim); assert.equal(player(game, 'richese').hand.some(card => card.id === SEMUTA_DRUG_ID), !claim);
for (const occupant of game.ecologicalStorm!.queue!.order)
game = applyAction(game, occupant, {type:'saphoStationPass',event:game.ecologicalStorm!.event});
for (let i = 0; i < 2; i++) { for (let i = 0; i < 2; i++) {
const owner = game.ecologicalStorm!.owner; const owner = game.ecologicalStorm!.owner;
const action = discoveryStormActions(viewGame(game, owner)).find(choice => choice.delta === 0); const action = discoveryStormActions(viewGame(game, owner)).find(choice => choice.delta === 0);
+3
View File
@@ -83,6 +83,9 @@ for (const advanced of [false, true]) for (const mode of ['first', 'last'] as co
assert.equal(seat(resumed, 'r').hand.some(card => card.id === SAPHO), claim); assert.equal(seat(resumed, 'r').hand.some(card => card.id === SAPHO), claim);
assert.equal(seat(resumed, 'r').hand.some(card => card.id === SEMUTA_DRUG_ID), !claim); assert.equal(seat(resumed, 'r').hand.some(card => card.id === SEMUTA_DRUG_ID), !claim);
assert.throws(() => applyAction(copy(resumed), 'r', {type:'semutaCommit', event:pendingEvent})); assert.throws(() => applyAction(copy(resumed), 'r', {type:'semutaCommit', event:pendingEvent}));
assert.equal(resumed.saphoStationPriority?.event, resumed.ecologicalStorm?.event);
for (const occupant of resumed.ecologicalStorm!.queue!.order)
resumed = applyAction(resumed, occupant, {type:'saphoStationPass', event:resumed.ecologicalStorm!.event});
for (const delta of [1, -1]) { for (const delta of [1, -1]) {
const owner = resumed.ecologicalStorm!.owner; const owner = resumed.ecologicalStorm!.owner;
const choice = discoveryStormActions(viewGame(resumed, owner)).find(row => row.delta === delta); const choice = discoveryStormActions(viewGame(resumed, owner)).find(row => row.delta === delta);