43 lines
2.4 KiB
TypeScript
43 lines
2.4 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { createGame, newPlayer, viewGame } from '../game/engine';
|
|
import { acquireDuke, captureDuke, createDukeVidal, DUKE_VIDAL_ID, executeCapturedDuke } from '../game/duke-vidal';
|
|
import { newRevivalRules } from '../game/revival';
|
|
import { createNexusCards } from '../game/nexus-cards';
|
|
import { baseDeck } from '../game/cards';
|
|
import { ecazDukeRevivalBlock } from '../game/ecaz-duke-revival';
|
|
|
|
/** Staged public-equivalent custody in a supported Advanced Nexus roster. */
|
|
function fixture() {
|
|
const game = createGame('DUKEGHOLAPRIVACY', newPlayer('ec', 'Ecaz', 'ecaz'), true, ['ecaz']);
|
|
game.players.push(newPlayer('h', 'Harkonnen', 'harkonnen'), newPlayer('g', 'Guild', 'guild'));
|
|
Object.assign(game, { status:'playing', phase:0, turn:1, order:['ec','h','g'],
|
|
revivalRules:newRevivalRules(), nexusCards:{cards:createNexusCards(game.players, () => 0.5),phase:null} });
|
|
game.deck = baseDeck();
|
|
const ghola = game.deck.findIndex(card => card.effect === 'ghola');
|
|
assert.ok(ghola >= 0);
|
|
game.players[0].hand.push(game.deck.splice(ghola, 1)[0]);
|
|
const prior = acquireDuke(createDukeVidal(), 'g', 1, 'ecaz');
|
|
game.dukeVidal = captureDuke(prior, 'h', 'g', 1, 'arrakeen');
|
|
return game;
|
|
}
|
|
|
|
void test('Ecaz Ghola options do not disclose a secretly executed foreign Duke captive', () => {
|
|
const alive = fixture(), executed = structuredClone(alive);
|
|
executed.dukeVidal = executeCapturedDuke(executed.dukeVidal!, 'h', executed.turn);
|
|
assert.ok(ecazDukeRevivalBlock(alive, 'ec'), 'Actual living captive is unavailable');
|
|
assert.equal(ecazDukeRevivalBlock(executed, 'ec'), null, 'Secret execution changes authoritative eligibility');
|
|
const before = viewGame(alive, 'ec'), after = viewGame(executed, 'ec');
|
|
assert.deepEqual(before.dukeVidal, after.dukeVidal, 'Duke custody remains publicly equivalent');
|
|
assert.deepEqual(before.ghola, after.ghola, 'Ghola options must not reveal the hidden execution');
|
|
assert.equal(after.ghola.leaders.some(leader => leader.id === DUKE_VIDAL_ID), false);
|
|
});
|
|
|
|
void test('Ecaz is offered its publicly dead Duke for Ghola', () => {
|
|
const game = fixture();
|
|
game.dukeVidal = createDukeVidal();
|
|
game.dukeVidal.leader.dead = true;
|
|
game.dukeVidal.leader.deaths = 1;
|
|
assert.equal(viewGame(game, 'ec').ghola.leaders.some(leader => leader.id === DUKE_VIDAL_ID), true);
|
|
});
|