Integrate CHOAM Nexus Cunning Kull with source-aware costs

This commit is contained in:
Quintine committed 2026-10-01 06:06:03 +10:00
1 parent fc5cbcd720
commit 0d9d0a72d6
32 files changed
+2502 -193

No files matched your search

+33 -13
View File
@@ -1,7 +1,6 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {
CHOAM_NEXUS_EFFECTS,
createNexusChoam,
validateNexusChoam,
type NexusChoamContext,
@@ -19,18 +18,7 @@ const context: NexusChoamContext = {
};
const clone = <T>(value: T): T => JSON.parse(JSON.stringify(value));
void test('CHOAM Nexus records all six printed effects with their distinct phase windows', () => {
assert.deepEqual(
Object.values(CHOAM_NEXUS_EFFECTS).sort(),
[
'Baliset',
'Jubba Cloak',
'Kull Wahad',
'Kulon',
'La La La',
'Trip to Gamont',
].sort(),
);
void test('CHOAM Nexus receipts enforce effect timing while leaving Kull response authority to the caller', () => {
for (const [effect, phase] of [
['kulon', 5],
['laLaLa', 4],
@@ -216,3 +204,35 @@ void test('CHOAM receipt creation rejects malformed or foreign inputs before pro
);
assert.deepEqual(context, before);
});
void test('self-consistent saved Kull receipts still reject invalid intrinsic cost, owner and stamps', () => {
const receipt = createNexusChoam(context, 'c', 5, 'physical-weapon-1', 'kull');
const patches: Partial<NexusChoamReceipt>[] = [
{ card: '' },
{ card: ' ' },
{ card: '__proto__' },
{ owner: 'a' },
{ owner: 'missing' },
{ turn: 0 },
{ turn: context.turn + 1 },
{ turn: 1.5 },
{ phase: -1 },
{ phase: 9 },
{ phase: 5.5 },
{ effect: 'unknown' as NexusChoamEffect },
];
for (const patch of patches) {
const invalid = { ...clone(receipt), ...patch };
invalid.event = JSON.stringify([
'nexusChoam', invalid.turn, invalid.phase, invalid.owner, invalid.card, invalid.effect,
]);
invalid.signature = JSON.stringify([
invalid.version, invalid.event, invalid.turn, invalid.phase,
invalid.owner, invalid.card, invalid.effect,
invalid.roster.map(player => [player.id, player.faction]),
]);
const before = clone(invalid);
assert.throws(() => validateNexusChoam(context, invalid));
assert.deepEqual(invalid, before);
}
});