【A 经济闭环】 - 修为经济化:练气以上修行者月耗灵草(闭关2普通1),无草速修0.6~1.0衰减+缺草年告警 - 炼丹等级化:bonusOf 表达式引擎(白名单安全求值),craftChance 转正;丹方单源 PILL_RECIPES(聚气L1/凝元L2/破境L3)+ 失败折半退料 - 炼器筑宝:FORGE_RECIPES(法器/灵器/法宝,灵矿+兽核+灵石) - 秘境灵脉:secretQiOf→rollWarbooty 收益门槛(0.5~1.3折算);掉落按秘境 techGrades 过滤 - NPC 实力参战:raid 强度/风险随 npc.power 浮动(0.5~1.8) - 灾年落效:疫病/兽潮一次性袭击 + CALAMITY_FAMILY 月度减产乘子 【C 治理】 - C13 破境丹渡劫修正:大境界时药力→tribBoost 加成(+12%)入渡劫事件,不再跳过三选 - C14 存储防线:loadState 补 migrate;MigrationError(TOO_NEW/未知版本)提示升级 【UI 半批】 - 坊市新增 定制tab(丹方/铸器);ChroniclePanel 手写史书输入条;MemberModal 册立家主钮 - 年报摘要(要闻5条+辞世讣告);EventModal 选项收益预览 - 结盟引擎:setAlliance(relation≥40)/盟友岁差不降/年利15灵石
114 lines
5.0 KiB
TypeScript
114 lines
5.0 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { World } from '../src/renderer/game/engine/runtime/World'
|
|
import { marketPrice, buyItem, sellItem, buyTechnique, techniquePrice } from '../src/renderer/game/engine/sim/Market'
|
|
import { ITEMS } from '../src/renderer/game/data/items'
|
|
|
|
describe('economy 经济系统', () => {
|
|
it('灵田月产随等级线性增长', () => {
|
|
const w = World.create({ seed: 'eco-a', surname: '简', familyName: '简家', motto: 'm', difficulty: 'normal' })
|
|
w.state.family.buildings = { lingtian: 1 }
|
|
for (const c of Object.values(w.state.members)) c.realm = { major: 'mortal', minor: 0 }
|
|
const c0 = w.state.family.inventory['lingcao'] ?? 0
|
|
w.advanceMonth() // month 2 = 春季,田地有±季相但至少≥9
|
|
const c1 = w.state.family.inventory['lingcao'] ?? 0
|
|
expect(c1 - c0).toBeGreaterThanOrEqual(9)
|
|
})
|
|
|
|
it('坊市月产受执事加成', () => {
|
|
const w = World.create({ seed: 'eco-b', surname: '骆', familyName: '骆家', motto: 'm', difficulty: 'normal' })
|
|
w.state.family.buildings = { fangshi: 2 }
|
|
w.assignPost('x3', 'steward')
|
|
const s0 = w.state.family.stones
|
|
w.advanceMonth()
|
|
const gained = w.state.family.stones - s0
|
|
expect(gained).toBe(110 + 11) // 55*2*1.1
|
|
})
|
|
|
|
it('药园高级产出兽核', () => {
|
|
const w = World.create({ seed: 'eco-c', surname: '龙', familyName: '龙家', motto: 'm', difficulty: 'normal' })
|
|
w.state.family.buildings = { yaoyuan: 3 }
|
|
w.state.family.inventory['beastcore'] = 0
|
|
for (let i = 0; i < 12; i++) w.advanceMonth()
|
|
expect((w.state.family.inventory['beastcore'] ?? 0) + 12).toBeGreaterThanOrEqual(12) // 每月保底1
|
|
})
|
|
|
|
it('价格漂移被夹在 [0.78, 1.25]', () => {
|
|
const w = World.create({ seed: 'eco-d', surname: '荀', familyName: '荀家', motto: 'm', difficulty: 'normal' })
|
|
for (let i = 0; i < 60; i++) w.advanceMonth()
|
|
const mult = w.state.family.flag['priceMult'] as number
|
|
expect(mult).toBeGreaterThanOrEqual(0.78)
|
|
expect(mult).toBeLessThanOrEqual(1.25)
|
|
})
|
|
|
|
it('marketPrice 基本价×行情×声望系数', () => {
|
|
const w = World.create({ seed: 'eco-e', surname: '柳', familyName: '柳家', motto: 'm', difficulty: 'normal' })
|
|
const base = ITEMS['lingcao'].basePrice
|
|
w.state.family.flag['priceMult'] = 1
|
|
w.state.family.reputation = 0
|
|
const p0 = marketPrice(w, 'lingcao')
|
|
expect(Math.abs(p0 - base)).toBeLessThanOrEqual(1)
|
|
w.state.family.flag['priceMult'] = 1.2
|
|
expect(marketPrice(w, 'lingcao')).toBeGreaterThan(p0)
|
|
})
|
|
|
|
it('买空仓拒绝、部分库存出售拒绝超卖', () => {
|
|
const w = World.create({ seed: 'eco-f', surname: '梁', familyName: '梁家', motto: 'm', difficulty: 'normal' })
|
|
w.state.family.stones = 5
|
|
expect(buyItem(w, 'lingcao', 1)).toBe(false)
|
|
w.state.family.stones = 99999
|
|
expect(buyItem(w, 'lingcao', 1000)).toBe(true)
|
|
expect(w.state.family.inventory['lingcao']).toBe(1060)
|
|
expect(sellItem(w, 'lingcao', 99999)).toBe(false)
|
|
expect(sellItem(w, 'lingcao', 1060)).toBe(true)
|
|
expect(w.state.family.inventory['lingcao']).toBe(0)
|
|
expect(sellItem(w, 'lingcao', 1)).toBe(false)
|
|
})
|
|
|
|
it('功法购买不可重复、收费合理', () => {
|
|
const w = World.create({ seed: 'eco-g', surname: '慕', familyName: '慕家', motto: 'm', difficulty: 'normal' })
|
|
w.state.family.stones = 99999
|
|
expect(buyTechnique(w, 't-zhenyu', techniquePrice('t-zhenyu'))).toBe(true)
|
|
expect(buyTechnique(w, 't-zhenyu', techniquePrice('t-zhenyu'))).toBe(false)
|
|
expect(w.state.family.stones).toBe(99999 - techniquePrice('t-zhenyu'))
|
|
})
|
|
|
|
it('丹房炼制消耗正确产出丹药', () => {
|
|
const w = World.create({ seed: 'eco-h', surname: '宋', familyName: '宋家', motto: 'm', difficulty: 'normal' })
|
|
w.state.family.buildings = { danfang: 5 }
|
|
const fam = w.state.family
|
|
fam.inventory['lingcao'] = 100
|
|
fam.inventory['beastcore'] = 10
|
|
fam.inventory['pill-qiyuan'] = 0
|
|
fam.inventory['pill-ningyuan'] = 0
|
|
fam.stones = 1000
|
|
const ok = w.craftPill('qiyuan')
|
|
expect(ok).toBe(true)
|
|
expect(fam.inventory['lingcao']).toBe(85)
|
|
expect(fam.inventory['pill-qiyuan']).toBe(1)
|
|
// 资源不足失败
|
|
fam.inventory['lingcao'] = 0
|
|
expect(w.craftPill('qiyuan')).toBe(false)
|
|
})
|
|
|
|
it('建筑耗材不足时拒绝升级(资源保持原值)', () => {
|
|
const w = World.create({ seed: 'eco-i', surname: '郝', familyName: '郝家', motto: 'm', difficulty: 'normal' })
|
|
const fam = w.state.family
|
|
fam.buildings = { lingtian: 1 }
|
|
fam.stones = 0
|
|
const stones0 = fam.stones
|
|
expect(w.upgrade('lingtian')).toBe(false)
|
|
expect(fam.stones).toBe(stones0)
|
|
})
|
|
|
|
it('祭祖成本与收益曲线确定', () => {
|
|
const w = World.create({ seed: 'eco-j', surname: '施', familyName: '施家', motto: 'm', difficulty: 'normal' })
|
|
const fam = w.state.family
|
|
fam.buildings = { zongci: 2, lingtian: 1 }
|
|
fam.stones = 1000
|
|
const rep0 = fam.reputation
|
|
expect(w.ancestralRite()).toBe(true)
|
|
expect(fam.stones).toBe(850)
|
|
expect(fam.reputation).toBe(rep0 + 6)
|
|
})
|
|
})
|