Retain independent36, original Homeworlds and Nexus12 through classic fresh setup with optional Skills and phase modules. Resolve own-World Reinforcements fees before computing temporary Sardaukar roles, preserving original Cunning declarations, printed traits and physical counters. Record the provisional ordinary-nonrole-first policy and align human/AI quotes and captions. Validation: types/lint/build, 128 affected tests across 15 files, bounded rule-source review and finite original-action smoke for Recruits, Harass, local-fee Cunning, all four legal policies and rendered source controls. Verified runtime c219ec587a54b44079539168d93835a5af904c8afb4de58bcec0a3d60c809f0c; documentation-only proof update 8ee21598e7be0c89a08fbad50786c346ebc8ae705492d8b31ea00fae0ffefa3c. Full modes, combinations, assurance and deployed acceptance remain open. No saved-room/provider changes.
134 lines
6.1 KiB
TypeScript
134 lines
6.1 KiB
TypeScript
import { FACTIONS } from './catalog';
|
|
|
|
/** Public lobby configuration only; physical freshness is checked by the initializer. */
|
|
export type FactionModuleProfile = {
|
|
advanced: boolean;
|
|
expansions: readonly string[];
|
|
players: readonly { faction: string }[];
|
|
techTokens?: unknown;
|
|
strongholdCards?: unknown;
|
|
leaderSkills?: unknown;
|
|
homeworlds?: unknown;
|
|
nexusCards?: unknown;
|
|
discoveryEnabled?: unknown;
|
|
discoveries?: unknown;
|
|
discoveryStash?: unknown;
|
|
greatMaker?: unknown;
|
|
ecazTreachery?: unknown;
|
|
semutaPreview?: unknown;
|
|
advancedPreview?: unknown;
|
|
kullPreview?: unknown;
|
|
nexusKullPreview?: unknown;
|
|
guildBetrayalPreview?: unknown;
|
|
richeseBetrayalPreview?: unknown;
|
|
nexusIxianReplacementPreview?: unknown;
|
|
nexusIxianBetrayalPreview?: unknown;
|
|
nexusHarkonnenBetrayalPreview?: unknown;
|
|
};
|
|
|
|
type ClassicNexusProfile = Partial<FactionModuleProfile> & Pick<FactionModuleProfile, 'expansions'> & {
|
|
sandtrout?: unknown; moritaniAssassinatePreview?: unknown;
|
|
};
|
|
|
|
/** Classic Nexus12 with selected base33/independent36, optional all14, original
|
|
* Homeworlds and phase modules. Native effect stamps are not selected overlays. */
|
|
export function classicNexusCoreProfile(game: ClassicNexusProfile): boolean {
|
|
const players = game.players;
|
|
if (typeof game.advanced !== 'boolean' || !game.nexusCards ||
|
|
game.expansions.length !== 0 || !players || players.length < (game.techTokens ? 3 : 2) || players.length > 6 ||
|
|
(game.strongholdCards && !game.advanced) || game.sandtrout ||
|
|
game.discoveryEnabled || game.discoveries || game.discoveryStash || game.greatMaker ||
|
|
game.semutaPreview || game.moritaniAssassinatePreview || game.advancedPreview || game.kullPreview || game.nexusKullPreview ||
|
|
game.richeseBetrayalPreview ||
|
|
game.nexusIxianBetrayalPreview) return false;
|
|
for (let i = 0; i < players.length; i++) {
|
|
for (let j = 0; j < i; j++) if (players[j].faction === players[i].faction) return false;
|
|
let classic = false;
|
|
for (const faction of FACTIONS)
|
|
if (faction.id === players[i].faction) { classic = faction.expansion === 'base'; break; }
|
|
if (!classic) return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/** Card consumers require the actual independent-variant selection. */
|
|
export function classicIndependentNexusProfile(game: ClassicNexusProfile): boolean {
|
|
return game.ecazTreachery === true && classicNexusCoreProfile(game);
|
|
}
|
|
|
|
/** Original E1/E2 families or standalone Ecaz/Moritani; explicit Semuta context only. */
|
|
export function nativeFactionTechProfile(game: FactionModuleProfile, semuta = false): boolean {
|
|
if (typeof game.advanced !== 'boolean' || !game.techTokens ||
|
|
game.players.length < 3 || game.players.length > 6 ||
|
|
game.expansions.length < 1 || game.expansions.length > 2 ||
|
|
(game.strongholdCards && !game.advanced) || game.leaderSkills ||
|
|
game.homeworlds || game.nexusCards || game.discoveryEnabled || game.discoveries ||
|
|
game.discoveryStash || game.greatMaker || game.ecazTreachery ||
|
|
(game.semutaPreview && (!semuta || game.semutaPreview !== true)) ||
|
|
game.advancedPreview || game.kullPreview || game.nexusKullPreview ||
|
|
game.guildBetrayalPreview || game.richeseBetrayalPreview ||
|
|
game.nexusIxianReplacementPreview || game.nexusIxianBetrayalPreview ||
|
|
game.nexusHarkonnenBetrayalPreview) return false;
|
|
const e3 = game.expansions.length === 1 && game.expansions[0] === 'ecaz';
|
|
if (!e3) {
|
|
for (let i = 0; i < game.expansions.length; i++) {
|
|
if (game.expansions[i] !== 'ix' && game.expansions[i] !== 'choam') return false;
|
|
for (let j = 0; j < i; j++) if (game.expansions[i] === game.expansions[j]) return false;
|
|
}
|
|
}
|
|
let native = 0;
|
|
let moritani = false;
|
|
let harkonnen = false;
|
|
for (let i = 0; i < game.players.length; i++) {
|
|
const player = game.players[i];
|
|
for (let j = 0; j < i; j++) if (player.faction === game.players[j].faction) return false;
|
|
let expansion: string | undefined;
|
|
for (const faction of FACTIONS)
|
|
if (faction.id === player.faction) { expansion = faction.expansion; break; }
|
|
if (expansion === undefined) return false;
|
|
if (expansion !== 'base') {
|
|
if (e3 ? player.faction !== 'ecaz' && player.faction !== 'moritani'
|
|
: !game.expansions.includes(expansion)) return false;
|
|
native++;
|
|
}
|
|
if (player.faction === 'moritani') moritani = true;
|
|
if (player.faction === 'harkonnen') harkonnen = true;
|
|
}
|
|
return native > 0 && (!e3 || native === 1) &&
|
|
!(game.advanced && moritani && harkonnen);
|
|
}
|
|
|
|
export type MixedE3NativeRoster = {
|
|
advanced?: boolean;
|
|
expansions: readonly string[];
|
|
players?: readonly { faction: string }[];
|
|
};
|
|
|
|
/** Selected E3 plus E1 and/or E2, with an actual native from every selected family. */
|
|
export function mixedE3NexusRosterProfile(game: MixedE3NativeRoster, skills = false): boolean {
|
|
const players = game.players;
|
|
if (typeof game.advanced !== 'boolean' || !players || players.length < 2 || players.length > 6 ||
|
|
game.expansions.length < 2 || game.expansions.length > 3 || !game.expansions.includes('ecaz'))
|
|
return false;
|
|
for (let i = 0; i < game.expansions.length; i++) {
|
|
const expansion = game.expansions[i];
|
|
if (expansion !== 'ecaz' && expansion !== 'ix' && expansion !== 'choam') return false;
|
|
for (let j = 0; j < i; j++) if (expansion === game.expansions[j]) return false;
|
|
}
|
|
let ix = false, choam = false, e3 = false, harkonnen = false;
|
|
for (let i = 0; i < players.length; i++) {
|
|
const player = players[i];
|
|
for (let j = 0; j < i; j++) if (player.faction === players[j].faction) return false;
|
|
let family: string | undefined;
|
|
for (const faction of FACTIONS)
|
|
if (faction.id === player.faction) { family = faction.expansion; break; }
|
|
if (family === undefined || (family !== 'base' && !game.expansions.includes(family))) return false;
|
|
if (family === 'ix') ix = true;
|
|
if (family === 'choam') choam = true;
|
|
if (family === 'ecaz') e3 = true;
|
|
if (player.faction === 'harkonnen') harkonnen = true;
|
|
}
|
|
return e3 && ix === game.expansions.includes('ix') && choam === game.expansions.includes('choam') &&
|
|
!(game.advanced && harkonnen && skills);
|
|
}
|