v0.1.0: 仙途家族志 · Chronicle of the Immortal Clan

家族模拟器首版:修仙/经营/战斗/外交/叙事全套系统
- Electron + React + TS + MetonaSqlark(aria+OPFS)
- 水墨中国风 UI
- 引擎种子随机、确定性可回放
- 19 项单元测试、端到端冒烟验证
This commit is contained in:
2026-08-23 00:04:16 +08:00
commit adb22f0558
69 changed files with 14305 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
import { World } from './world'
import { ITEMS } from '../data/items'
export function marketPrice(w: World, itemId: string): number {
const base = ITEMS[itemId]?.basePrice ?? 1
const fam = w.state.family
const mult = typeof fam.flag['priceMult'] === 'number' ? (fam.flag['priceMult'] as number) : 1
const mood = fam.reputation >= 40 ? 1.06 : fam.reputation >= 20 ? 1.02 : 0.98
return Math.max(1, Math.round(base * mult * mood))
}
export function buyItem(w: World, itemId: string, count: number): boolean {
const fam = w.state.family
const total = marketPrice(w, itemId) * count
if (total > fam.stones) return false
fam.stones -= total
fam.inventory[itemId] = (fam.inventory[itemId] ?? 0) + count
return true
}
export function sellItem(w: World, itemId: string, count: number): boolean {
const fam = w.state.family
const have = fam.inventory[itemId] ?? 0
if (have < count) return false
fam.inventory[itemId] = have - count
fam.stones += marketPrice(w, itemId) * count
return true
}
export function buyTechnique(w: World, techId: string, price: number): boolean {
const fam = w.state.family
if (fam.techniques.includes(techId)) return false
if (fam.stones < price) return false
fam.stones -= price
fam.techniques.push(techId)
return true
}
export function techniquePrice(techId: string): number {
const grade = TECH_GRADE_BASE[techId] ?? 200
return grade
}
import { TECHNIQUES } from '../data/techniques'
const TECH_GRADE_BASE: Record<string, number> = Object.fromEntries(
TECHNIQUES.map((t) => [t.id, [120, 300, 700, 1600, 3600][t.grade] ?? 300])
)