Allow Advanced Auditor inspection choice
Verify and publish checkpoint container / container (push) Successful in 11m25s
Verify and publish checkpoint container / container (push) Successful in 11m25s
This commit is contained in:
1 parent
0681529e8e
commit
7e6e8c2d12
9 files changed
+292
-31
No files matched your search
@@ -7,6 +7,7 @@ import {
|
||||
createAuditorLeader,
|
||||
auditCandidates,
|
||||
auditCount,
|
||||
selectedAuditCount,
|
||||
sampleAuditCards,
|
||||
} from '../game/choam-auditor';
|
||||
import { matchingTraitor, traitorDeck } from '../game/traitors';
|
||||
@@ -216,6 +217,43 @@ void test('partial sampling honors exclusions and valid RNG endpoints without ch
|
||||
assert.deepEqual(original, before);
|
||||
});
|
||||
|
||||
void test('Auditor can select one uniformly from two eligible cards without changing the hand', () => {
|
||||
const original = hand();
|
||||
const before = structuredClone(original);
|
||||
const used = original.slice(2).map((card) => card.id);
|
||||
assert.equal(auditCount(original, used, true), 2);
|
||||
for (const [draw, expected] of [[0, 'shield-a'], [0.5, 'shield-b']] as const) {
|
||||
let calls = 0;
|
||||
const selected = sampleAuditCards(original, used, true, () => { calls++; return draw; }, 1);
|
||||
assert.deepEqual(selected.map((card) => card.id), [expected]);
|
||||
assert.equal(calls, 1);
|
||||
selected[0].name = 'Changed snapshot';
|
||||
}
|
||||
assert.deepEqual(original, before);
|
||||
assert.deepEqual(used, ['hero', 'poison', 'portable']);
|
||||
});
|
||||
|
||||
void test('explicit Auditor inspection sizes respect actual survival and eligible bounds', () => {
|
||||
const original = hand();
|
||||
const before = structuredClone(original);
|
||||
const neverDraw = (): number => { throw new Error('Unexpected randomness'); };
|
||||
assert.equal(selectedAuditCount(0), 0);
|
||||
assert.equal(selectedAuditCount(2), 2);
|
||||
assert.equal(selectedAuditCount(2, 1), 1);
|
||||
assert.equal(selectedAuditCount(2, 2), 2);
|
||||
assert.deepEqual(sampleAuditCards(original.slice(0, 2), [], true, neverDraw, 2), original.slice(0, 2));
|
||||
assert.deepEqual(sampleAuditCards(original.slice(0, 1), [], false, neverDraw, 1), original.slice(0, 1));
|
||||
for (const bad of [0, -1, 1.5, 3, NaN, Infinity, null, '1']) {
|
||||
assert.throws(() => sampleAuditCards(original, [], true, neverDraw, bad as number), /inspection count/);
|
||||
}
|
||||
assert.throws(() => sampleAuditCards(original, [], false, neverDraw, 2), /inspection count/);
|
||||
assert.throws(() => sampleAuditCards(original, original.map((card) => card.id), true, neverDraw, 1), /inspection count/);
|
||||
assert.throws(() => selectedAuditCount(-1), /inspection maximum/);
|
||||
assert.throws(() => selectedAuditCount(3), /inspection maximum/);
|
||||
assert.throws(() => selectedAuditCount(NaN), /inspection maximum/);
|
||||
assert.deepEqual(original, before);
|
||||
});
|
||||
|
||||
void test('invalid physical pools, survival states and RNG draws reject without mutating inputs', () => {
|
||||
const original = hand();
|
||||
const before = structuredClone(original);
|
||||
|
||||
Reference in new issue
Block a user