// Briefing — INFO_CHECK "1/2 确认本局信息" (research 06 §4.1, D1): enemy leader (silhouette, name,
// abilities), stage (+ its pool: 战场固定 / 战场随机(共N张)), 特训敌人 factions (icon, name, description), the difficulty
// tag, the ready count x/N with person pips, the 准备就绪 button (g.infoReady) and the countdown. The right column — 核心盟约
// / 附加盟约 rows of bond discs (disabled bonds greyed with the banned-member badge), the legend and the 本局禁用干员
// avatars, with the player's own 自选 pieces out of the shop (m.private.diyBanned) — is ui/matchInfo.js MatchInfo, the same
// blocks the strategy draft's 本局信息 dialog shows (screens/bandDraft.js).
import { useState } from '../../vendor/hooks.module.js';
import { html, Button, Icon, MicroLabel } from '../ui/components.js';
import { useGameData, Img, RichText } from '../ui/gameComponents.js';
import { StepHeader, ExitModal } from '../ui/matchChrome.js';
import { MatchInfo, matchInfoModel } from '../ui/matchInfo.js';
import { LoadoutButton } from './loadout.js';
import { SetupReroll } from '../ui/setupReroll.js';
import { actions } from '../ui/gameActions.js';
import { factionTypes, sortedPlayers, phaseTotalSeconds } from '../ui/gameLogic.js';
import { enemyIconUrl, factionIconUrl } from '../ui/assetUrls.js';
import { useStore } from '../store.js';
import { data } from '../data.js';
import { t, tParts } from '../../../shared/i18n.js';
const cx = (...p) => p.flat().filter(Boolean).join(' ');
/** INFO_CHECK screen. */
export function BriefingScreen() {
const pub = useStore((s) => s.match.public);
const priv = useStore((s) => s.match.private);
const myId = useStore((s) => s.me.playerId);
const solo = useStore((s) => s.room?.mode === 'solo') || String(pub?.modeId || '').includes('single');
const gd = useGameData();
const [exit, setExit] = useState(false);
const [busy, setBusy] = useState(false);
if (!pub) return null;
const players = sortedPlayers(pub);
const me = players.find((p) => p.playerId === myId);
const readyN = players.filter((p) => p.ready).length;
const mode = gd.config?.modes?.[pub.modeId];
// (+ the own 自选 pieces this match leaves out of the shop: m.private.diyBanned)
const info = matchInfoModel(pub, { bonds: gd.list('bonds'), chess: gd.chess, mode, priv, diyData: { chess: data.get('chess'), backups: data.get('backups') } });
const boss = pub.bossId ? gd.boss(pub.bossId) : null;
const bossEnemy = boss ? gd.enemy(boss.enemyKey) : null;
const stage = pub.stageId ? gd.stage(pub.stageId) : null;
// the mode's battlefield pool (config.json modes[].stages): 标准 is always 战场#01, 险境+ draw one at random
const poolN = Array.isArray(mode?.stages) ? mode.stages.length : 0;
const pool = poolN > 1 ? t('战场随机(共{poolN}张)', { poolN }) : poolN === 1 ? t('战场固定') : '';
const types = factionTypes(pub.factions);
const factions = gd.factions?.types || {};
const m = gd.m;
const ready = async () => {
if (busy || me?.ready) return;
setBusy(true);
await actions.infoReady(pub.setupRevision ?? 0);
setBusy(false);
};
return html`
<${StepHeader} step=${1} of=${2} title=${t('确认本局信息')} micro="BRIEFING // INFO CHECK" pub=${pub}
total=${phaseTotalSeconds(pub, gd.config)} onExit=${() => setExit(true)} />
<${MicroLabel} tone="gold">${t('ENEMY LEADER // 敌方领袖')}${MicroLabel}>
${bossEnemy ? html`<${Img} src=${enemyIconUrl(m, boss.enemyKey)} class="brief-boss__sil" fallback=${html`
?`} />`
: html`
?`}
${boss?.name || bossEnemy?.name || t('未知领袖')}
${tParts('第 {r} 回合 · 最终攻势', { r: html`${mode?.bossRound ?? pub.lastRound ?? 14}` })}
${Array.isArray(boss?.abilities) && boss.abilities.length ? html`
${boss.abilities.slice(0, 3).map((a, i) => html`- <${RichText} text=${a} />
`)}
` : null}
<${MicroLabel}>BATTLEFIELD${MicroLabel}>${pool ? html`${pool}` : null}
<${Icon} name="rook" />${stage?.name || pub.stageId || '—'}
${t('特训敌人')}<${MicroLabel}>SPECIAL ENEMIES${MicroLabel}>
${types.length ? types.map((t) => html`
<${Img} src=${factionIconUrl(m, factions[t]?.icon)} />
${factions[t]?.name || t}${factions[t]?.desc || ''}
`) : html`
${t('本局没有特训敌人')}
`}
<${MatchInfo} model=${info} />
<${SetupReroll} pub=${pub} />
<${ExitModal} open=${exit} onClose=${() => setExit(false)} solo=${solo} />
`;
}