import { useGameStore } from '../store' import { ITEMS } from '../../game/data/items' import { TECHNIQUES } from '../../game/data/techniques' import { TECHNIQUE_GRADE_NAMES } from '../../game/data/realms' import { marketPrice, buyItem, sellItem, buyTechnique } from '../../game/engine/market' import { useMemo, useState } from 'react' export default function MarketPanel() { const world = useGameStore((s) => s.world) const bump = useGameStore((s) => s.bump) const revision = useGameStore((s) => s.revision) void revision if (!world) return null const w = world const fam = w.state.family const inv = fam.inventory const [tab, setTab] = useState<'goods' | 'tech'>('goods') const goods = useMemo(() => Object.values(ITEMS).filter((i) => i.kind === 'resource' || i.kind === 'pill'), []) const artifacts = useMemo(() => Object.values(ITEMS).filter((i) => i.kind === 'artifact'), []) const marketTech = TECHNIQUES.filter((t) => t.grade <= 3) const cangshuLv = fam.buildings['cangshu'] ?? 0 const price = (id: string) => marketPrice(w, id) return (
setTab('goods')}>货栈
setTab('tech')}>法帖
{tab === 'goods' && ( <>
集市物价随季节波动(当前行情 {Math.round(((fam.flag['priceMult'] as number) ?? 1) * 100)}%)。 仓库寄存的灵草、灵矿、兽核均可在此出手。
{[...goods, ...artifacts].map((item) => { const have = item.id === 'lingcao' || item.id === 'lingkuang' || item.id === 'beastcore' || item.kind === 'pill' || item.kind === 'artifact' ? inv[item.id] ?? 0 : 0 const stock = item.kind === 'artifact' ? 3 : item.kind === 'pill' ? 5 : 9999 const count = item.kind === 'artifact' ? 1 : 5 return ( ) })}
品名 说明 行价 库存/持有 买卖
{item.icon} {item.name} {item.desc} {price(item.id)} 灵石 {have} {' '} {((item.kind === 'resource' || item.kind === 'pill') && have >= count) && ( )} {item.kind === 'artifact' && have > 0 && ( 已购藏 )}
丹房炼制 灵草+辅矿 → 丹药(丹房等级越高成数越足) {fam.buildings['danfang'] ? `${fam.buildings['danfang']}级丹房` : '未建丹房'} 灵草{inv['lingcao'] ?? 0} {fam.buildings['danfang'] && ( <> {' '} )}
)} {tab === 'tech' && ( <>
藏书阁录存法帖,族人可修习。藏书阁等级决定可在坊市搜购的品阶(当前 {cangshuLv} 级,可购至{TECHNIQUE_GRADE_NAMES[Math.min(3, Math.max(0, cangshuLv))]})。 若藏书阁未建或等级不足,只可见基础法帖。
{marketTech .filter((t) => t.grade <= 1 + cangshuLv) .filter((t) => t.grade <= 3) .map((t) => { const owned = fam.techniques.includes(t.id) const p = t.grade <= 1 + cangshuLv const priceT = [120, 300, 700, 1600, 3600][t.grade] ?? 300 return ( ) })}
法帖 品阶/路子 妙用 修为加成 战力加成
《{t.name}》 {TECHNIQUE_GRADE_NAMES[t.grade]} · {t.path} {t.desc} +{Math.round((t.expBonus) * 100)}% +{Math.round((t.powerBonus) * 100)}% {owned ? ( 已录 ) : ( )}
)}
灵矿不足时可上坊市民间收购;妖丹于探秘与灵兽园中可得。
) }