Files
Dune/tests/battle-card-slots.test.ts
Quintine 04501567d0 Connect Harass & Withdraw to the battle preview
The independent Ecaz Treachery variant now supports Harass in either physical battle-card slot. A category-null Prescience answer keeps its identity private without erasing the selected card. Exact undialed normal/elite counters return before battle losses; opposing successful Traitors cancel withdrawal, ordinary leader deaths still resolve, and the card is discarded exactly once. Controls, all four AI profiles and saved continuation share the same physical quote. Existing Planetologist inspection and literal Truthtrance slot promises retain their meanings.

Unique Basic/Advanced physical allocations are supported. Ambiguous allocations, co-present Ecaz allied armies on either side, Richese card-family configurations and other optional modules remain gated before sealing from public/own context. The pending Stone Burner timing question is not assumed answered. Reveal-before-explosion order and mandatory disposal on an own-Traitor win are explicit source-timing/specificity inferences, consistent with existing Planetologist precedence. Reinforcements and full variant/public mode acceptance remain unfinished.

Independent rules/privacy/persistence review fixed asymmetric selector legality, misleading blocked-card guidance, invalid restored battle pairs, native-only inspection bypass and unsupported allied-army admission. Ixian fixtures preserve all seven physical cyborgs. The first broad run caught a semantic-status lint error in the blocked guidance; replacing the paragraph role with an output element fixed it. A subsequent broad run passed 4,775 of 4,776 tests and exposed an old UI assertion requiring category-null slots to be disabled. The updated regression verifies enabled category-null selectors exclude ordinary held cards, while exact leader/dial locks and submitted values remain bound; focused controls pass 14/14. No game source changed after the eight samples or browser replay. Types, lint, 4776 offline tests, build and 43 HTTP tests pass with unchanged source. Authenticated SQLite cases verify sealed private restoration and competing duplicate traitor actions with one physical resolution.

Eight fixed genuine six-seat games finish: basic/Easy: 1803 actions, 0 Harass plans, 0 withdrawals, 48 periodic restores; basic/Medium: 225 actions, 0 Harass plans, 0 withdrawals, 6 periodic restores; basic/Hard: 2184 actions, 1 Harass plans, 1 withdrawals, 59 periodic restores; basic/Brutal: 2073 actions, 1 Harass plans, 1 withdrawals, 56 periodic restores; advanced/Easy: 2057 actions, 1 Harass plans, 1 withdrawals, 55 periodic restores; advanced/Medium: 532 actions, 0 Harass plans, 0 withdrawals, 14 periodic restores; advanced/Hard: 538 actions, 0 Harass plans, 0 withdrawals, 14 periodic restores; advanced/Brutal: 544 actions, 0 Harass plans, 0 withdrawals, 14 periodic restores. All 218 game-source files match their source-stable runs; exact card/traitor/force custody and periodic/terminal private views are checked. Browser controls verify the full card, category None, Defense-first legality, actual sealing/reveal, four returned forces, ordinary leader death, disposal and refresh. A separate final-source replay verifies the conserved browser fixture and opposing continuation, including Face Dancer replacement. This is bounded playability evidence, not full compliance or AI calibration.

All 936 opening games and their original seat/recovery records remain unchanged (970 after checks); all 937 present immediately before checks are also preserved. Database integrity and foreign keys pass. The healthy server was reused after the power failure without restart, reset or recurring automation.

Verified source tree: be193613c455c5b76b49800fe3a7400504ea879af34c59621ade3d44f0fe019d
2026-09-14 04:41:30 +10:00

