Files
Dune/tests/richese-card-presentation.test.ts
T
Quintine 04501567d0 Connect Harass & Withdraw to the battle preview
The independent Ecaz Treachery variant now supports Harass in either physical battle-card slot. A category-null Prescience answer keeps its identity private without erasing the selected card. Exact undialed normal/elite counters return before battle losses; opposing successful Traitors cancel withdrawal, ordinary leader deaths still resolve, and the card is discarded exactly once. Controls, all four AI profiles and saved continuation share the same physical quote. Existing Planetologist inspection and literal Truthtrance slot promises retain their meanings.

Unique Basic/Advanced physical allocations are supported. Ambiguous allocations, co-present Ecaz allied armies on either side, Richese card-family configurations and other optional modules remain gated before sealing from public/own context. The pending Stone Burner timing question is not assumed answered. Reveal-before-explosion order and mandatory disposal on an own-Traitor win are explicit source-timing/specificity inferences, consistent with existing Planetologist precedence. Reinforcements and full variant/public mode acceptance remain unfinished.

Independent rules/privacy/persistence review fixed asymmetric selector legality, misleading blocked-card guidance, invalid restored battle pairs, native-only inspection bypass and unsupported allied-army admission. Ixian fixtures preserve all seven physical cyborgs. The first broad run caught a semantic-status lint error in the blocked guidance; replacing the paragraph role with an output element fixed it. A subsequent broad run passed 4,775 of 4,776 tests and exposed an old UI assertion requiring category-null slots to be disabled. The updated regression verifies enabled category-null selectors exclude ordinary held cards, while exact leader/dial locks and submitted values remain bound; focused controls pass 14/14. No game source changed after the eight samples or browser replay. Types, lint, 4776 offline tests, build and 43 HTTP tests pass with unchanged source. Authenticated SQLite cases verify sealed private restoration and competing duplicate traitor actions with one physical resolution.

Eight fixed genuine six-seat games finish: basic/Easy: 1803 actions, 0 Harass plans, 0 withdrawals, 48 periodic restores; basic/Medium: 225 actions, 0 Harass plans, 0 withdrawals, 6 periodic restores; basic/Hard: 2184 actions, 1 Harass plans, 1 withdrawals, 59 periodic restores; basic/Brutal: 2073 actions, 1 Harass plans, 1 withdrawals, 56 periodic restores; advanced/Easy: 2057 actions, 1 Harass plans, 1 withdrawals, 55 periodic restores; advanced/Medium: 532 actions, 0 Harass plans, 0 withdrawals, 14 periodic restores; advanced/Hard: 538 actions, 0 Harass plans, 0 withdrawals, 14 periodic restores; advanced/Brutal: 544 actions, 0 Harass plans, 0 withdrawals, 14 periodic restores. All 218 game-source files match their source-stable runs; exact card/traitor/force custody and periodic/terminal private views are checked. Browser controls verify the full card, category None, Defense-first legality, actual sealing/reveal, four returned forces, ordinary leader death, disposal and refresh. A separate final-source replay verifies the conserved browser fixture and opposing continuation, including Face Dancer replacement. This is bounded playability evidence, not full compliance or AI calibration.

All 936 opening games and their original seat/recovery records remain unchanged (970 after checks); all 937 present immediately before checks are also preserved. Database integrity and foreign keys pass. The healthy server was reused after the power failure without restart, reset or recurring automation.

Verified source tree: be193613c455c5b76b49800fe3a7400504ea879af34c59621ade3d44f0fe019d
2026-09-14 04:41:30 +10:00

