import assert from 'node:assert/strict'; import test from 'node:test'; import { kullDefaultEligible, kullDefaultProfile, type KullDefaultProfile } from '../game/kull-default-profile'; const lobby: KullDefaultProfile = { status: 'lobby', advanced: false, expansions: ['choam', 'ix'], players: [{ faction: 'choam' }, { faction: 'atreides' }, { faction: 'guild' }], nexusCards: { cards: null, phase: null }, }; void test('Basic CHOAM and classic Nexus lobby receives the same public Kull default quote', () => { assert.deepEqual(kullDefaultProfile(lobby), { eligible: true, reason: null }); assert.equal(kullDefaultEligible({ ...lobby, players: [{ faction: 'choam' }] }), true); assert.equal(kullDefaultEligible({ ...lobby, players: [{ faction: 'choam' }, { faction: 'ixians' }, { faction: 'tleilaxu' }] }), true); assert.equal(kullDefaultEligible({ ...lobby, players: [{ faction: 'choam' }, { faction: 'richese' }] }), true); // GameView carries Nexus selection as a public boolean instead of Game state. assert.equal(kullDefaultEligible({ ...lobby, nexusCards: undefined, lobbyModules: { nexusCards: true } }), true); // The host's explicit opt-out belongs to the caller, not the eligibility quote. const optedOut = { leaderSkills: false, kullOptOut: true }; assert.equal(kullDefaultEligible({ ...lobby, lobbyOptions: optedOut }), true); }); void test('Nexus Kull default retains its native roster and module boundaries', () => { const unsupported: Partial[] = [ { advanced: true }, { status: 'playing' }, { expansions: ['choam'] }, { expansions: ['choam', 'ix', 'ecaz'] }, { players: [{ faction: 'choam' }, { faction: 'atreides' }, { faction: 'atreides' }] }, { players: [{ faction: 'atreides' }, { faction: 'guild' }] }, { lobbyOptions: { leaderSkills: true } }, { lobbyOptions: { ecazTreachery: true } }, { lobbyModules: { nexusCards: true, ecazTreachery: true } }, { lobbyModules: { nexusCards: true, discoveries: true } }, { leaderSkills: {} }, { ecazTreachery: true }, { discoveryEnabled: true }, { discoveries: {} }, { discoveryStash: {} }, { greatMaker: {} }, { homeworlds: {} }, { techTokens: {} }, { strongholdCards: {} }, { sandtrout: {} }, ]; for (const variant of unsupported) { const result = kullDefaultProfile({ ...lobby, ...variant }); assert.equal(result.eligible, false, JSON.stringify(variant)); assert.ok(result.reason, 'Unavailable lobbies need a readable reason'); } }); void test('Nexus Kull eligibility depends on public roster and options, never hidden cards or spice', () => { const privateSeat = { faction: 'choam', get hand() { throw Error('private hand read'); }, get spice() { throw Error('private spice read'); } }; assert.equal(kullDefaultEligible({ ...lobby, players: [privateSeat, { faction: 'fremen' }] }), true); });