106 lines
5.2 KiB
TypeScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { baseDeck, treacheryDeck } from '../game/cards';
import { ecazTreacheryCards } from '../game/ecaz-cards';
import {
battleCardSlotEligible,
battleCategoryInspectionValue,
fixedBattleInspectionMatches,
validBattleSlotPair,
} from '../game/battle-card-slots';
const ecaz = Object.fromEntries(ecazTreacheryCards().map((card) => [card.effect, card]));
const base = baseDeck();
const projectile = base.find((card) => card.kind === 'projectile')!;
const shield = base.find((card) => card.kind === 'shield')!;
const worthless = base.find((card) => card.kind === 'worthless')!;
const hajr = base.find((card) => card.effect === 'hajr')!;
void test('slot specials preserve single-card custody and alternate-role category requirements', () => {
const cards = treacheryDeck(['ix']);
const chemistry = cards.find((card) => card.kind === 'chemistry')!;
const weirding = cards.find((card) => card.kind === 'weirdingWay')!;
assert.equal(validBattleSlotPair(ecaz.harassWithdraw, shield), true);
assert.equal(validBattleSlotPair(projectile, ecaz.harassWithdraw), true);
assert.equal(validBattleSlotPair(ecaz.harassWithdraw, ecaz.harassWithdraw), false);
assert.equal(validBattleSlotPair(ecaz.recruits, shield), false);
assert.equal(validBattleSlotPair(ecaz.harassWithdraw, weirding), false);
assert.equal(validBattleSlotPair(chemistry, ecaz.harassWithdraw), false);
assert.equal(validBattleSlotPair(weirding, ecaz.harassWithdraw), true);
assert.equal(validBattleSlotPair(ecaz.harassWithdraw, chemistry), true);
assert.equal(validBattleSlotPair(chemistry, weirding), true);
assert.equal(validBattleSlotPair(hajr, shield, true), true);
assert.equal(validBattleSlotPair(hajr, weirding, true), false);
});
void test('only the two exact canonical Ecaz battle specials occupy either slot', () => {
for (const effect of ['reinforcements', 'harassWithdraw'] as const) {
assert.equal(battleCardSlotEligible('weapon', ecaz[effect]), true);
assert.equal(battleCardSlotEligible('defense', ecaz[effect]), true);
}
for (const forged of [
ecaz.recruits,
{ ...ecaz.reinforcements, name: 'Forged Reinforcements' },
{ ...ecaz.harassWithdraw, extra: true },
{ ...ecaz.reinforcements, id: 'similar-reinforcements' },
]) {
assert.equal(battleCardSlotEligible('weapon', forged), false);
assert.equal(battleCardSlotEligible('defense', forged), false);
}
});
void test('ordinary categories and externally validated Planetologist substitution remain unchanged', () => {
assert.equal(battleCardSlotEligible('weapon', undefined), true);
assert.equal(battleCardSlotEligible('defense', undefined), true);
assert.equal(battleCardSlotEligible('weapon', projectile), true);
assert.equal(battleCardSlotEligible('defense', projectile), false);
assert.equal(battleCardSlotEligible('weapon', shield), false);
assert.equal(battleCardSlotEligible('defense', shield), true);
assert.equal(battleCardSlotEligible('weapon', worthless), true);
assert.equal(battleCardSlotEligible('defense', worthless), true);
assert.equal(battleCardSlotEligible('weapon', hajr), false);
assert.equal(battleCardSlotEligible('weapon', hajr, { planetologistWeapon: true }), true);
assert.equal(battleCardSlotEligible('defense', hajr, { planetologistWeapon: true }), false);
});
void test('category inspection hides Ecaz slot occupants without changing existing Planetologist or ordinary answers', () => {
assert.equal(
battleCategoryInspectionValue('weapon', ecaz.reinforcements.id, ecaz.reinforcements),
null,
);
assert.equal(
battleCategoryInspectionValue('defense', ecaz.harassWithdraw.id, ecaz.harassWithdraw),
null,
);
assert.equal(battleCategoryInspectionValue('weapon', hajr.id, hajr), hajr.id);
assert.equal(battleCategoryInspectionValue('defense', worthless.id, worthless), worthless.id);
assert.equal(battleCategoryInspectionValue('weapon', projectile.id, projectile), projectile.id);
assert.equal(battleCategoryInspectionValue('weapon', ecaz.recruits.id, ecaz.recruits), ecaz.recruits.id);
});
void test('non-card fields, empty slots and unfinished partial values preserve their exact shape', () => {
assert.equal(battleCategoryInspectionValue('dial', 2.5), 2.5);
assert.equal(battleCategoryInspectionValue('leader', 'atreides-0'), 'atreides-0');
assert.equal(battleCategoryInspectionValue('weapon', null), null);
assert.equal(battleCategoryInspectionValue('defense', undefined), undefined);
assert.throws(
() => battleCategoryInspectionValue('weapon', projectile.id, shield),
/does not match/,
);
});
void test('fixed category comparisons keep partial search open and compare resolved category values', () => {
assert.equal(fixedBattleInspectionMatches('weapon', null, undefined), true);
assert.equal(
fixedBattleInspectionMatches('weapon', null, ecaz.reinforcements.id, ecaz.reinforcements),
true,
);
assert.equal(fixedBattleInspectionMatches('weapon', null, projectile.id, projectile), false);
assert.equal(
fixedBattleInspectionMatches('defense', worthless.id, worthless.id, worthless),
true,
);
assert.equal(fixedBattleInspectionMatches('dial', 3.5, 3.5), true);
assert.equal(fixedBattleInspectionMatches('leader', 'atreides-0', null), false);
});