// Bond strip (active-bond discs under the top bar) and the bond detail popup: the key facts first (user playtest #2 // item 9: name, members in play / next threshold, layers, reached tier and its threshold row, the current effect with // layer-resolved numbers), then the full description and the member list with owned / on-board state. Opened from // the detail panel's bond chips it docks beside that panel (`beside`: the panel's side). // Research 06 §11.1: round mint discs, stack count over the disc, name below, sorted by stacks; grey = // present but inactive; in 联防 / boss rounds the strip is dimmed ("层数叠加已禁用"). // Watching a teammate (DESIGN §20.15, ui/watchBonds.js) the strip and the popup show THAT player's bonds and layers: // the strip carries an amber "👁 name" tag (`owner`, the observing pill's spelling, research 09 §3.1) and amber rings, // the popup a "👁 name 的盟约" line; its member list reads the teammate's operators on the field (no hand: never sent). import { html, BondDisc, Icon, MicroLabel, Tooltip } from './components.js'; import { RichText, UnitThumb, BondGlyph, GIcon } from './gameComponents.js'; import { sortBonds, bondMembers, nextThreshold, bondTier } from './gameLogic.js'; import { formatBondEffect } from './richText.js'; import { bondIconUrl } from './assetUrls.js'; import { data } from '../data.js'; const cx = (...p) => p.flat().filter(Boolean).join(' '); /** The "👁 name" tag of a teammate's strip (DESIGN §20.15). */ function OwnerTag({ owner }) { return html` <${GIcon} name="eye" class="bstrip__eye" /><${MicroLabel}>${owner} `; } /** * @param {{ bonds: any[], layersDisabled?: boolean, onOpen:(bondId:string)=>void, openId?: string|null, max?: number, * owner?: string|null }} props — owner: the watched teammate's name (null = your own bonds) */ export function BondStrip({ bonds, layersDisabled = false, onOpen, openId = null, max = 14, owner = null }) { const sorted = sortBonds(bonds, (id) => data.lookup('bonds', id)); if (!sorted.length) { return html`
${owner ? html`<${OwnerTag} owner=${owner} />` : html`<${MicroLabel}>BONDS`}${owner ? `${owner} 尚未激活盟约` : '部署干员以激活盟约'}
`; } const m = data.get('assets'); const shown = sorted.slice(0, max); const strip = html`
${owner ? html`<${OwnerTag} owner=${owner} />` : null} ${shown.map((b) => { const rec = data.lookup('bonds', b.bondId); const th = Array.isArray(b.thresholds) && b.thresholds.length ? b.thresholds : rec?.thresholds || []; const next = nextThreshold(b.count ?? 0, th); return html`
<${BondDisc} name=${rec?.name || b.bondId} icon=${bondIconUrl(m, b.bondId)} layers=${b.layers ?? 0} tier=${b.tier ?? 0} maxTier=${Math.max(1, th.length)} active=${!!b.active} size="sm" showName=${true} layersDisabled=${layersDisabled} onClick=${() => onOpen(b.bondId)} title=${`${rec?.name || b.bondId} ${b.count ?? 0}/${next ?? th[th.length - 1] ?? '-'}`} /> ${b.count ?? 0}/${next ?? th[th.length - 1] ?? '-'}
`; })} ${sorted.length > shown.length ? html`+${sorted.length - shown.length}` : null}
`; return layersDisabled ? html`<${Tooltip} text="层数叠加已禁用" placement="bottom">${strip}` : strip; } /** * Bond detail popup. * @param {{ bondId: string, entry?: any, priv?: any, banned?: string[], onClose: Function, onMember?: (chessId:string)=>void, * place?: 'left'|'beside'|'besideR'|'right'|null, over?: boolean, beside?: 'left'|'right'|null, owner?: string|null }} props — * `place`: where it opens (gameLogic bondPopupPlace; `beside: 'left'` = the older spelling of 'beside'); `over`: above the * detail card; `owner`: the watched teammate's name (`entry` / `priv` are then theirs: ui/watchBonds.js) */ export function BondPopup({ bondId, entry, priv, banned = [], onClose, onMember, place = null, over = false, beside = null, owner = null }) { const b = data.lookup('bonds', bondId); if (!b) return null; const count = entry?.count ?? 0; const layers = entry?.layers ?? 0; const th = Array.isArray(entry?.thresholds) && entry.thresholds.length ? entry.thresholds : b.thresholds || []; const tier = entry?.tier ?? bondTier(count, th, b.maxCount); const active = entry ? !!entry.active : tier > 0; const members = bondMembers(b, priv, banned, (id) => data.lookup('chess', id)); const countsHand = entry?.countsHand ?? b.countsHand; const next = nextThreshold(count, th); const hasNow = !!(b.effectDescRaw || b.effectDesc); const at = place || (beside === 'left' ? 'beside' : 'left'); return html``; }