import { useGameStore } from '../store' import { BUILDINGS, buildingById, listBuildingDefs, SPECIALTY_MULT, bonusOf, isSpecialty } from '../../game/data/buildings' import { useMemo } from 'react' export default function TerritoryPanel() { const world = useGameStore((s) => s.world) const bump = useGameStore((s) => s.bump) const revision = useGameStore((s) => s.revision) void revision const ids = useMemo(() => listBuildingDefs().map((d) => d.id), []) if (!world) return null const fam = world.state.family const levelLabel = (l: number) => '·'.repeat(l) + '。'.repeat(5 - l) return (
族产经营:建造建筑后每月自动产出;坊市、丹房等基础设施可解锁功能。 灵石与灵矿不足则无法建造或升级。
{ids.map((id) => { const def = buildingById(id) if (!def) return null const level = fam.buildings[id] ?? 0 const built = level > 0 const cost = built && level >= def.maxLevel ? null : def.upgradeCost(built ? level + 1 : 1) const produce = def.produceTable ? def.produceTable(built ? level : 1) : null const canUpgrade = !!cost && fam.stones >= cost.stones && fam.inventory['lingkuang'] >= cost.lingkuang const isSpecialtyBuilding = fam.flag['buildingSpecialty'] === id return (
{def.icon}
{def.name}{isSpecialtyBuilding && 【专精】}
{def.kind === 'produce' ? '产出' : '功效'}
{built ? `${level}级` : ''}
{def.desc}
{/* 0.1.41 建筑专精加成预览 */} {built && def.extra && Object.keys(def.extra).length > 0 && (() => { const specialtyId = fam.flag['buildingSpecialty'] as string | undefined const currentLevel = level const isThisSpecialty = isSpecialty(id, specialtyId) const bonusLabels: { name: string; base: number; specialty: number }[] = [] for (const [key, expr] of Object.entries(def.extra)) { void expr const base = bonusOf(id, key, currentLevel, undefined) const spec = bonusOf(id, key, currentLevel, id) bonusLabels.push({ name: extraLabel(key), base, specialty: spec }) } return (
{bonusLabels.map((b, i) => ( {b.name}: {b.base.toFixed(2)} {isThisSpecialty && →x{SPECIALTY_MULT} = {(b.base * SPECIALTY_MULT).toFixed(2)}} {!isThisSpecialty && specialtyId && (设为专精可至 {(b.base * SPECIALTY_MULT).toFixed(2)})} ))}
) })()} {produce && Object.keys(produce).length > 0 && (
{Object.entries(produce) .filter(([k]) => k !== 'beastcore' || (built && level >= 3)) .map(([k, v]) => `${itemLabel(k)} ×${v}`) .join(' / ')} /月
)}
{built ? ( <> {level < def.maxLevel ? ( ) : ( 已臻极致 )} {id === 'cangshu' && ( )} {id === 'zongci' && ( )} {built && def.extra && Object.keys(def.extra).length > 0 && ( )} {levelLabel(level)} ) : ( )}
) })}
) } function MonumentList() { const world = useGameStore((s) => s.world) const revision = useGameStore((s) => s.revision) void revision if (!world) return null const monuments = world.state.chronicle.filter((e) => e.text.startsWith('功德碑')).slice().reverse() if (monuments.length === 0) return null return (
宗祠碑录
{monuments.slice(0, 4).map((m) => (
{m.year}年 {m.text.slice(3)}
))}
) } function itemLabel(k: string): string { const map: Record = { stone: '灵石', lingcao: '灵草', lingkuang: '灵矿', beastcore: '兽核' } return map[k] ?? k } /** 0.1.41 建筑加成属性中文名 */ function extraLabel(key: string): string { const map: Record = { craftChance: '成丹率', unlockGrade: '解锁品阶', expBonus: '修炼加成', powerBonus: '战力加成', repBonus: '声望' } return map[key] ?? key }