59 lines
3.4 KiB
TypeScript
59 lines
3.4 KiB
TypeScript
import { FACTIONS } from './catalog';
|
|
import type { FactionModuleProfile } from './faction-module-profile';
|
|
import { classicDiscoveryNexusProfile, pairedDiscoveryNexusProfile } from './discovery-module-profile';
|
|
|
|
/** Public classic configuration only; the initializer checks undealt physical components. */
|
|
export function classicNexusModulesProfile(game: FactionModuleProfile): boolean {
|
|
if (game.discoveryEnabled || game.discoveries) return classicDiscoveryNexusProfile(game);
|
|
if (typeof game.advanced !== 'boolean' || !game.nexusCards ||
|
|
(!game.techTokens && !game.strongholdCards) || game.expansions.length !== 0 ||
|
|
game.players.length < 2 || game.players.length > 6 ||
|
|
(game.techTokens && game.players.length < 3) ||
|
|
(game.strongholdCards && !game.advanced) || game.leaderSkills || game.homeworlds ||
|
|
game.discoveryEnabled || game.discoveries || game.discoveryStash || game.greatMaker ||
|
|
game.ecazTreachery || game.semutaPreview || game.advancedPreview ||
|
|
game.kullPreview || game.nexusKullPreview || game.guildBetrayalPreview ||
|
|
game.richeseBetrayalPreview || game.nexusIxianReplacementPreview ||
|
|
game.nexusIxianBetrayalPreview || game.nexusHarkonnenBetrayalPreview) return 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 classic = false;
|
|
for (const faction of FACTIONS)
|
|
if (faction.id === player.faction) { classic = faction.expansion === 'base'; break; }
|
|
if (!classic) return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/** Both original natives in one E1 or E2 family; mixed decks/families stay separate. */
|
|
export function pairedNexusModulesProfile(game: FactionModuleProfile): boolean {
|
|
if (game.discoveryEnabled || game.discoveries) return pairedDiscoveryNexusProfile(game);
|
|
if (typeof game.advanced !== 'boolean' || !game.nexusCards ||
|
|
(!game.techTokens && !game.strongholdCards) || game.expansions.length !== 1 ||
|
|
game.players.length < 2 || game.players.length > 6 ||
|
|
(game.techTokens && game.players.length < 3) ||
|
|
(game.strongholdCards && !game.advanced) || game.leaderSkills || game.homeworlds ||
|
|
game.discoveryEnabled || game.discoveries || game.discoveryStash || game.greatMaker ||
|
|
game.ecazTreachery || game.semutaPreview || game.advancedPreview ||
|
|
game.kullPreview || game.nexusKullPreview || game.guildBetrayalPreview ||
|
|
game.richeseBetrayalPreview || game.nexusIxianReplacementPreview ||
|
|
game.nexusIxianBetrayalPreview || game.nexusHarkonnenBetrayalPreview) return false;
|
|
const expansion = game.expansions[0];
|
|
if (expansion !== 'ix' && expansion !== 'choam') return false;
|
|
const primary = expansion === 'ix' ? 'ixians' : 'choam';
|
|
const secondary = expansion === 'ix' ? 'tleilaxu' : 'richese';
|
|
let hasPrimary = false, hasSecondary = 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 family: string | undefined;
|
|
for (const faction of FACTIONS)
|
|
if (faction.id === player.faction) { family = faction.expansion; break; }
|
|
if (family !== 'base' && family !== expansion) return false;
|
|
if (player.faction === primary) hasPrimary = true;
|
|
if (player.faction === secondary) hasSecondary = true;
|
|
}
|
|
return hasPrimary && hasSecondary;
|
|
}
|