Admit the genuine private setup profile for Basic Moritani with base opponents, exactly the Ecaz expansion and no other optional modules. Keep all14 physical skills, private two-card offers, starting-card/Traitor order and Moritani's final six-force placement. Public starts and complete-mode/publication gates remain. Share public profile eligibility across Banker, Diplomat, Sandmaster movement and worm riding, Smuggler shipping/collection, Bureaucrat payments, Planetologist controls/bots and Suk/Rihani/Sandmaster battle settlement. Admission reads no hidden cards or random deal. Preserve base/CHOAM boundaries and existing source questions; no full AI implementation, strategy or calibration changes. Genuine setup regressions cover all14 assignments, legal profiles and guards, Terror Assassination death and exact skill return, optional own revival draw/privacy, Sabotage, movement controls/bots, Smuggler shipment and Bureaucrat paid bribes. Battle actions cover Rihani exchange, Sandmaster spice, Banker funds, Suk casualties and Smuggler collection. Actual enemy alliances prove losing-ally retention excludes mandatory Planetologist Special and Diplomat-copy disposal. A real worm/Nexus ride collects Sandmaster spice once. Authenticated in-memory SQLite restarts and concurrent skill choices preserve one assignment, private offers, saved seats and final Moritani placement. Conserved staged positions are explicitly distinct from played phase histories. Add a reproducible moritani-skills profile to the existing faction-game runner, including fixed2-6-player Basic rosters, seed offsets16-20 and saved resume. Verify expected module presence, all14 physical skills and ordinary Traitor custody alongside existing card/force/private-view checks. Default six expansion samples and base samples retain their rosters/ordinals. No live DB is used by these complete-game samples. CLI regressions check interrupted continuation and Advanced refusal; corruption tests catch lost cards and entire module loss. Independent review caught an old all-base worm guard and a sample checker that missed whole-module deletion; both fixed with meaningful regressions and reviewed. Initial edits had a stale helper reference and final lint found an unused import; these were corrected. Types, lint, all 5034 offline tests and build pass on stable final source. Five genuine complete-game samples passed with no rejected actions:2 players189 actions/5 restores,3 players53/1,4 players862/23, 5 players116/3 and6 players1338/36. These are legality samples, not calibration or exhaustive faction/card acceptance. No endpoint/auth/storage changes; existing HTTP suite not repeated, while new authenticated storage and live browser actions exercise the newly admitted profile through production boundaries. Browser created a fresh Basic human Moritani/Easy Emperor lobby, then the existing backed-up local initializer started that named ready room without replacing seats. Human inspected both Killer Medic bands, assigned Lupino Ord, chose a private Traitor and placed six in Polar Sink after all other setup. Refresh preserved the two public skills, own hand/Traitor and6 deployed/14 reserves at pending Storm. Mobile skill panel339px, client/scroll337; viewport restored afterward. Screenshot capture timed out, so full visual/screen-reader acceptance stays open. All 1580 opening games, 3348 saved seats and auxiliary rows remain identical. One isolated QA game adds one human seat and entry receipt; its row is unchanged after setup through refresh, with all seats unchanged. SQLite integrity and foreign keys pass. No server restart, migration, reset or recurring automation. Existing unfinished Leader Skill bands and material rulings remain explicit in the new integration guide and internal checklist. Private evidence: 20260921-moritani-skills. Verified source tree: d5078661ecc2199b2bbfebd18034b16585d06410a697a78dc514bfa5b3b77a1c
152 lines
5.3 KiB
TypeScript
152 lines
5.3 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { botActions } from '../game/bots';
|
|
import {
|
|
applyAction,
|
|
createGame,
|
|
initializeBaseGameForAudit,
|
|
initializeFactionExpansionsGameForAudit,
|
|
joinGame,
|
|
newPlayer,
|
|
viewGame,
|
|
} from '../game/engine';
|
|
import { sampleInventory, verifySampleCustody } from '../tools/sample-custody';
|
|
import { completedMoritaniSkillsGame } from './moritani-skills-fixture';
|
|
|
|
void test('Moritani Skills sample custody checks the physical skill and Traitor inventories after genuine setup', () => {
|
|
const game = completedMoritaniSkillsGame();
|
|
const inventory = sampleInventory(game);
|
|
assert.ok(inventory.traitors);
|
|
verifySampleCustody(game, inventory);
|
|
const skills = structuredClone(game);
|
|
skills.leaderSkills!.deck.pop();
|
|
assert.throws(() => verifySampleCustody(skills, inventory));
|
|
const missing = structuredClone(game);
|
|
delete missing.leaderSkills;
|
|
assert.throws(() => verifySampleCustody(missing, inventory), /Leader Skills module custody/);
|
|
const traitors = structuredClone(game);
|
|
traitors.players[0].traitors[0] = traitors.players[1].traitors[0];
|
|
assert.throws(() => verifySampleCustody(traitors, inventory), /traitor custody/);
|
|
});
|
|
|
|
function fixture(advanced = false) {
|
|
let game = createGame(
|
|
'SAMPLEQA',
|
|
newPlayer('emperor', 'Emperor', 'emperor'),
|
|
advanced,
|
|
);
|
|
for (const faction of ['fremen', 'atreides', 'harkonnen'] as const)
|
|
joinGame(game, newPlayer(faction, faction, faction));
|
|
for (const player of game.players) {
|
|
player.ready = true;
|
|
player.bot = 'Medium';
|
|
}
|
|
game = initializeBaseGameForAudit(game);
|
|
const inventory = sampleInventory(game);
|
|
verifySampleCustody(game, inventory);
|
|
for (let steps = 0; game.status === 'setup' && steps < 30; steps++) {
|
|
const choice = game.players.flatMap((player) =>
|
|
botActions(viewGame(game, player.id)).map((action) => ({
|
|
player,
|
|
action,
|
|
})),
|
|
)[0];
|
|
assert.ok(choice, 'genuine setup has a legal AI choice');
|
|
game = applyAction(game, choice.player.id, choice.action);
|
|
verifySampleCustody(game, inventory);
|
|
}
|
|
assert.equal(game.status, 'playing');
|
|
return { game, inventory };
|
|
}
|
|
|
|
void test('sample custody follows genuine setup and distinct Advanced elite inventories', () => {
|
|
for (const advanced of [false, true]) {
|
|
const { game, inventory } = fixture(advanced);
|
|
verifySampleCustody(JSON.parse(JSON.stringify(game)), inventory);
|
|
const corrupted = structuredClone(game);
|
|
const card = corrupted.deck.pop();
|
|
assert.ok(card);
|
|
assert.throws(
|
|
() => verifySampleCustody(corrupted, inventory),
|
|
/physical card custody/,
|
|
);
|
|
}
|
|
});
|
|
|
|
void test('sample custody detects balanced negative forces and elite subsets outside their group', () => {
|
|
const { game, inventory } = fixture(true);
|
|
const negative = structuredClone(game);
|
|
negative.players[0].tanks = -1;
|
|
negative.players[0].reserves++;
|
|
assert.throws(
|
|
() => verifySampleCustody(negative, inventory),
|
|
/nonnegative forces/,
|
|
);
|
|
const missing = structuredClone(game);
|
|
delete missing.players.find((seat) => seat.faction === 'fremen')!.elites;
|
|
assert.throws(
|
|
() => verifySampleCustody(missing, inventory),
|
|
/missing elite inventory fremen/,
|
|
);
|
|
const misplaced = structuredClone(game);
|
|
const player = misplaced.players.find((seat) => seat.faction === 'emperor')!;
|
|
assert.ok(player.elites);
|
|
player.elites.reserves--;
|
|
player.elites.forces['arrakeen:10'] = 1;
|
|
assert.throws(
|
|
() => verifySampleCustody(misplaced, inventory),
|
|
/elite board subset/,
|
|
);
|
|
});
|
|
|
|
void test('sample custody catches a duplicated base traitor after setup despite preserved hand size', () => {
|
|
const { game, inventory } = fixture();
|
|
const original = game.players[0].traitors[0];
|
|
assert.ok(original);
|
|
const other = game.players.find((player) => player.id !== game.players[0].id)!
|
|
.traitors[0];
|
|
assert.ok(other && other !== original);
|
|
game.players[0].traitors[0] = other;
|
|
assert.throws(
|
|
() => verifySampleCustody(game, inventory),
|
|
/physical base traitor custody/,
|
|
);
|
|
});
|
|
|
|
void test('sample custody retains all seven Ixian cyborgs in genuine expansion setup', () => {
|
|
const lobby = createGame(
|
|
'SAMPLEIX',
|
|
newPlayer('ixians', 'Ixians', 'ixians'),
|
|
false,
|
|
['ix'],
|
|
);
|
|
for (const faction of ['tleilaxu', 'atreides', 'harkonnen'] as const)
|
|
joinGame(lobby, newPlayer(faction, faction, faction));
|
|
for (const player of lobby.players) player.ready = true;
|
|
const game = initializeFactionExpansionsGameForAudit(lobby);
|
|
const inventory = sampleInventory(game);
|
|
verifySampleCustody(game, inventory);
|
|
const player = game.players.find((seat) => seat.faction === 'ixians')!;
|
|
assert.ok(player.elites);
|
|
player.elites.reserves--;
|
|
assert.throws(
|
|
() => verifySampleCustody(game, inventory),
|
|
/elite custody ixians/,
|
|
);
|
|
});
|
|
|
|
void test('resumed sample inventory cannot shrink with a deleted leader and matching Traitor card', () => {
|
|
const { game } = fixture();
|
|
const leader = game.players[0].leaders.pop();
|
|
assert.ok(leader);
|
|
game.traitorReserve = game.traitorReserve?.filter(
|
|
(card) => card !== leader.id,
|
|
);
|
|
for (const player of game.players)
|
|
player.traitors = player.traitors.filter((card) => card !== leader.id);
|
|
assert.throws(
|
|
() => verifySampleCustody(game, sampleInventory(game)),
|
|
/physical base traitor custody/,
|
|
);
|
|
});
|