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
89 lines
2.7 KiB
TypeScript
89 lines
2.7 KiB
TypeScript
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;
|
|
});
|
|
}
|