import { faction } from '@/game/catalog'; import { territory } from '@/game/board'; import type { StrongholdProgress } from '@/game/victory-progress'; import type { FremenVictoryProgress } from '@/game/fremen-victory'; import type { GameView } from '@/game/engine'; import { homeworldCard } from '@/game/homeworld-cards'; export function VictoryProgress({ progress, players, fremen, ecazHomeworld, }: { progress: readonly StrongholdProgress[]; players: readonly { id: string; faction: string }[]; fremen?: FremenVictoryProgress | null; ecazHomeworld?: GameView['ecazHomeworldVictory']; }) { if (!progress.length && !fremen && !ecazHomeworld) return null; const rows = progress.filter((row) => row.player === row.members[0]); const playerFactionName = (id: string) => { const player = players.find((candidate) => candidate.id === id); return player ? faction(player.faction).name : id; }; return (
Victory progress

Stronghold victory progress

Current board, evaluated at the Mentat victory check. Battles and other effects may change these holdings. A correct Bene Gesserit prediction can replace a stronghold victory.

{ecazHomeworld && (

Ecaz High Homeworld victory

{ecazHomeworld.members.map(playerFactionName).join(' & ')}

{playerFactionName(ecazHomeworld.owner)} native population:{' '} {ecazHomeworld.population} / {ecazHomeworld.minimum} for High {' · '}{ecazHomeworld.high ? 'High' : 'Low'}

Source: printed Ecaz High Homeworld card. High requires at least{' '} {ecazHomeworld.minimum} native forces on Ecaz. The alliance must jointly occupy at least one actual stronghold and occupy the Homeworlds of two other native factions.

Joint strongholds: {ecazHomeworld.jointStrongholds.length} / 1 required

{ecazHomeworld.jointStrongholds.length ? ecazHomeworld.jointStrongholds.map((id) => territory(id).name).join(', ') : 'No jointly occupied stronghold.'}

Other native factions:{' '} {ecazHomeworld.distinctNativeFactions.length} / 2 required

{ecazHomeworld.distinctNativeFactions.length ? ecazHomeworld.distinctNativeFactions.map((id) => faction(id).name).join(', ') : 'No other native faction’s Homeworld occupied.'}

{ecazHomeworld.foreignHomeworlds.length > 0 && ( )}

Two physical Emperor Homeworlds count as one other native faction. Homeworlds add no ordinary stronghold points; a Tech Token set is not a joint stronghold.

{ecazHomeworld.blocked && ( Source blocked: {ecazHomeworld.blocked} )}

{ecazHomeworld.blocked ? 'This source cannot resolve the Ecaz Homeworld victory check.' : ecazHomeworld.qualifies ? 'Ecaz Homeworld conditions are met on this board.' : 'Ecaz Homeworld conditions are not met on this board.'} {' '}Prospective progress only: victory is evaluated at the Mentat victory check, not awarded here.

)} {fremen && (

Fremen final-turn victory

At the end of the final turn, if nobody has a stronghold victory, these conditions let Fremen and its ally win before Guild. A Bene Gesserit prediction cannot replace this special victory. An agreed extra turn provisionally moves this check to the new final turn.

{fremen.qualifies ? 'Fremen’s special conditions are met on this board. They award victory only at the final-turn check.' : 'Fremen’s special conditions are not met on this board.'}

)}
); }