v0.1.34a: 功法万象+世界自演化——流派效果/元素时节/悟位大成/战争疲劳/换代半衰/断供应急/新秘境
【功法】TechniqueDef 新增 critChance/guardBonus/tribBonus/secretBonus(optional 零漂); 6 部新功法(玄冰凝甲/紫电惊雷/丹鼎护道/风遁青冥/山灵镇岳/澜海听涛); 季节元素共鸣(春木夏火秋金冬水——修炼额外×1.04);演武场联动悟位积累;悟位2大成战斗效果倍增 【世界】warFatigue 互攻累积→世界温度冷降→乱世加速(打不动即荒年); NpcDyn 换代恩义清(关系网向零收敛×0.5);断供应急(连续3月池深<70%→广播+价×1.5); 新秘境灵机(年首几率·乱世×2·模板化生成 addMission 扩展口);addMission 公共口(secrets.ts) 【修复】shortage 广播模块级全局污染→世界状态化(多世界确定性恢复) 【测试】world 确定性恢复绿;金钟罩预期漂移(换代/共鸣/warFatigue)——0.1.34 基线待重算
This commit is contained in:
@@ -13,10 +13,13 @@ export function marketPrice(w: World, itemId: string): number {
|
||||
const mood = fam.reputation >= 40 ? 1.06 : fam.reputation >= 20 ? 1.02 : 0.98
|
||||
// 世界行情乘子(唯一读口:worldSim.marketMultFor;无 sim 时 1)
|
||||
const simMult = w.state.worldSim ? new WorldSim(w).marketMultFor(itemId) : 1
|
||||
// 0.1.34 断供应急:货源连续告急(shortage ≥ 触发月数)→ 价格上浮(恐慌:供不应求者贵)
|
||||
const shortN = w.state.worldSim?.shortage?.[itemId]
|
||||
const shortMult = shortN && shortN >= worldNum('shortageMonths') ? worldNum('shortagePrice') : 1
|
||||
// 利己(priceMult)与信誉修正
|
||||
const sellers = w.aliveMembers().filter((c) => traitBonuses(c).priceMult > 0).length
|
||||
const liarPct = Math.min(0.2, sellers * 0.04)
|
||||
return Math.max(1, Math.round(base * mult * mood * simMult * (1 - liarPct)))
|
||||
return Math.max(1, Math.round(base * mult * mood * simMult * shortMult * (1 - liarPct)))
|
||||
}
|
||||
|
||||
export function buyItem(w: World, itemId: string, count: number): boolean {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { WorldSimState, NpcDynamics, WORLDSIM, ERA_CONF, makeWorldSimState, NpcS
|
||||
import { pack } from '../../data/registry'
|
||||
import { ITEMS } from '../../data/items'
|
||||
import { npcById, getNpcDefs, registerNpcDef, unregisterNpcDef } from '../../data/npcs'
|
||||
import { allMissions, addMission, WONDER_TEMPLATES, type MissionDef } from '../../data/secrets'
|
||||
import { MAJORS, MAJOR_ORDER } from '../../data/realms'
|
||||
|
||||
const MARKET_IDS = ['lingcao', 'lingkuang', 'beastcore', 'lingyu', 'lingmu', 'shoupi', 'lingguo', 'pill-qiyuan', 'pill-ningyuan']
|
||||
@@ -16,7 +17,7 @@ export class WorldSim {
|
||||
if (!w.state.worldSim) w.state.worldSim = initSim(w)
|
||||
const ws = w.state.worldSim as WorldSimState
|
||||
if (!ws.secretQi || Object.keys(ws.secretQi).length === 0) {
|
||||
const defs = pack().missions
|
||||
const defs = allMissions()
|
||||
ws.secretQi = {}
|
||||
for (const m of defs) ws.secretQi[m.id] = 50
|
||||
}
|
||||
@@ -127,7 +128,25 @@ export class WorldSim {
|
||||
// ---- A. 资源循环市场(世界供给/需求 + NPC 上桌 + 再平衡) ----
|
||||
worldBreath(this.w, s) // A2+A3:常驻供给与需求(潮汐乘化)
|
||||
npcTrade(this.w, s, rng.next()) // A4:NPC 按 sells/buys 与池交易
|
||||
driftMarket(s, rng.next()) // 波动项(保留噪声弹性)
|
||||
driftMarket(s, rng.next(), this.w) // 波动项(保留噪声弹性)
|
||||
|
||||
// ---- B0. 新秘境灵机(0.1.34 万象归元:年首机率——乱世×2) ----
|
||||
if (this.w.state.month === 1) {
|
||||
const era2 = s.era === 'luanshi' ? 2 : 1
|
||||
if (rng.chance(worldNum('newSecretChance') * era2)) {
|
||||
const tpl = rng.pick(WONDER_TEMPLATES)
|
||||
const seedS = rng.int(1000, 9999)
|
||||
const def: MissionDef = {
|
||||
...tpl,
|
||||
id: `m-wonder-${seedS}`,
|
||||
name: `${tpl.icon}地灵诏——「${'古幽玄凌'}${rng.int(1, 9)}」`
|
||||
}
|
||||
addMission(def)
|
||||
s.secretQi[def.id] = Math.max(50, s.secretQi[def.id] ?? 50)
|
||||
s.newsFeed.push({ year: this.w.state.year, month: 1, src: '天机', text: `${def.name} 现世——灵光冲霄,远近皆见。`, kind: 'annal' })
|
||||
this.w.log('info', `【天下】有异宝出世:${def.name}。`)
|
||||
}
|
||||
}
|
||||
|
||||
// ---- B. NPC 演化(换代 + 关系网 + 互攻;B7) ----
|
||||
evolveNpc(this.w, s, rng.next())
|
||||
@@ -282,7 +301,9 @@ export class WorldSim {
|
||||
sum += (s.marketPool[id] ?? base) / base
|
||||
n++
|
||||
}
|
||||
return n > 0 ? sum / n : 1
|
||||
const cold = n > 0 ? sum / n : 1
|
||||
// 0.1.34 战争疲劳上浮:天下杀伐不止,寒气怨气凝而灵脉皆冷(打不动即荒年)
|
||||
return cold - (s.warFatigue ?? 0) * worldNum('warFatigueTempK')
|
||||
}
|
||||
|
||||
news(): WorldSimState['newsFeed'] {
|
||||
@@ -409,7 +430,12 @@ function npcTrade(w: World, s: WorldSimState, noise: number): void {
|
||||
}
|
||||
}
|
||||
|
||||
function driftMarket(s: WorldSimState, noise: number): void {
|
||||
function itemNameOf(id: string): string {
|
||||
const N: Record<string, string> = { lingcao: '灵草', lingkuang: '灵矿', beastcore: '兽核', lingyu: '灵玉', lingmu: '灵木', shoupi: '兽皮', lingguo: '灵果' }
|
||||
return N[id] ?? id
|
||||
}
|
||||
|
||||
function driftMarket(s: WorldSimState, noise: number, w: World): void {
|
||||
let n = noise
|
||||
// W3 材料生态相关:自然资源同向微漂(灵木/符链共享偏置——物产同源)
|
||||
const matBias = (noise - 0.5) * 0.012
|
||||
@@ -423,6 +449,19 @@ function driftMarket(s: WorldSimState, noise: number): void {
|
||||
const isMaterial = ['lingyu', 'lingmu', 'shoupi', 'lingguo'].includes(id)
|
||||
|
||||
s.marketPool[id] = Math.max(base * WORLDSIM.poolFloorPct, cur + rebalance + drift + (isMaterial ? matBias * base : 0))
|
||||
// 0.1.34 断供监测:货源紧张连续月计数(触发价上浮×世界广播)
|
||||
const line = base * WORLDSIM.shortageLine
|
||||
if (s.marketPool[id] < line) {
|
||||
s.shortage = s.shortage ?? {}
|
||||
s.shortage[id] = (s.shortage[id] ?? 0) + 1
|
||||
if (s.shortage[id] === worldNum('shortageMonths')) {
|
||||
s.shortageWarned = s.shortageWarned ?? {}
|
||||
s.shortageWarned[id] = w.state.year
|
||||
s.newsFeed.push({ year: w.state.year, month: 6, src: '行商', text: `${itemNameOf(id)}断货数月——坊市惜售,价腾三成。`, kind: 'annal' })
|
||||
}
|
||||
} else if (s.shortage?.[id]) {
|
||||
delete s.shortage[id]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,6 +608,8 @@ function evolveNpc(w: World, s: WorldSimState, noise: number): void {
|
||||
const wr = otherDyn.relationsWithOthers[winner.id] ?? 0
|
||||
otherDyn.relationsWithOthers[winner.id] = clamp(wr + 4, -100, 100)
|
||||
}
|
||||
// 0.1.34 战争疲劳:乱象(互攻/大劫)累积——世界温度上浮,乱世加速
|
||||
s.warFatigue = clamp((s.warFatigue ?? 0) + worldNum('warFatigueRise'), 0, 1)
|
||||
s.newsFeed.push({
|
||||
year, month: 1, src: winner.name,
|
||||
text: `${winner.name} 与 ${loser.name} 起衅——痛挫其锋,势力大动。`
|
||||
|
||||
@@ -52,6 +52,12 @@ export interface WorldSimState {
|
||||
overfluxYear?: number
|
||||
/** 盟友求援(最近一次:互攻失利波及盟我之族) */
|
||||
distress?: { id: string; year: number; month: number }
|
||||
/** 战争疲劳(0~1):NPC 互攻/玩家 raid 逐年累积——世界温度上浮,乱世加速 */
|
||||
warFatigue?: number
|
||||
/** 断供监测:货源id→连续低于警戒线月数(≥3 触发断供告警×1.5 价) */
|
||||
shortage?: Record<string, number>
|
||||
/** 断供已播年(id→年——仅始发广播,持续断供不刷屏) */
|
||||
shortageWarned?: Record<string, number>
|
||||
/** 天下史书(十年一鉴独立留档,免 newsFeed 裁剪;上限 80 页) */
|
||||
worldAnnals?: { year: number; text: string }[]
|
||||
/** 世鉴(50/100 年宏观:开局 vs 现在/era 路径/最强家更替——独立数组零漂) */
|
||||
@@ -206,7 +212,14 @@ export const WORLDSIM = {
|
||||
calamities: ['旱灾', '涝灾', '蝗灾', '疫病', '兽潮', '寒潮'] as const,
|
||||
npcEventChance: 0.05, // NPC 互攻年首诗签概率
|
||||
newsEvery: 24, // 月
|
||||
newsKeep: 120
|
||||
newsKeep: 120,
|
||||
// —— 0.1.34 万象归元(战争疲劳/断供/新秘境) ——
|
||||
warFatigueRise: 0.008, // 每次乱象(NPC 互攻)累积的战争疲劳
|
||||
warFatigueTempK: 0.6, // 疲劳对世界温度的冷降幅度(打不动即荒年)
|
||||
shortageLine: 0.7, // 断供警戒线:池/基准 < 此值起计连续月
|
||||
shortageMonths: 3,
|
||||
shortagePrice: 1.5, // 断供价乘
|
||||
newSecretChance: 0.04 // 年首新秘境现身概率(乱世 ×2)
|
||||
}
|
||||
|
||||
export type CalamityName = string
|
||||
|
||||
Reference in New Issue
Block a user