Connect the Recruits independent-card revival preview
The explicit development initializer now includes the complete three-card Ecaz Treachery variant before genuine Basic/Advanced faction setup. Recruits has owned play/discard controls, full inspection, a public current-rate table, shared authoritative revival quotes, all four AI profiles and persistent exact free-use ledgers. Existing CHOAM/Tleilaxu choices settle before returning forces. Inactive games retain their prior allowance arithmetic. Clean activation before normal returns or after exactly recorded free returns is connected. Prior-paid/unknown use, later Fremen grants, pending repricing, same-turn recovered-card replay and additional optional modules stay gated. Native unlimited faction advantages remain unlimited. The independent seven-force cap after faction cancellation is explicitly documented as an inference from independent effects, not a direct combined FAQ. Reinforcements and Harass & Withdraw remain unfinished; public starts and publication stay gated. Independent rules/privacy/persistence review passed. Review fixed auction alias double-counting after a physical card sale, malformed canonical cards, legacy zero-ledger activation, a seat-control validation bypass and an ordinary-start bypass. Focused tests cover readiness and turn expiry as well as authenticated restart, exact free/paid accounting, stale/duplicate requests, competing writes and malformed-save rejection. Types, lint, 4743 offline tests, build and 43 HTTP tests passed with unchanged source. Eight fixed-seed genuine six-seat samples finish: basic/Easy: 1961 accepted, 0 Recruits plays, 53 JSON restores; basic/Medium: 711 accepted, 0 Recruits plays, 19 JSON restores; basic/Hard: 239 accepted, 0 Recruits plays, 6 JSON restores; basic/Brutal: 1367 accepted, 1 Recruits plays, 36 JSON restores; advanced/Easy: 1402 accepted, 0 Recruits plays, 37 JSON restores; advanced/Medium: 530 accepted, 0 Recruits plays, 14 JSON restores; advanced/Hard: 545 accepted, 1 Recruits plays, 14 JSON restores; advanced/Brutal: 1240 accepted, 1 Recruits plays, 33 JSON restores. Reports retain rejected candidates and earlier harness attempts. All 216 game-source hashes remain identical to the samples; a later presentation-test expectation update changes no game code. Actual card use, custody and periodic/terminal private views are checked; this is bounded playability evidence, not full variant acceptance or AI calibration. A separate conserved browser Revival fixture verifies the full inspector, physical play, public rates, four free returns and active/resolved refresh. All 902 opening games and original seat/recovery records remain unchanged (936 after checks). All 903 present immediately before broad checks are also preserved. Database integrity and foreign keys pass. The healthy server recovered after the power failure and was reused without restart, reset or recurring automation. Verified source tree: 1f934f996268b35c8a20d0d617fa962aad878108496fa1a4a05323360757b0e3
This commit is contained in:
1 parent
9ca17a66a0
commit
c04cb93830
21 files changed
+1421
-119
No files matched your search
@@ -42,7 +42,7 @@ void test('the verified Ecaz variant has one physical special of each identity a
|
||||
assert.throws(() => treacheryDeck([unsupported]), /not implemented/);
|
||||
assert.equal(ECAZ_TREACHERY_VARIANT.independentOfFactions, true);
|
||||
assert.equal(ECAZ_TREACHERY_VARIANT.independentOfOtherVariants, true);
|
||||
assert.equal(ECAZ_TREACHERY_VARIANT.activation, 'not-implemented');
|
||||
assert.equal(ECAZ_TREACHERY_VARIANT.activation, 'audit-prototype');
|
||||
});
|
||||
|
||||
void test('Ecaz faction selection preserves each ordinary deck and never includes its separate unfinished variant', () => {
|
||||
@@ -121,7 +121,10 @@ void test('verified inventory and source rules remain distinct from unimplemente
|
||||
assert.equal(definition.quantity, 1);
|
||||
assert.equal(definition.verification.inventory, 'verified');
|
||||
assert.equal(definition.verification.sourceRules, 'verified');
|
||||
assert.equal(definition.verification.runtime, 'not-implemented');
|
||||
assert.equal(
|
||||
definition.verification.runtime,
|
||||
definition.card.effect === 'recruits' ? 'prototype' : 'not-implemented',
|
||||
);
|
||||
assert.equal(definition.verification.combinedInteractions, 'incomplete');
|
||||
assert.ok(definition.verification.unresolved.length > 0);
|
||||
assert.ok(definition.summary.length > 20);
|
||||
@@ -139,6 +142,7 @@ void test('every canonical Ecaz face receives its full original gameplay guide a
|
||||
assert.equal(presentation.category, 'Special treachery');
|
||||
assert.equal(presentation.role, 'utility');
|
||||
assert.deepEqual(Object.keys(presentation).sort(), [
|
||||
'availability',
|
||||
'category',
|
||||
'gameplay',
|
||||
'guidance',
|
||||
@@ -150,7 +154,9 @@ void test('every canonical Ecaz face receives its full original gameplay guide a
|
||||
assert.equal(serialized.includes(note), false);
|
||||
assert.equal(serialized.includes('sourceRules'), false);
|
||||
assert.equal(serialized.includes('not-implemented'), false);
|
||||
assert.deepEqual(presentation.topics, []);
|
||||
assert.deepEqual(presentation.topics.map((topic) => topic.id), ['card-recruits']);
|
||||
assert.match(presentation.availability ?? '', card.effect === 'recruits'
|
||||
? /development controls during Revival/ : /battle effect is still being implemented/);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
applyAction,
|
||||
createGame,
|
||||
initializeEcazTreacheryGameForAudit,
|
||||
joinGame,
|
||||
newPlayer,
|
||||
viewGame,
|
||||
type Game,
|
||||
} from '../game/engine';
|
||||
import { botActions } from '../game/bots';
|
||||
|
||||
function seeded<T>(seed: number, work: () => T): T {
|
||||
const original = Object.getOwnPropertyDescriptor(crypto, 'getRandomValues');
|
||||
let state = seed >>> 0;
|
||||
Object.defineProperty(crypto, 'getRandomValues', {
|
||||
configurable: true,
|
||||
value: (array: Uint32Array) => {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
state = (Math.imul(state, 1664525) + 1013904223) >>> 0;
|
||||
array[i] = state;
|
||||
}
|
||||
return array;
|
||||
},
|
||||
});
|
||||
try {
|
||||
return work();
|
||||
} finally {
|
||||
if (original) Object.defineProperty(crypto, 'getRandomValues', original);
|
||||
}
|
||||
}
|
||||
|
||||
/** Genuine faction setup with the independent cards included before shuffling. */
|
||||
export function recruitsGame(
|
||||
advanced = true,
|
||||
seed = 3,
|
||||
seatIds: readonly [string, string, string, string] = ['at', 'fr', 'tl', 'ch'],
|
||||
): Game {
|
||||
return seeded(seed, () => {
|
||||
let g = createGame('RECRUITS', newPlayer(seatIds[0], 'Atreides', 'atreides'), advanced, [
|
||||
'ix',
|
||||
'choam',
|
||||
]);
|
||||
for (const [id, name, faction] of [
|
||||
[seatIds[1], 'Fremen', 'fremen'],
|
||||
[seatIds[2], 'Tleilaxu', 'tleilaxu'],
|
||||
[seatIds[3], 'CHOAM', 'choam'],
|
||||
] as const)
|
||||
joinGame(g, newPlayer(id, name, faction));
|
||||
for (const player of g.players) g = applyAction(g, player.id, { type: 'ready' });
|
||||
g = initializeEcazTreacheryGameForAudit(g);
|
||||
for (let step = 0; g.status === 'setup' && step < 80; step++) {
|
||||
let next: Game | undefined;
|
||||
for (const player of g.players) {
|
||||
const view = viewGame(g, player.id);
|
||||
view.players.find((candidate) => candidate.id === player.id)!.bot = 'Medium';
|
||||
const action = botActions(view)[0];
|
||||
if (action) {
|
||||
next = applyAction(g, player.id, action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert.ok(next, 'Genuine setup must provide a legal continuation.');
|
||||
g = next;
|
||||
}
|
||||
assert.equal(g.status, 'playing');
|
||||
assert.ok(g.players.some((player) => player.hand.some((card) => card.id === 'ecaz-recruits')),
|
||||
'Fixture seed must deal Recruits without restaging card custody.');
|
||||
g.turn = 2;
|
||||
g.phase = 4;
|
||||
g.active = null;
|
||||
g.ready = [];
|
||||
g.phaseOpening = null;
|
||||
g.decision = null;
|
||||
g.response = null;
|
||||
g.revivalRules = undefined;
|
||||
g.freeRevival = [];
|
||||
for (const player of g.players) {
|
||||
player.bot = undefined;
|
||||
player.revived = 0;
|
||||
player.freeForcesRevived = 0;
|
||||
player.spice = 20;
|
||||
player.tanks = Math.min(10, player.reserves - (player.elites?.reserves ?? 0));
|
||||
player.reserves -= player.tanks;
|
||||
}
|
||||
return g;
|
||||
});
|
||||
}
|
||||
@@ -49,6 +49,25 @@ function fixture(t: test.TestContext) {
|
||||
return { db, game };
|
||||
}
|
||||
|
||||
void test('Ecaz Treachery preview saves the complete independent inventory before genuine setup once', (t) => {
|
||||
const { db } = fixture(t);
|
||||
const beforeSeats = db.prepare('SELECT * FROM seats').all();
|
||||
const other = db.prepare('SELECT * FROM rooms WHERE code=?').get('KEEPME00');
|
||||
const result = startPrototypeRoom(db, 'PROTOTYP', 7, 'ecaz-treachery');
|
||||
const row = db.prepare('SELECT state FROM rooms WHERE code=?').get('PROTOTYP')!;
|
||||
const g = JSON.parse(row.state as string) as Game;
|
||||
assert.equal(result.version, 8);
|
||||
assert.equal(g.ecazTreachery, true);
|
||||
const cards = [...g.deck, ...g.players.flatMap((p) => p.hand), ...(g.ixSetupCards ?? [])];
|
||||
assert.deepEqual(cards.filter((c) => c.id.startsWith('ecaz-')).map((c) => c.id).sort(),
|
||||
['ecaz-harass-withdraw', 'ecaz-recruits', 'ecaz-reinforcements']);
|
||||
assert.deepEqual(db.prepare('SELECT * FROM seats').all(), beforeSeats);
|
||||
assert.deepEqual(db.prepare('SELECT * FROM rooms WHERE code=?').get('KEEPME00'), other);
|
||||
const rows = db.prepare('SELECT * FROM rooms').all();
|
||||
assert.throws(() => startPrototypeRoom(db, 'PROTOTYP', 8, 'ecaz-treachery'), /cannot redeal/);
|
||||
assert.deepEqual(db.prepare('SELECT * FROM rooms').all(), rows);
|
||||
});
|
||||
|
||||
void test('local prototype starts the named ready lobby once, retaining every seat and other room', (t) => {
|
||||
const { db } = fixture(t);
|
||||
const seats = db.prepare('SELECT * FROM seats').all();
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createElement } from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { Recruits } from '../components/recruits';
|
||||
import { applyAction, viewGame, type Game } from '../game/engine';
|
||||
import { botActions } from '../game/bots';
|
||||
import { recruitsPlayAction } from '../game/recruits';
|
||||
import { cardPresentation } from '../game/card-presentation';
|
||||
import { recruitsGame } from './fixture-recruits';
|
||||
|
||||
function ownerGame() {
|
||||
const g = recruitsGame();
|
||||
const owner = g.players.find((p) => p.hand.some((c) => c.id === 'ecaz-recruits'))!;
|
||||
const atreides = g.players.find((p) => p.faction === 'atreides')!;
|
||||
const index = owner.hand.findIndex((c) => c.id === 'ecaz-recruits');
|
||||
// A conserved fixture exchange gives the free-rate faction the actual card.
|
||||
[owner.hand[index], atreides.hand[0]] = [atreides.hand[0], owner.hand[index]];
|
||||
return g;
|
||||
}
|
||||
const render = (g: Game, viewer = 'at', busy = false) => renderToStaticMarkup(
|
||||
createElement(Recruits, { game: viewGame(g, viewer), act() {}, busy }),
|
||||
);
|
||||
function allowRevival(g: Game) {
|
||||
for (let step = 0; g.pendingRevival && step < 20; step++) {
|
||||
let next: Game | undefined;
|
||||
for (const p of g.players) {
|
||||
const view = viewGame(g, p.id);
|
||||
view.players.find((player) => player.id === p.id)!.bot = 'Easy';
|
||||
const action = botActions(view)[0];
|
||||
if (action) { next = applyAction(g, p.id, action); break; }
|
||||
}
|
||||
assert.ok(next, 'Revival decisions must have legal continuation.');
|
||||
g = next;
|
||||
}
|
||||
assert.equal(g.pendingRevival, null);
|
||||
return g;
|
||||
}
|
||||
|
||||
void test('Recruits owner has an accessible physical-card action; rivals cannot infer its owner before play', () => {
|
||||
const g = ownerGame(), html = render(g);
|
||||
assert.match(html, /Play Recruits · Discard card/);
|
||||
assert.match(html, /Current revival rates/);
|
||||
assert.match(html, /Unlimited/);
|
||||
assert.doesNotMatch(html, /disabled=""/);
|
||||
assert.match(render(g, 'at', true), /disabled=""/);
|
||||
assert.equal(render(g, 'fr'), '');
|
||||
assert.equal(viewGame(g, 'fr').recruitsPreview?.play, null);
|
||||
const card = g.players[0].hand.find((c) => c.id === 'ecaz-recruits')!;
|
||||
assert.ok(cardPresentation(card).topics.some((topic) => topic.id === 'card-recruits'));
|
||||
});
|
||||
|
||||
void test('late-paid and wrong-phase controls stay guarded through the shared action adapter', () => {
|
||||
let g = ownerGame();
|
||||
g = allowRevival(applyAction(g, 'at', { type: 'revive', amount: 3 }));
|
||||
const preview = viewGame(g, 'at').recruitsPreview;
|
||||
assert.match(preview?.play?.blocked ?? '', /paid normal force revival/);
|
||||
assert.equal(recruitsPlayAction(preview), null);
|
||||
assert.match(render(g), /aria-describedby="recruits-unavailable"/);
|
||||
assert.match(render(g), /disabled=""/);
|
||||
g.phase = 5;
|
||||
assert.equal(render(g), '');
|
||||
assert.equal(recruitsPlayAction(undefined), null);
|
||||
});
|
||||
|
||||
void test('resolved public rates survive JSON restoration without displaying an extra card action', () => {
|
||||
const g = applyAction(ownerGame(), 'at', { type: 'card', card: 'ecaz-recruits' });
|
||||
const restored = JSON.parse(JSON.stringify(g)) as Game;
|
||||
for (const p of g.players) {
|
||||
const html = render(restored, p.id);
|
||||
assert.match(html, /Active this turn/);
|
||||
assert.doesNotMatch(html, /Play Recruits · Discard card/);
|
||||
assert.deepEqual(viewGame(restored, p.id).recruitsPreview, viewGame(g, p.id).recruitsPreview);
|
||||
}
|
||||
});
|
||||
|
||||
for (const level of ['Easy', 'Medium', 'Hard', 'Brutal'] as const) {
|
||||
void test(`${level} uses the owned offer once, then legally revives at the doubled rate`, () => {
|
||||
let g = ownerGame();
|
||||
let view = viewGame(g, 'at');
|
||||
view.players.find((p) => p.id === 'at')!.bot = level;
|
||||
const action = botActions(view)[0];
|
||||
assert.deepEqual(action, { type: 'card', card: 'ecaz-recruits' });
|
||||
assert.deepEqual(action, recruitsPlayAction(view.recruitsPreview));
|
||||
g = applyAction(g, 'at', action);
|
||||
view = viewGame(g, 'at');
|
||||
view.players.find((p) => p.id === 'at')!.bot = level;
|
||||
const revival = botActions(view).find((candidate) => candidate.type === 'revive');
|
||||
assert.ok(revival);
|
||||
const done = allowRevival(applyAction(g, 'at', revival));
|
||||
assert.ok(done.players[0].revived > 0);
|
||||
assert.equal(done.players[0].freeForcesRevived, 4);
|
||||
assert.equal(done.discard.filter((c) => c.id === 'ecaz-recruits').length, 1);
|
||||
assert.ok(!botActions(view).some((candidate) => candidate.type === 'card' && candidate.card === 'ecaz-recruits'));
|
||||
});
|
||||
}
|
||||
|
||||
void test('all AI profiles skip the unresolved late Fremen grant while using other legal revival choices', () => {
|
||||
let g = ownerGame();
|
||||
g.players[0].ally = 'fr'; g.players[1].ally = 'at';
|
||||
g = applyAction(g, 'at', { type: 'card', card: 'ecaz-recruits' });
|
||||
for (const level of ['Easy', 'Medium', 'Hard', 'Brutal'] as const) {
|
||||
const view = viewGame(g, 'fr');
|
||||
view.players.find((p) => p.id === 'fr')!.bot = level;
|
||||
const actions = botActions(view);
|
||||
assert.ok(actions.length);
|
||||
assert.ok(!actions.some((action) => action.type === 'grantRevival'));
|
||||
assert.doesNotThrow(() => applyAction(g, 'fr', actions[0]));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,265 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
applyAction,
|
||||
createGame,
|
||||
initializeBaseGameForAudit,
|
||||
joinGame,
|
||||
newPlayer,
|
||||
viewGame,
|
||||
type Action,
|
||||
type Game,
|
||||
} from '../game/engine';
|
||||
import { recruitsPlayAction } from '../game/recruits';
|
||||
import { normalRevivalAllowance, newRevivalRules } from '../game/revival';
|
||||
import { botActions } from '../game/bots';
|
||||
import { recruitsGame } from './fixture-recruits';
|
||||
|
||||
const play = { type: 'card', card: 'ecaz-recruits' } as const;
|
||||
function rejectUnchanged(g: Game, player: string, action: Action = play) {
|
||||
const before = structuredClone(g);
|
||||
assert.throws(() => applyAction(g, player, action));
|
||||
assert.deepEqual(g, before);
|
||||
}
|
||||
function physical(g: Game) {
|
||||
return [
|
||||
...g.deck,
|
||||
...g.discard,
|
||||
...g.players.flatMap((player) => player.hand),
|
||||
...(g.ixSetupCards ?? []),
|
||||
...(g.ixAuction?.cards ?? []),
|
||||
...(g.auction?.cards.slice(g.auction.index) ?? []),
|
||||
];
|
||||
}
|
||||
function settleRevival(state: Game) {
|
||||
let g = state;
|
||||
for (let step = 0; g.pendingRevival && step < 20; step++) {
|
||||
let next: Game | undefined;
|
||||
for (const player of g.players) {
|
||||
const view = viewGame(g, player.id);
|
||||
view.players.find((candidate) => candidate.id === player.id)!.bot = 'Medium';
|
||||
const action = botActions(view)[0];
|
||||
if (action) {
|
||||
next = applyAction(g, player.id, action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert.ok(next, 'Pending revival must retain a legal continuation.');
|
||||
g = next;
|
||||
}
|
||||
assert.equal(g.pendingRevival, null);
|
||||
return g;
|
||||
}
|
||||
|
||||
void test('genuine Basic and Advanced setup owns exactly one of all three independent cards and projects only the holder play', () => {
|
||||
for (const advanced of [false, true]) {
|
||||
const g = recruitsGame(advanced);
|
||||
const cards = physical(g).filter((card) => card.id.startsWith('ecaz-'));
|
||||
assert.deepEqual(cards.map((card) => card.id).sort(), [
|
||||
'ecaz-harass-withdraw',
|
||||
'ecaz-recruits',
|
||||
'ecaz-reinforcements',
|
||||
]);
|
||||
const owner = g.players.find((player) => player.hand.some((card) => card.id === play.card))!;
|
||||
for (const player of g.players) {
|
||||
const preview = viewGame(g, player.id).recruitsPreview;
|
||||
assert.ok(preview);
|
||||
assert.equal(preview.active, false);
|
||||
assert.deepEqual(
|
||||
recruitsPlayAction(preview),
|
||||
player.id === owner.id ? play : null,
|
||||
);
|
||||
assert.equal(preview.play === null, player.id !== owner.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
void test('playing Recruits discards its exact card and publishes effective rates and independent limits', () => {
|
||||
for (const advanced of [false, true]) {
|
||||
const before = recruitsGame(advanced);
|
||||
const g = applyAction(before, 'ch', play);
|
||||
assert.deepEqual(g.recruits, { turn: 2, player: 'ch', card: play.card });
|
||||
assert.equal(g.players.find((player) => player.id === 'ch')!.hand.some((card) => card.id === play.card), false);
|
||||
assert.equal(g.discard.filter((card) => card.id === play.card).length, 1);
|
||||
const preview = viewGame(JSON.parse(JSON.stringify(g)), 'at').recruitsPreview!;
|
||||
assert.deepEqual(
|
||||
Object.fromEntries(preview.rates.map((row) => [row.player, [row.freeRate, row.limit]])),
|
||||
{ at: [4, 7], fr: [6, 7], tl: [4, 20], ch: [0, 20] },
|
||||
);
|
||||
assert.equal(preview.active, true);
|
||||
assert.equal(preview.playedBy, 'ch');
|
||||
assert.equal(preview.grantRevivalBlocked?.includes('before Recruits'), true);
|
||||
}
|
||||
});
|
||||
|
||||
void test('the accepted card changes the authoritative normal revival quote and free ledger', () => {
|
||||
let g = applyAction(recruitsGame(true), 'ch', play);
|
||||
const player = g.players.find((candidate) => candidate.id === 'at')!;
|
||||
const before = { reserves: player.reserves, tanks: player.tanks, spice: player.spice };
|
||||
g = settleRevival(applyAction(g, player.id, { type: 'revive', amount: 4, elite: 0 }));
|
||||
const after = g.players.find((candidate) => candidate.id === player.id)!;
|
||||
assert.equal(after.reserves, before.reserves + 4);
|
||||
assert.equal(after.tanks, before.tanks - 4);
|
||||
assert.equal(after.spice, before.spice);
|
||||
assert.equal(after.revived, 4);
|
||||
assert.equal(after.freeForcesRevived, 4);
|
||||
assert.equal(viewGame(g, player.id).revival.forcesRemaining, 3);
|
||||
rejectUnchanged(g, player.id, { type: 'revive', amount: 4, elite: 0 });
|
||||
});
|
||||
|
||||
void test('free prevention remains zero and canceled unlimited faction caps compose to seven', () => {
|
||||
const g = recruitsGame();
|
||||
g.revivalRules = {
|
||||
...newRevivalRules(),
|
||||
freeBlocked: ['at'],
|
||||
choamBlocked: true,
|
||||
limitBlocked: true,
|
||||
};
|
||||
const active = applyAction(g, 'ch', play);
|
||||
const rows = Object.fromEntries(
|
||||
viewGame(active, 'at').recruitsPreview!.rates.map((row) => [row.player, row]),
|
||||
);
|
||||
assert.equal(rows.at.freeRate, 0);
|
||||
assert.equal(rows.at.limit, 7);
|
||||
assert.equal(rows.tl.limit, 7);
|
||||
assert.equal(rows.ch.limit, 7);
|
||||
});
|
||||
|
||||
void test('prior settled Fremen ally grant is doubled, while a grant after activation rejects immutably', () => {
|
||||
let g = recruitsGame();
|
||||
const fremen = g.players.find((player) => player.id === 'fr')!;
|
||||
const atreides = g.players.find((player) => player.id === 'at')!;
|
||||
fremen.ally = atreides.id;
|
||||
atreides.ally = fremen.id;
|
||||
g = applyAction(g, fremen.id, { type: 'grantRevival' });
|
||||
g = applyAction(g, 'ch', play);
|
||||
assert.deepEqual(
|
||||
viewGame(g, 'at').recruitsPreview!.rates.find((row) => row.player === 'at'),
|
||||
{ player: 'at', freeRate: 6, limit: 7 },
|
||||
);
|
||||
|
||||
const late = recruitsGame();
|
||||
late.players.find((player) => player.id === 'fr')!.ally = 'at';
|
||||
late.players.find((player) => player.id === 'at')!.ally = 'fr';
|
||||
const active = applyAction(late, 'ch', play);
|
||||
rejectUnchanged(active, 'fr', { type: 'grantRevival' });
|
||||
});
|
||||
|
||||
void test('activation rejects pending, prior paid, unknown and inconsistent revival histories without consuming the card', () => {
|
||||
const cases = [
|
||||
(g: Game) => {
|
||||
g.decision = { kind: 'revivalStop', player: 'at', recipient: 'at', revival: 'forces' };
|
||||
},
|
||||
(g: Game) => { const p = g.players[0]; p.revived = 2; p.freeForcesRevived = 1; },
|
||||
(g: Game) => { const p = g.players[0]; p.revived = 1; delete p.freeForcesRevived; },
|
||||
(g: Game) => { const p = g.players[0]; p.revived = 1; p.freeForcesRevived = 2; },
|
||||
];
|
||||
for (const arrange of cases) {
|
||||
const g = recruitsGame();
|
||||
arrange(g);
|
||||
assert.ok(viewGame(g, 'ch').recruitsPreview!.play?.blocked);
|
||||
rejectUnchanged(g, 'ch');
|
||||
}
|
||||
});
|
||||
|
||||
void test('same-turn Box recovery cannot replay or consume Recruits', () => {
|
||||
const g = applyAction(recruitsGame(), 'ch', play);
|
||||
const card = g.discard.find((candidate) => candidate.id === play.card)!;
|
||||
g.discard = g.discard.filter((candidate) => candidate.id !== play.card);
|
||||
g.players.find((player) => player.id === 'ch')!.hand.push(card);
|
||||
assert.equal(viewGame(g, 'ch').recruitsPreview!.play?.blocked?.includes('already active'), true);
|
||||
rejectUnchanged(g, 'ch');
|
||||
});
|
||||
|
||||
void test('a ready owner may still play before Revival closes, and the receipt expires on the next turn', () => {
|
||||
let g = recruitsGame();
|
||||
for (const player of g.players) {
|
||||
player.reserves += Object.values(player.forces).reduce((sum, amount) => sum + amount, 0);
|
||||
player.forces = {};
|
||||
if (player.elites) {
|
||||
player.elites.reserves += Object.values(player.elites.forces).reduce((sum, amount) => sum + amount, 0);
|
||||
player.elites.forces = {};
|
||||
}
|
||||
if (player.advisors) player.advisors = {};
|
||||
}
|
||||
g.ready = ['ch'];
|
||||
g = applyAction(g, 'ch', play);
|
||||
assert.equal(g.recruits?.turn, 2);
|
||||
for (let step = 0; g.status === 'playing' && g.turn === 2 && step < 1000; step++) {
|
||||
let next: Game | undefined;
|
||||
for (const player of g.players) {
|
||||
const view = viewGame(g, player.id);
|
||||
view.players.find((candidate) => candidate.id === player.id)!.bot = 'Medium';
|
||||
const action = botActions(view)[0];
|
||||
if (action) {
|
||||
next = applyAction(g, player.id, action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert.ok(next, 'The active effect must retain a legal path to turn end.');
|
||||
g = next;
|
||||
}
|
||||
assert.equal(g.turn, 3);
|
||||
assert.equal(g.recruits, null);
|
||||
assert.equal(viewGame(g, 'at').recruitsPreview?.active, false);
|
||||
});
|
||||
|
||||
void test('legacy known-zero ledgers are initialized atomically when Recruits is accepted', () => {
|
||||
const g = recruitsGame();
|
||||
for (const player of g.players) delete player.freeForcesRevived;
|
||||
const active = applyAction(g, 'ch', play);
|
||||
assert.ok(active.players.every((player) => player.freeForcesRevived === 0));
|
||||
assert.doesNotThrow(() => viewGame(JSON.parse(JSON.stringify(active)), 'at'));
|
||||
});
|
||||
|
||||
void test('a sold Recruits card is counted once while its normal auction continuation is open', () => {
|
||||
const g = recruitsGame();
|
||||
const card = g.players.find((player) => player.id === 'ch')!.hand.find((candidate) => candidate.id === play.card)!;
|
||||
g.phase = 3;
|
||||
g.auction = { cards: [card], index: 0, bid: 1, bidder: 'ch', active: 'ch', passed: [], opener: 0, peekKnown: false };
|
||||
g.currentAuctionSale = { winner: 'ch', amount: 1, free: false, origin: 'normal', seller: null };
|
||||
g.response = { kind: 'harkonnenBonus', owner: 'ch', passed: [] };
|
||||
assert.doesNotThrow(() => viewGame(g, 'at'));
|
||||
});
|
||||
|
||||
void test('ordinary audit setup cannot silently activate a forged Ecaz variant marker', () => {
|
||||
const lobby = createGame('NOECAZV', newPlayer('at', 'Atreides', 'atreides'));
|
||||
joinGame(lobby, newPlayer('fr', 'Fremen', 'fremen'));
|
||||
for (const player of lobby.players) player.ready = true;
|
||||
lobby.ecazTreachery = true;
|
||||
rejectUnchanged(lobby, 'at', { type: 'start' });
|
||||
assert.throws(() => initializeBaseGameForAudit(lobby), /audit initializer supports/);
|
||||
});
|
||||
|
||||
void test('ordinary revival math remains unchanged while Recruits is inactive', () => {
|
||||
const g = recruitsGame();
|
||||
const player = g.players.find((candidate) => candidate.id === 'at')!;
|
||||
g.revivalRules = newRevivalRules();
|
||||
g.freeRevival = [player.id];
|
||||
player.revived = 2;
|
||||
player.freeForcesRevived = 0;
|
||||
assert.equal(normalRevivalAllowance(g, player).freeRemaining, 1);
|
||||
g.recruits = { turn: g.turn, player: 'ch', card: 'ecaz-recruits' };
|
||||
assert.equal(normalRevivalAllowance(g, player).freeRemaining, 5);
|
||||
});
|
||||
|
||||
void test('preview rejects missing, duplicate and forged physical variant cards', () => {
|
||||
for (const corrupt of [
|
||||
(g: Game) => { g.deck = g.deck.filter((card) => card.id !== 'ecaz-reinforcements'); },
|
||||
(g: Game) => { g.deck.push({ ...physical(g).find((card) => card.id === 'ecaz-harass-withdraw')! }); },
|
||||
(g: Game) => {
|
||||
const card = physical(g).find((candidate) => candidate.id === 'ecaz-reinforcements')!;
|
||||
card.effect = 'recruits';
|
||||
},
|
||||
]) {
|
||||
const g = recruitsGame();
|
||||
corrupt(g);
|
||||
assert.throws(() => viewGame(g, 'at'), /inventory/);
|
||||
}
|
||||
});
|
||||
|
||||
void test('seat-control changes cannot persist a malformed variant save', () => {
|
||||
const g = recruitsGame();
|
||||
g.deck = g.deck.filter((card) => card.id !== 'ecaz-reinforcements');
|
||||
rejectUnchanged(g, 'at', { type: 'setAutopilot', difficulty: 'Medium' });
|
||||
});
|
||||
@@ -0,0 +1,417 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import type { DatabaseSync } from 'node:sqlite';
|
||||
import { viewGame, type Action, type Game } from '../game/engine';
|
||||
import { treacheryDeck } from '../game/cards';
|
||||
import { ecazTreacheryCards } from '../game/ecaz-cards';
|
||||
import { recruitsPlayAction } from '../game/recruits';
|
||||
import { traitorDeck } from '../game/traitors';
|
||||
import type { RoomsClock } from '../db/rooms';
|
||||
import { unitStore } from './fixture-nexus-room-store';
|
||||
import { recruitsGame } from './fixture-recruits';
|
||||
|
||||
const clock: RoomsClock = { now: () => 73000, sleep: async () => {} };
|
||||
const play: Action = { type: 'card', card: 'ecaz-recruits' };
|
||||
const rows = (sqlite: DatabaseSync) => ({
|
||||
rooms: sqlite.prepare('SELECT * FROM rooms ORDER BY code').all(),
|
||||
seats: sqlite.prepare('SELECT * FROM seats ORDER BY player_id').all(),
|
||||
});
|
||||
|
||||
function custody(g: Game) {
|
||||
const cards = [...g.deck, ...g.discard, ...g.players.flatMap((p) => p.hand)];
|
||||
assert.deepEqual(
|
||||
cards.map((card) => card.id).sort(),
|
||||
[...treacheryDeck(g.expansions), ...ecazTreacheryCards()]
|
||||
.map((card) => card.id)
|
||||
.sort(),
|
||||
);
|
||||
const traitors = [
|
||||
...(g.traitorReserve ?? []),
|
||||
...g.players.flatMap((p) => [
|
||||
...p.traitors,
|
||||
...(p.faceDancers ?? []).map((card) => card.leader),
|
||||
]),
|
||||
];
|
||||
assert.deepEqual(traitors.sort(), traitorDeck(g.players, true).sort());
|
||||
for (const p of g.players) {
|
||||
const values = [p.reserves, p.tanks, ...Object.values(p.forces)];
|
||||
assert.ok(values.every((n) => Number.isSafeInteger(n) && n >= 0));
|
||||
assert.equal(
|
||||
values.reduce((a, b) => a + b, 0),
|
||||
20,
|
||||
);
|
||||
if (p.elites) {
|
||||
const elite = [
|
||||
p.elites.reserves,
|
||||
p.elites.tanks,
|
||||
...Object.values(p.elites.forces),
|
||||
];
|
||||
assert.ok(elite.every((n) => Number.isSafeInteger(n) && n >= 0));
|
||||
assert.equal(
|
||||
elite.reduce((a, b) => a + b, 0),
|
||||
3,
|
||||
);
|
||||
assert.ok(p.elites.reserves <= p.reserves && p.elites.tanks <= p.tanks);
|
||||
for (const [location, amount] of Object.entries(p.elites.forces))
|
||||
assert.ok(amount <= (p.forces[location] ?? 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function fixture(t: test.TestContext, advanced = true) {
|
||||
const store = unitStore();
|
||||
t.after(() => store.sqlite.close());
|
||||
const made = await store.rooms.createRoom(
|
||||
'Recruits recovery',
|
||||
'atreides',
|
||||
advanced,
|
||||
['ix', 'choam'],
|
||||
);
|
||||
const code = made.view.code,
|
||||
tokens = [made.token];
|
||||
for (const faction of ['fremen', 'tleilaxu', 'choam'] as const)
|
||||
tokens.push((await store.rooms.joinRoom(code, faction, faction)).token!);
|
||||
const auths = await Promise.all(
|
||||
tokens.map((token) => store.rooms.authenticate(code, token)),
|
||||
);
|
||||
const ids = [
|
||||
auths[0].playerId,
|
||||
auths[1].playerId,
|
||||
auths[2].playerId,
|
||||
auths[3].playerId,
|
||||
] as const;
|
||||
// Genuine identities/setup and dealt cards; the shared fixture explicitly stages Revival and normal losses.
|
||||
const g = recruitsGame(advanced, 3, ids);
|
||||
g.code = code;
|
||||
g.version = (await store.rooms.readRoom(code)).version;
|
||||
custody(g);
|
||||
const owner = g.players.find((p) =>
|
||||
p.hand.some((card) => card.id === 'ecaz-recruits'),
|
||||
)!.id;
|
||||
assert.equal(owner, ids[3]);
|
||||
store.sqlite
|
||||
.prepare('UPDATE rooms SET state=?, version=? WHERE code=?')
|
||||
.run(JSON.stringify(g), g.version, code);
|
||||
store.writes.length = 0;
|
||||
return { ...store, code, tokens, auths, ids, owner };
|
||||
}
|
||||
type Fixture = Awaited<ReturnType<typeof fixture>>;
|
||||
|
||||
async function act(f: Fixture, player: string, action: Action) {
|
||||
const rooms = f.restart(),
|
||||
index = f.ids.indexOf(player);
|
||||
assert.ok(index >= 0);
|
||||
const auth = await rooms.authenticate(f.code, f.tokens[index]);
|
||||
const before = await rooms.readRoom(f.code);
|
||||
await rooms.act(f.code, auth, before.version, action, clock);
|
||||
const after = await rooms.readRoom(f.code);
|
||||
custody(after);
|
||||
return after;
|
||||
}
|
||||
|
||||
async function restored(f: Fixture) {
|
||||
const g = await f.restart().readRoom(f.code),
|
||||
before = rows(f.sqlite);
|
||||
const publicRates = viewGame(g, f.owner).recruitsPreview!.rates;
|
||||
for (const [index, token] of f.tokens.entries()) {
|
||||
const rooms = f.restart(),
|
||||
auth = await rooms.authenticate(f.code, token);
|
||||
const view = await rooms.readSeatView(f.code, auth);
|
||||
assert.deepEqual(view, viewGame(g, f.ids[index]));
|
||||
assert.deepEqual(
|
||||
view,
|
||||
viewGame(JSON.parse(JSON.stringify(g)) as Game, f.ids[index]),
|
||||
);
|
||||
assert.deepEqual(view.recruitsPreview!.rates, publicRates);
|
||||
if (auth.playerId !== f.owner)
|
||||
assert.equal(view.recruitsPreview!.play, null);
|
||||
for (const rival of view.players.filter((p) => p.id !== auth.playerId))
|
||||
for (const field of [
|
||||
'hand',
|
||||
'traitors',
|
||||
'spice',
|
||||
'prediction',
|
||||
'faceDancers',
|
||||
])
|
||||
assert.equal(field in rival, false);
|
||||
}
|
||||
assert.deepEqual(rows(f.sqlite), before);
|
||||
custody(g);
|
||||
return g;
|
||||
}
|
||||
|
||||
async function noWrite(
|
||||
f: Fixture,
|
||||
player: string,
|
||||
action: Action,
|
||||
version?: number,
|
||||
reason?: RegExp,
|
||||
) {
|
||||
const rooms = f.restart(),
|
||||
auth = await rooms.authenticate(f.code, f.tokens[f.ids.indexOf(player)]);
|
||||
const current = await rooms.readRoom(f.code),
|
||||
before = rows(f.sqlite),
|
||||
writes = f.writes.length;
|
||||
const attempt = rooms.act(
|
||||
f.code,
|
||||
auth,
|
||||
version ?? current.version,
|
||||
action,
|
||||
clock,
|
||||
);
|
||||
if (reason) await assert.rejects(attempt, reason);
|
||||
else await assert.rejects(attempt);
|
||||
assert.deepEqual(rows(f.sqlite), before);
|
||||
assert.equal(f.writes.length, writes);
|
||||
}
|
||||
|
||||
/** Allow only the existing revival/CHOAM/Tleilaxu continuation through authenticated room actions. */
|
||||
async function settleRevival(f: Fixture) {
|
||||
for (let step = 0; step < 30; step++) {
|
||||
const g = await f.restart().readRoom(f.code);
|
||||
if (!g.pendingRevival && !g.decision && !g.response) return g;
|
||||
if (g.decision) {
|
||||
assert.ok(['choamFreeRevival', 'revivalStop'].includes(g.decision.kind));
|
||||
await act(f, g.decision.player, { type: 'decision', decline: true });
|
||||
} else if (g.response) {
|
||||
const next = g.players.find((p) => !g.response!.passed.includes(p.id));
|
||||
assert.ok(next);
|
||||
await act(f, next.id, { type: 'passResponse' });
|
||||
} else assert.fail('A pending revival needs an explicit continuation.');
|
||||
}
|
||||
assert.fail('The saved revival failed to settle.');
|
||||
}
|
||||
|
||||
void test('Recruits restores privately and counts earlier free revivals once across later free and paid returns', async (t) => {
|
||||
for (const advanced of [false, true]) {
|
||||
const f = await fixture(t, advanced),
|
||||
original = await restored(f);
|
||||
const seats = rows(f.sqlite).seats,
|
||||
initialAtreides = original.players[0];
|
||||
assert.deepEqual(
|
||||
recruitsPlayAction(viewGame(original, f.owner).recruitsPreview),
|
||||
play,
|
||||
);
|
||||
await noWrite(f, f.ids[0], play, undefined, /not in your hand/);
|
||||
await noWrite(
|
||||
f,
|
||||
f.owner,
|
||||
{ ...play, blocked: null },
|
||||
undefined,
|
||||
/additional mode or selection/,
|
||||
);
|
||||
|
||||
await act(f, f.ids[0], { type: 'revive', amount: 2, elite: 0 });
|
||||
const priorFree = await settleRevival(f);
|
||||
assert.equal(priorFree.players[0].freeForcesRevived, 2);
|
||||
assert.equal(priorFree.players[0].revived, 2);
|
||||
assert.equal(priorFree.players[0].spice, initialAtreides.spice);
|
||||
const played = await act(f, f.owner, play);
|
||||
assert.deepEqual(played.recruits, {
|
||||
turn: 2,
|
||||
player: f.owner,
|
||||
card: 'ecaz-recruits',
|
||||
});
|
||||
assert.equal(
|
||||
played.discard.filter((card) => card.id === 'ecaz-recruits').length,
|
||||
1,
|
||||
);
|
||||
assert.equal(
|
||||
played.players
|
||||
.flatMap((p) => p.hand)
|
||||
.some((card) => card.id === 'ecaz-recruits'),
|
||||
false,
|
||||
);
|
||||
for (const p of played.players) {
|
||||
const before = priorFree.players.find(
|
||||
(candidate) => candidate.id === p.id,
|
||||
)!;
|
||||
assert.deepEqual(
|
||||
[p.spice, p.reserves, p.tanks, p.revived, p.freeForcesRevived],
|
||||
[
|
||||
before.spice,
|
||||
before.reserves,
|
||||
before.tanks,
|
||||
before.revived,
|
||||
before.freeForcesRevived,
|
||||
],
|
||||
);
|
||||
}
|
||||
const active = await restored(f);
|
||||
assert.deepEqual(
|
||||
viewGame(active, f.owner).recruitsPreview!.rates,
|
||||
active.order.map((player) => {
|
||||
const faction = active.players.find((p) => p.id === player)!.faction;
|
||||
return {
|
||||
player,
|
||||
freeRate: faction === 'fremen' ? 6 : faction === 'choam' ? 0 : 4,
|
||||
limit: faction === 'tleilaxu' || faction === 'choam' ? 20 : 7,
|
||||
};
|
||||
}),
|
||||
);
|
||||
await noWrite(f, f.owner, play, priorFree.version);
|
||||
await noWrite(f, f.owner, play, active.version, /not in your hand/);
|
||||
|
||||
await act(f, f.ids[0], { type: 'revive', amount: 2, elite: 0 });
|
||||
const four = await settleRevival(f);
|
||||
assert.equal(four.players[0].freeForcesRevived, 4);
|
||||
assert.equal(four.players[0].revived, 4);
|
||||
assert.equal(four.players[0].spice, initialAtreides.spice);
|
||||
await restored(f);
|
||||
await act(f, f.ids[0], { type: 'revive', amount: 3, elite: 0 });
|
||||
const seven = await settleRevival(f);
|
||||
assert.equal(seven.players[0].freeForcesRevived, 4);
|
||||
assert.equal(seven.players[0].revived, 7);
|
||||
assert.equal(seven.players[0].spice, initialAtreides.spice - 6);
|
||||
assert.equal(seven.players[0].tanks, initialAtreides.tanks - 7);
|
||||
assert.equal(seven.players[0].reserves, initialAtreides.reserves + 7);
|
||||
assert.equal(
|
||||
seven.discard.filter((card) => card.id === 'ecaz-recruits').length,
|
||||
1,
|
||||
);
|
||||
await noWrite(f, f.ids[0], { type: 'revive', amount: 1, elite: 0 });
|
||||
await restored(f);
|
||||
assert.deepEqual(rows(f.sqlite).seats, seats);
|
||||
}
|
||||
});
|
||||
|
||||
void test('pending and already paid revivals reject Recruits after restart without changing the saved transaction', async (t) => {
|
||||
const f = await fixture(t);
|
||||
const pending = await act(f, f.ids[0], {
|
||||
type: 'revive',
|
||||
amount: 3,
|
||||
elite: 0,
|
||||
});
|
||||
assert.equal(pending.decision?.kind, 'choamFreeRevival');
|
||||
assert.equal(pending.pendingRevival?.cost, 2);
|
||||
await restored(f);
|
||||
assert.match(
|
||||
viewGame(pending, f.owner).recruitsPreview!.play!.blocked!,
|
||||
/transaction or priority/,
|
||||
);
|
||||
await noWrite(f, f.owner, play, undefined, /transaction or priority/);
|
||||
assert.deepEqual(
|
||||
(await f.restart().readRoom(f.code)).pendingRevival,
|
||||
pending.pendingRevival,
|
||||
);
|
||||
const paid = await settleRevival(f);
|
||||
assert.equal(paid.players[0].revived, 3);
|
||||
assert.equal(paid.players[0].freeForcesRevived, 2);
|
||||
assert.equal(paid.players[0].spice, 18);
|
||||
assert.match(
|
||||
viewGame(paid, f.owner).recruitsPreview!.play!.blocked!,
|
||||
/after a paid normal force revival/,
|
||||
);
|
||||
assert.equal(
|
||||
recruitsPlayAction(viewGame(paid, f.owner).recruitsPreview),
|
||||
null,
|
||||
);
|
||||
await noWrite(
|
||||
f,
|
||||
f.owner,
|
||||
play,
|
||||
undefined,
|
||||
/after a paid normal force revival/,
|
||||
);
|
||||
const final = await restored(f);
|
||||
assert.equal(final.recruits, undefined);
|
||||
assert.ok(final.players[3].hand.some((card) => card.id === 'ecaz-recruits'));
|
||||
});
|
||||
|
||||
void test('competing authenticated Recruits plays commit one physical discard and one effect', async (t) => {
|
||||
const f = await fixture(t),
|
||||
before = await f.rooms.readRoom(f.code),
|
||||
seatRows = rows(f.sqlite).seats;
|
||||
let entered = 0,
|
||||
release!: () => void;
|
||||
const both = new Promise<void>((resolve) => {
|
||||
release = resolve;
|
||||
});
|
||||
f.hooks.beforeWrite = async () => {
|
||||
if (++entered === 2) release();
|
||||
await both;
|
||||
};
|
||||
const attempts = await Promise.allSettled(
|
||||
[0, 1].map(() =>
|
||||
f.rooms.act(f.code, f.auths[3], before.version, play, clock),
|
||||
),
|
||||
);
|
||||
f.hooks.beforeWrite = undefined;
|
||||
assert.equal(
|
||||
attempts.filter((result) => result.status === 'fulfilled').length,
|
||||
1,
|
||||
);
|
||||
assert.deepEqual(
|
||||
f.writes.map((write) => write.changes).sort((a, b) => a - b),
|
||||
[0, 1],
|
||||
);
|
||||
const after = await restored(f);
|
||||
assert.equal(after.version, before.version + 1);
|
||||
assert.equal(
|
||||
after.discard.filter((card) => card.id === 'ecaz-recruits').length,
|
||||
1,
|
||||
);
|
||||
assert.equal(
|
||||
after.log.filter((entry) => entry.text.includes('played Recruits.')).length,
|
||||
1,
|
||||
);
|
||||
for (const p of after.players) assert.equal(p.revived, 0);
|
||||
await noWrite(f, f.owner, play, before.version);
|
||||
await noWrite(f, f.owner, play, after.version);
|
||||
assert.deepEqual(rows(f.sqlite).seats, seatRows);
|
||||
});
|
||||
|
||||
void test('malformed active Recruits saves fail private reads and actions without SQL writes', async (t) => {
|
||||
const f = await fixture(t),
|
||||
valid = await act(f, f.owner, play);
|
||||
const mutations: ((g: Game) => void)[] = [
|
||||
(g) => {
|
||||
g.recruits!.turn++;
|
||||
},
|
||||
(g) => {
|
||||
g.players[0].freeForcesRevived = 1;
|
||||
},
|
||||
(g) => {
|
||||
g.players[0].hand.push(
|
||||
g.discard.find((card) => card.id === 'ecaz-recruits')!,
|
||||
);
|
||||
},
|
||||
];
|
||||
for (const mutate of mutations) {
|
||||
const corrupt = JSON.parse(JSON.stringify(valid)) as Game;
|
||||
mutate(corrupt);
|
||||
f.sqlite
|
||||
.prepare('UPDATE rooms SET state=? WHERE code=?')
|
||||
.run(JSON.stringify(corrupt), f.code);
|
||||
const before = rows(f.sqlite),
|
||||
writes = f.writes.length;
|
||||
for (const [index, token] of f.tokens.entries()) {
|
||||
const rooms = f.restart(),
|
||||
auth = await rooms.authenticate(f.code, token);
|
||||
await assert.rejects(
|
||||
rooms.readSeatView(f.code, auth),
|
||||
/Recruits|Ecaz Treachery/,
|
||||
);
|
||||
assert.throws(
|
||||
() => viewGame(corrupt, f.ids[index]),
|
||||
/Recruits|Ecaz Treachery/,
|
||||
);
|
||||
}
|
||||
await noWrite(
|
||||
f,
|
||||
f.owner,
|
||||
{ type: 'ready' },
|
||||
valid.version,
|
||||
/Recruits|Ecaz Treachery/,
|
||||
);
|
||||
await noWrite(
|
||||
f,
|
||||
f.owner,
|
||||
{ type: 'setAutopilot', difficulty: 'Easy' },
|
||||
valid.version,
|
||||
/Recruits|Ecaz Treachery/,
|
||||
);
|
||||
assert.deepEqual(rows(f.sqlite), before);
|
||||
assert.equal(f.writes.length, writes);
|
||||
}
|
||||
});
|
||||
@@ -154,7 +154,7 @@ void test('the public collection and ten full card topics are searchable, linked
|
||||
);
|
||||
});
|
||||
|
||||
void test('base, Ix and Ecaz presentations stay unchanged as the two CHOAM deck replacements become available', () => {
|
||||
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);
|
||||
@@ -168,8 +168,9 @@ void test('base, Ix and Ecaz presentations stay unchanged as the two CHOAM deck
|
||||
const presentation = cardPresentation(card);
|
||||
assert.equal(presentation.category, 'Special treachery');
|
||||
assert.ok(presentation.gameplay!.length >= 4);
|
||||
assert.equal(presentation.availability, undefined);
|
||||
assert.deepEqual(presentation.topics, []);
|
||||
assert.match(presentation.availability ?? '', card.effect === 'recruits'
|
||||
? /development controls during Revival/ : /battle effect is still being implemented/);
|
||||
assert.deepEqual(presentation.topics.map((topic) => topic.id), ['card-recruits']);
|
||||
}
|
||||
assert.equal(treacheryDeck().length, 33);
|
||||
assert.equal(treacheryDeck(['ix']).length, 47);
|
||||
|
||||
Reference in new issue
Block a user