Connect native Discovery setup and nested force paths
This commit is contained in:
1 parent
8d17fab3de
commit
67ce690064
17 files changed
+1379
-39
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createGame, initializeDiscoveryGameForAudit, joinGame, newPlayer, RuleError, type Game } from '../game/engine';
|
||||
import type { FactionId } from '../game/catalog';
|
||||
import { createTechTokens } from '../game/tech-tokens';
|
||||
import { createStrongholdCards } from '../game/stronghold-cards';
|
||||
|
||||
function lobby(roster: FactionId[], expansions: string[], advanced = true): Game {
|
||||
const game = createGame('DISCINIT', newPlayer(roster[0], roster[0], roster[0]), advanced, expansions);
|
||||
for (const faction of roster.slice(1)) joinGame(game, newPlayer(faction, faction, faction));
|
||||
for (const player of game.players) player.ready = true;
|
||||
game.discoveryEnabled = true;
|
||||
return game;
|
||||
}
|
||||
|
||||
void test('Discovery requires the selected native family and does not admit paired or mixed E3', () => {
|
||||
const unsupported = [
|
||||
lobby(['ixians', 'guild'], []),
|
||||
lobby(['richese', 'guild'], ['ix']),
|
||||
lobby(['ecaz', 'moritani', 'guild'], ['ecaz']),
|
||||
lobby(['ecaz', 'ixians', 'guild'], ['ecaz', 'ix']),
|
||||
lobby(['moritani', 'harkonnen', 'guild'], ['ecaz']),
|
||||
];
|
||||
for (const game of unsupported) assert.throws(() => initializeDiscoveryGameForAudit(game), RuleError);
|
||||
// The Advanced Moritani/Harkonnen restriction is not a new Basic restriction.
|
||||
const basic = initializeDiscoveryGameForAudit(lobby(['moritani', 'harkonnen', 'guild'], ['ecaz'], false));
|
||||
assert.equal(basic.moritaniAssassinatePreview, undefined);
|
||||
assert.equal(basic.discoveries?.tokens.length, 8);
|
||||
});
|
||||
|
||||
void test('Discovery Tech requires three seats and untouched physical tokens', () => {
|
||||
const two = lobby(['ixians', 'tleilaxu'], ['ix']); two.techTokens = createTechTokens();
|
||||
assert.throws(() => initializeDiscoveryGameForAudit(two), RuleError);
|
||||
const used = lobby(['choam', 'richese', 'guild'], ['choam']); used.techTokens = createTechTokens();
|
||||
used.techTokens.production.owner = 'choam';
|
||||
assert.throws(() => initializeDiscoveryGameForAudit(used), RuleError);
|
||||
const fresh = lobby(['ixians', 'tleilaxu', 'guild'], ['ix']); fresh.techTokens = createTechTokens();
|
||||
const initialized = initializeDiscoveryGameForAudit(fresh);
|
||||
assert.equal(initialized.techTokens?.heighliners.owner, 'ixians');
|
||||
assert.equal(initialized.techTokens?.axlotl.owner, 'tleilaxu');
|
||||
assert.equal(initialized.discoveryEnabled, true);
|
||||
});
|
||||
|
||||
void test('Discovery cannot redeal started components or silently remove another module', () => {
|
||||
const initial = lobby(['ixians', 'tleilaxu', 'guild'], ['ix']);
|
||||
const started = initializeDiscoveryGameForAudit(initial);
|
||||
assert.throws(() => initializeDiscoveryGameForAudit(started), RuleError);
|
||||
const overlays: Game[] = [structuredClone(initial), structuredClone(initial), structuredClone(initial)];
|
||||
overlays[0].homeworlds = { custody: null };
|
||||
overlays[1].nexusCards = { cards: null, phase: null };
|
||||
overlays[2].strongholdCards = createStrongholdCards();
|
||||
for (const game of overlays) assert.throws(() => initializeDiscoveryGameForAudit(game), RuleError);
|
||||
});
|
||||
Reference in new issue
Block a user