v0.1.17: 天下为市——世界真炉膛(市场实体化+NPC博弈+灾年持续)

【A 市场实体化(真库存循环)】
- 世界呼吸:池月供给 × 潮汐span - 常驻需求(worldSupplyRate 2% vs worldDemandRate 1.5%)
- NPC 上桌:def.sells/buys 逐月入池出池——池浅采不到→power-15%,池深抛货→市场暖意
- 玩家交易回写:buy 浅池价涨/sell 盈池价跌(tradeSettle 0.35 份额粒度);池深<35% 断供拒单(12% 是枯井)
- marketPrice 统一走 marketMultFor;本地 POOL_BASE/TECH 复刻清除(worldsim-data 单源)

【B 世界格局博弈】
- 战争伤骨:劫掠胜负回写 power(败-18%/胜+6%)+ dead 字段 raidCount/warCooldownYear 启用
- 社交回响:赠礼回礼(30% 灵石/30% 灵草)+ power 微涨;联姻/和约/结盟皆涨 power
- NPC 关系网:relationsWithOthers 填实(同风格亲30~55/异风格隙-35~15)+ 年首±5 漂移;世仇<-50 年首互攻(败方-18%)
- 灾年共苦:灾年 NPC 贸易 ×0.7;tide 对供给 ±0.3 弹性
- 灾年持续 6 月渐退;灾起/灾散快讯(kind 标记)

【UI】
- 天下面板:池深百分比(含断供阈值 tooltip)/本族天下排位/灾年余月
- 快讯响应化:行情见顶抛售5/见底吃进5/灾年救济(50灵石→关系8)
- MarketPanel 法帖价格改 techniquePrice()(硬编码清除)

【测试】994 全绿(38 套件,新增世界炉膛 8 例);金钟罩 0.1.17 基线固化
This commit is contained in:
2026-08-23 14:24:23 +08:00
parent 809707408b
commit ea9f5c9c5d
17 changed files with 353 additions and 53 deletions
@@ -190,9 +190,16 @@ export function resolveRaid(
if (res.win) {
npc.relation = Math.min(60, npc.relation + 25)
w.state.family.reputation += 6
// B5:战争伤骨——败方 power 重挫,次年不再来犯(warCooldownYear/raidCount 启用)
npc.power = Math.max(40, Math.round(npc.power * 0.82))
npc.raidCount = (npc.raidCount ?? 0) + 1
npc.warCooldownYear = w.state.year
w.chronicle('battle', `击退${npc.name}的犯境,家族声威大振。`, undefined, true)
} else if (!res.draw) {
npc.relation = Math.max(-100, npc.relation - 15)
npc.raidCount = (npc.raidCount ?? 0) + 1
npc.warCooldownYear = w.state.year
npc.power = Math.min(900, Math.round(npc.power * 1.06))
const st = w.state.family.stones
const lostFew = Math.min(st, Math.round(st * 0.25))
w.state.family.stones -= lostFew
@@ -49,6 +49,17 @@ export function giftNpc(w: World, npcId: string, stones: number): boolean {
const npc = w.state.npcFamilies[npcId]
const gain = calcGiftGain(stones)
npc.relation = Math.min(100, npc.relation + gain)
npc.power = Math.min(900, npc.power + gain * 0.4)
// 回礼:盛情难却,或赠灵石或赠灵草
if (w.rng.chance(0.3)) {
const back = Math.round(gain * 1.5)
w.state.family.stones += back
w.log('info', `${npc.name} 回赠灵石${back},来而往之。`)
} else if (w.rng.chance(0.3)) {
const back = 2 + w.rng.int(0, 3)
w.state.family.inventory['lingcao'] = (w.state.family.inventory['lingcao'] ?? 0) + back
w.log('info', `${npc.name} 回赠灵草${back}株。`)
}
w.log('info', `厚礼送往${npc.name},两家关系 +${gain}`)
return true
}
@@ -59,6 +70,7 @@ export function makePeace(w: World, npcId: string): boolean {
if (fam.stones < 200) return false
fam.stones -= 200
npc.relation = Math.max(npc.relation + 35, 30)
npc.power = Math.min(900, npc.power + 5)
w.chronicle('diplomacy', `${npc.name}立下和约,两家罢兵互市。`, undefined, true)
w.log('good', `${npc.name}言和。`)
return true