import { GameState } from '../types/domain' import { TECHNIQUES } from '../data/techniques' import { describeRealm } from '../data/realms' import { aspirationById } from '../data/aspirations' import { postById } from '../data/posts' export interface BioLine { at?: number label: string text: string } export function buildBiography(s: GameState, memberId: string): BioLine[] { const c = s.members[memberId] if (!c) return [] const lines: BioLine[] = [] const tech = TECHNIQUES.find((t) => t.id === c.techniqueId) const asp = aspirationById(c.aspiration) const post = postById(c.post) lines.push({ label: '生平', text: `${c.name},第${c.generation}代子孙${c.gender === 'male' ? '男' : '女'},生于${c.bornYear}年${ c.deathYear ? `,殁于${c.deathYear}年(${c.deathCause ?? '寿终'})` : ',今尚在世' }。${post ? `曾居族中「${post.name}」之位。` : ''}${asp ? `平生志向:${asp.name}。` : ''}${ tech ? `主修《${tech.name}》。` : '' }` }) // 突破脉络 const breaks = s.chronicle.filter((e) => e.category === 'breakthrough' && e.memberId === c.id) const trials = s.chronicle.filter((e) => e.text.includes(c.name) && (e.category === 'battle' || e.category === 'exploration')) for (const e of breaks) { lines.push({ at: e.year, label: '修行', text: `${e.year}年${e.month}月,${e.text.replace(new RegExp(`^${c.name}\\s*`), '')}`}) } if (trials.length > 0) { lines.push({ at: trials[0].year, label: '历险', text: `${trials[0].year}年·${trials[0].text}` }) } // 婚育 const marriages = s.chronicle.filter((e) => e.category === 'marriage' && e.memberId === c.id) for (const m of marriages) { lines.push({ at: m.year, label: '姻缘', text: m.text }) } if (c.children.length > 0) { const kids = c.children.map((id) => s.members[id]?.name ?? '?').join('、') lines.push({ label: '子嗣', text: `抚育子女${c.children.length}人:${kids}。` }) } // 大比 const hisTourneys = s.stats.tourneyHistory.filter((t) => { const battle = s.battles.find((b) => b.year === t.year && b.title.includes('大比')) return battle?.lines.some((l) => l.includes(c.name)) }) for (const t of hisTourneys) { lines.push({ at: t.year, label: '大比', text: `${t.year}年,随队参加太虚大比,列第${t.rank}名。` }) } // 墓碑铭文 if (!c.alive) { const epitaph = EPITAPH[c.deathCause ?? '寿终'] ?? '一尘一土,终归青山。' lines.push({ label: '墓志', text: `${c.name}之墓。${epitaph}` }) } return lines } const EPITAPH: Record = { 寿终: '一尘一土,终归青山。子孙焚香,岁岁在此。', '寿元将尽': '一尘一土,终归青山。子孙焚香,岁岁在此。', 幼夭: '稚子长眠,天地垂爱。家人悬灯,常照归路。', '伤势不治': '壮士折戟,魂兮归来。家祠之下,与祖同列。', '突破走火': '一念求道,九死未悔。灵前法灯,为君长明。', '渡劫陨落': '雷霆战天,其志未竟。遗骨归山,英风尚在。', '战殁': '马革裹尸,归葬桑梓。长剑挂壁,子孙相传。', '云游飞升': '此去云深不知处,魂同列宿游太虚。' }