Retain independent Ecaz cards with Nexus Kull
Verify and publish checkpoint container / container (push) Canceled after 0s
Verify and publish checkpoint container / container (push) Canceled after 0s
This commit is contained in:
1 parent
66c563be71
commit
ecc4eb658a
7 files changed
+305
-11
No files matched your search
@@ -0,0 +1,67 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { applyAction, createGame, joinGame, newPlayer, viewGame, type Game } from '../game/engine';
|
||||
import { treacheryDeck } from '../game/cards';
|
||||
import { ecazTreacheryCards } from '../game/ecaz-cards';
|
||||
import { richeseCards } from '../game/richese-cards';
|
||||
import { advanceSemutaNexusTrade } from './fixture-semuta-nexus-trade';
|
||||
|
||||
function lobby(richese: boolean, ecazExpansion: boolean): Game {
|
||||
const expansions = ecazExpansion ? ['ix', 'choam', 'ecaz'] : ['ix', 'choam'];
|
||||
const game = createGame('NEXUSKULLINDEPENDENT', newPlayer('c', 'CHOAM', 'choam'), false, expansions);
|
||||
joinGame(game, newPlayer('r', richese ? 'Richese' : 'Guild', richese ? 'richese' : 'guild'));
|
||||
joinGame(game, newPlayer('a', 'Atreides', 'atreides'));
|
||||
return game;
|
||||
}
|
||||
|
||||
function inventory(game: Game): string[] {
|
||||
return [...game.deck, ...game.discard, ...(game.richeseCache ?? []), ...(game.richeseRemoved ?? []),
|
||||
...(game.auction?.cards.slice(game.auction.index) ?? []), ...(game.ixAuction?.cards ?? []),
|
||||
...game.players.flatMap(player => player.hand)].map(card => card.id).sort();
|
||||
}
|
||||
|
||||
for (const richese of [false, true]) for (const ecazExpansion of [false, true]) {
|
||||
void test(`Public Basic Nexus Kull retains independent Ecaz cards${richese ? ' with Richese' : ''}${ecazExpansion ? ' and selected Ecaz deck' : ''}`, () => {
|
||||
let game = lobby(richese, ecazExpansion);
|
||||
// Vary option order: selecting Kull while it is a default and explicitly
|
||||
// selecting it after the independent module must both retain the choice.
|
||||
const selections = richese
|
||||
? ['nexusCards', 'kullPreview', 'ecazTreachery', 'kullPreview']
|
||||
: ['ecazTreachery', 'nexusCards', 'kullPreview'];
|
||||
for (const moduleName of selections)
|
||||
game = applyAction(game, 'c', {type:'moduleOption', module:moduleName, enabled:true});
|
||||
const options = viewGame(game, 'c').lobbyModules!;
|
||||
assert.equal(options.ecazTreachery, true); assert.equal(options.nexusCards, true); assert.equal(options.kullPreview, true);
|
||||
for (const player of game.players) game = applyAction(game, player.id, {type:'ready'});
|
||||
game = applyAction(game, 'c', {type:'start'});
|
||||
assert.equal(game.ecazTreachery, true, 'Selected module must reach game state');
|
||||
assert.equal(game.kullPreview, true); assert.equal(game.nexusKullPreview, true);
|
||||
assert.ok(game.nexusCards); if (richese) assert.equal(game.semutaPreview, true);
|
||||
const expected = [...treacheryDeck(game.expansions), ...ecazTreacheryCards(), ...(richese ? richeseCards() : [])].map(card => card.id).sort();
|
||||
assert.deepEqual(inventory(game), expected, 'Every selected original card is present once');
|
||||
game = advanceSemutaNexusTrade(game, state => state.status === 'playing');
|
||||
assert.deepEqual(inventory(game), expected, 'Setup deals preserve every selected original card');
|
||||
assert.ok(game.nexusCards!.cards, 'Nexus cards are initialized during real setup');
|
||||
});
|
||||
}
|
||||
|
||||
for (const independent of [false, true]) void test(
|
||||
`Public Basic Nexus Kull never silently drops selected Leader Skills${independent ? ' with independent Ecaz cards' : ''}`, () => {
|
||||
let game = lobby(true, true);
|
||||
for (const moduleName of [...(independent ? ['ecazTreachery'] : []), 'nexusCards', 'leaderSkills', 'kullPreview'])
|
||||
game = applyAction(game, 'c', {type:'moduleOption', module:moduleName, enabled:true});
|
||||
const options = viewGame(game, 'c').lobbyModules!;
|
||||
assert.equal(options.leaderSkills, true); assert.equal(options.nexusCards, true); assert.equal(options.kullPreview, true);
|
||||
for (const player of game.players) game = applyAction(game, player.id, {type:'ready'});
|
||||
const before = structuredClone(game);
|
||||
let started: Game | undefined;
|
||||
try { started = applyAction(game, 'c', {type:'start'}); }
|
||||
catch (error) {
|
||||
assert.ok(error instanceof Error && /skill|module|combination/i.test(error.message), 'Unsupported starts need a readable module reason');
|
||||
assert.deepEqual(game, before, 'Rejected start cannot change the lobby');
|
||||
}
|
||||
if (started) {
|
||||
assert.ok(started.leaderSkills, 'A successful start must retain selected Leader Skills');
|
||||
assert.equal(started.kullPreview, true);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user