225 lines
8.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import test from 'node:test';
import assert from 'node:assert/strict';
import {
cardPresentation,
richeseCardActionBlock,
} from '../game/card-presentation';
import { baseDeck, ixDeck, treacheryDeck, type Card } from '../game/cards';
import { ecazTreacheryCards } from '../game/ecaz-cards';
import { RICHESE_CARD_DEFINITIONS, richeseCards } from '../game/richese-cards';
import { RULE_TOPICS, RULE_CHECKLIST_AREAS } from '../game/reference';
void test('every Richese physical card presents its complete guide and actual printed category without changing its runtime kind', () => {
for (const definition of RICHESE_CARD_DEFINITIONS) {
const supplied = { ...definition.card };
const original = structuredClone(supplied);
const presentation = cardPresentation(supplied);
assert.deepEqual(supplied, original);
assert.equal(presentation.category, definition.printedType);
assert.equal(presentation.guidance, definition.summary);
assert.deepEqual(presentation.gameplay, definition.gameplay);
assert.equal(
presentation.role,
definition.behavior.battleCategory === 'weapon'
? 'weapon'
: definition.behavior.battleCategory === 'poison-defense'
? 'defense'
: 'utility',
);
assert.match(
presentation.availability!,
definition.card.effect === 'stoneBurner'
? /Combined allocation timing and Ix timing remain guarded/
: /effect integration and verification are incomplete/,
);
assert.deepEqual(
presentation.topics.map((topic) => topic.id),
[
definition.card.effect === 'juiceOfSapho'
? 'juice-of-sapho'
: definition.card.effect === 'stoneBurner'
? 'stone-burner'
: definition.card.effect === 'portableSnooper'
? 'portable-snooper'
: 'richese-cards',
],
);
assert.equal(supplied.kind, 'special');
}
});
void test('presentation does not export source-verification metadata or unverified interaction guesses', () => {
for (const definition of RICHESE_CARD_DEFINITIONS) {
const presentation = cardPresentation(definition.card);
assert.deepEqual(Object.keys(presentation).sort(), [
'availability',
'category',
'gameplay',
'guidance',
'role',
'topics',
]);
const serialized = JSON.stringify(presentation);
for (const note of definition.verification.unresolved)
assert.equal(serialized.includes(note), false);
for (const metadata of [
'physical-faces-verified',
'original-paraphrase-of-physical-faces',
'combinedInteractions',
'https://cdn.anyfinder',
])
assert.equal(serialized.includes(metadata), false);
}
});
void test('missing, altered and merely similar Richese identities receive no canonical full guide', () => {
for (const card of richeseCards()) {
const impostors: Card[] = [
{ ...card, id: 'other-card' },
{ ...card, name: 'Other name' },
{ ...card, kind: 'poison' },
{ ...card, effect: 'unknown-effect' },
{ ...card, effect: undefined },
{ ...card, id: card.id.toUpperCase() },
];
for (const impostor of impostors) {
const result = cardPresentation(impostor);
assert.equal(result.gameplay, undefined);
assert.equal(result.availability, undefined);
assert.equal(
result.topics.some((topic) => topic.id === 'richese-cards'),
false,
);
}
}
});
void test('the public collection and ten full card topics are searchable, linked and identify implemented handlers', () => {
const ids = new Set(RULE_TOPICS.map((topic) => topic.id));
assert.equal(ids.size, RULE_TOPICS.length);
const hub = RULE_TOPICS.find((topic) => topic.id === 'richese-cards')!;
assert.deepEqual(
hub.checklist!.map((item) => item.area),
[...RULE_CHECKLIST_AREAS],
);
assert.equal(hub.coverage, 'Partial');
assert.equal(
hub.checklist!.find((item) => item.area === 'AI')!.status,
'Partial',
);
assert.match(
hub.steps.join(' '),
/not the contents of any player’s current cache or hand/,
);
assert.match(
hub.steps.join(' '),
/Mirror Weapon and Semuta Drug remain unfinished/,
);
assert.match(hub.steps.join(' '), /Discard contents remain private/);
for (const definition of RICHESE_CARD_DEFINITIONS) {
const id = `card-${definition.card.id}`;
const topic = RULE_TOPICS.find((candidate) => candidate.id === id)!;
assert.ok(hub.related!.includes(id));
assert.equal(topic.coverage, 'Partial');
assert.ok(topic.summary.includes(definition.printedType));
assert.deepEqual(topic.steps.slice(0, -1), definition.gameplay);
assert.match(
topic.steps.at(-1)!,
definition.card.effect === 'juiceOfSapho'
? /Juice of Sapho panel/
: definition.card.effect === 'karama'
? /existing generic handler/
: definition.card.effect === 'distrans'
? /Distrans transfer panel/
: definition.card.effect === 'nullentropyBox'
? /Nullentropy Box panel/
: definition.card.effect === 'ornithopter'
? /Ornithopter movement controls/
: definition.card.effect === 'residualPoison'
? /Residual Poison panel/
: definition.card.effect === 'portableSnooper'
? /Portable Snooper/
: definition.card.effect === 'stoneBurner'
? /Stone Burner/
: /actions are not enabled/,
);
for (const related of topic.related!) assert.ok(ids.has(related));
assert.doesNotMatch(JSON.stringify(topic), /https?:\/\//);
}
for (const id of ['implementation-checklist', 'choam-modules'])
assert.ok(
RULE_TOPICS.find((topic) => topic.id === id)!.related!.includes(
'richese-cards',
),
);
});
void test('base, Ix and Ecaz guides remain separate from Richese replacement-card guidance', () => {
for (const card of [...baseDeck(), ...ixDeck()]) {
const presentation = cardPresentation(card);
assert.equal(presentation.availability, undefined);
assert.equal(presentation.gameplay, undefined);
assert.equal(
presentation.topics.some((topic) => topic.id === 'richese-cards'),
false,
);
}
for (const card of ecazTreacheryCards()) {
const presentation = cardPresentation(card);
assert.equal(presentation.category, 'Special treachery');
assert.ok(presentation.gameplay!.length >= 4);
assert.match(presentation.availability ?? '', card.effect === 'recruits'
? /development controls during Revival/ : card.effect === 'harassWithdraw'
? /development controls in either battle-card slot/ : /battle effect is still being implemented/);
assert.deepEqual(presentation.topics.map((topic) => topic.id), [card.effect === 'harassWithdraw' ? 'card-harass-withdraw' : 'card-recruits']);
}
assert.equal(treacheryDeck().length, 33);
assert.equal(treacheryDeck(['ix']).length, 47);
assert.equal(treacheryDeck(['choam']).length, 35);
assert.throws(() => treacheryDeck(['richese']), /not implemented/);
});
void test('unsupported canonical Richese effects have an explicit action block while Karama and unrelated cards retain their validators', () => {
for (const card of richeseCards()) {
if (card.effect === 'karama')
assert.equal(richeseCardActionBlock(card), null);
else if (card.effect === 'portableSnooper')
assert.match(richeseCardActionBlock(card)!, /late-defense panel/);
else if (card.effect === 'stoneBurner')
assert.match(richeseCardActionBlock(card)!, /battle weapon slot/);
else if (card.effect === 'residualPoison')
assert.match(richeseCardActionBlock(card)!, /Residual Poison panel/);
else if (card.effect === 'ornithopter')
assert.match(
richeseCardActionBlock(card)!,
/Ornithopter movement controls/,
);
else if (card.effect === 'nullentropyBox')
assert.match(richeseCardActionBlock(card)!, /Nullentropy Box panel/);
else if (card.effect === 'distrans')
assert.match(richeseCardActionBlock(card)!, /Distrans transfer panel/);
else if (card.effect === 'juiceOfSapho')
assert.match(richeseCardActionBlock(card)!, /Juice of Sapho panel/);
else
assert.match(
richeseCardActionBlock(card)!,
/effect is not implemented yet/,
);
assert.equal(
richeseCardActionBlock({ ...card, id: 'another-physical-card' }),
null,
);
assert.equal(
richeseCardActionBlock({ ...card, name: 'Another name' }),
null,
);
assert.equal(richeseCardActionBlock({ ...card, kind: 'worthless' }), null);
assert.equal(
richeseCardActionBlock({ ...card, effect: 'another-effect' }),
null,
);
}
for (const card of [...baseDeck(), ...ixDeck(), ...ecazTreacheryCards()])
assert.equal(richeseCardActionBlock(card), null);
});