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:
2026-08-23 22:00:55 +08:00
parent b7c5f1eca0
commit a491b9c54a
12 changed files with 163 additions and 15 deletions
@@ -90,7 +90,16 @@ export function resolveEncounter(
const talisman = opts.kind === 'war' ? talismanWarPrep(w) : null
const talismMult = talisman === 'feng' ? 1.12 : talisman === 'shan' ? 1.15 : 1
let team = 0
for (const c of opts.team) team += combatPowerOf(w, c)
let guard = 0
let crit = 0
for (const c of opts.team) {
team += combatPowerOf(w, c)
const t = techniqueById(c.techniqueId)
guard += (t?.guardBonus ?? 0)
crit += (t?.critChance ?? 0)
}
guard /= Math.max(1, opts.team.length)
crit /= Math.max(1, opts.team.length)
team *= talismMult
const enemy = Math.round(enemyPowerOf(opts.enemy, opts.risk) * form.def)
const jitter = w.rng.between(0.88, 1.12)
@@ -118,7 +127,7 @@ export function resolveEncounter(
if (!c.alive || c.state === 'wounded') continue
const severity = w.rng.next()
if (!win) {
if (severity < 0.1 && w.rng.chance(opts.risk * 0.08 + 0.02)) {
if (severity < 0.1 && w.rng.chance((opts.risk * 0.08 + 0.02) * (1 - crit))) {
c.alive = false
c.deathYear = year
c.deathCause = `战殁于${opts.enemy.name}之手`
@@ -126,13 +135,13 @@ export function resolveEncounter(
w.chronicle('death', `${c.name} 战殁于${opts.enemy.name},一身所学俱付尘烟。`, c.id, true)
w.emitFx('ripple', `death:${c.id}`)
} else if (severity < 0.45) {
const woundAmt = Math.round((40 + w.rng.int(0, 25)) * form.retreatWound * (talisman === 'shan' ? 0.5 : 1))
const woundAmt = Math.round((40 + w.rng.int(0, 25)) * form.retreatWound * (talisman === 'shan' ? 0.5 : 1) * (1 - guard))
c.health = Math.max(1, c.health - woundAmt)
c.state = 'wounded'
loss.push(`${c.name} 重伤`)
}
} else if (w.rng.chance(0.12)) {
c.health = Math.max(1, c.health - 20 - w.rng.int(0, 15))
c.health = Math.max(1, c.health - Math.round((20 + w.rng.int(0, 15)) * (1 - guard)))
if (c.health < 35) c.state = 'wounded'
loss.push(`${c.name} 轻伤`)
}
@@ -4,6 +4,7 @@ import { ROOT_GRADES } from '../../../data/elements'
import { masteryRateOfMajor } from '../../../data/pacing'
import { aspirationById, fitBonusOf } from '../../../data/aspirations'
import { techniqueById } from '../../../data/techniques'
import { seasonOf, SEASON_ELEMENT } from '../../../data/season'
import { nextRealm, breakthroughBaseChance, realmDeathChance, describeRealm, MAJOR_ORDER } from '../../../data/realms'
import { lifespanOf } from './lifecycle'
import { traitBonuses } from '../pcgen'
@@ -24,6 +25,8 @@ export function monthlyRate(w: World, c: Character, herbFactor = 1): number {
const tech = techniqueById(c.techniqueId)
if (tech && c.realm.major !== 'mortal') {
rate *= 1 + tech.expBonus + (c.techniqueRank ?? 0) * 0.05
// 0.1.34 万象归元:功法元素与时令共鸣(春木夏火秋金冬水——身合自然)
if (w.sysEnabled('season') && SEASON_ELEMENT[seasonOf(st.month)] === tech.element) rate *= 1.04
} else if (c.realm.major !== 'mortal') {
rate *= 0.65
}
@@ -108,7 +111,9 @@ export function cultivationTick(w: World): void {
// 悟道进度:有功法且修为之外,另积一分慧根
if (c.techniqueId && c.realm.major !== 'mortal') {
const rank = c.techniqueRank ?? 0
const gain = rate * (rank === 0 ? 0.5 : rank === 1 ? 0.3 : 0.15)
const wuLvl = w.state.family.buildings['yanwu'] ?? 0
const wuMult = 1 + wuLvl * 0.08 // 0.1.34 演武场联动——日日操练,悟性开慧
const gain = rate * (rank === 0 ? 0.5 : rank === 1 ? 0.3 : 0.15) * wuMult
c.techniqueProgress = Math.min(100, (c.techniqueProgress ?? 0) + gain)
if (c.techniqueProgress >= 100) {
if (rank === 0) {
@@ -36,7 +36,7 @@ export function missionTick(w: World): void {
if (victim.health < 35) victim.state = 'wounded'
}
} else if (stage.kind === 'resource') {
const loot = rollWarbooty(w, stage.loot ?? def.completionLoot, qiRatioOf(w, def.id))
const loot = scaleBySecret(w, m, rollWarbooty(w, stage.loot ?? def.completionLoot, qiRatioOf(w, def.id)))
m.log.push(`${stage.title}:收获 ${lootText(loot)}`)
} else if (stage.kind === 'combat' || stage.kind === 'boss') {
const enemy = ENEMIES.find((e) => e.id === stage.enemyId) ?? ENEMIES[0]
@@ -69,7 +69,7 @@ export function missionTick(w: World): void {
m.done = true
m.result = 'success'
releaseSquad(w, m)
const total = rollWarbooty(w, def.completionLoot, qiRatioOf(w, def.id))
const total = scaleBySecret(w, m, rollWarbooty(w, def.completionLoot, qiRatioOf(w, def.id)))
// 0.1.23 秘境回池:探得之物近 2 成回流人间(负反馈世界侧供给)
if (w.state.worldSim) {
const sim = new WorldSim(w)
@@ -92,6 +92,19 @@ export function missionTick(w: World): void {
}
}
/** 0.1.34 功法秘境加成:结队平均 secretBonus → 战利乘数(零 rng——值域确定) */
function scaleBySecret(w: World, m: MissionState, loot: Record<string, number>): Record<string, number> {
const squad = squadOf(w, m)
if (squad.length === 0) return loot
let bonus = 0
for (const c of squad) bonus += techniqueById(c.techniqueId)?.secretBonus ?? 0
bonus /= squad.length
if (bonus <= 0) return loot
const out: Record<string, number> = {}
for (const [k, v] of Object.entries(loot)) out[k] = typeof v === 'number' ? Math.max(1, Math.round(v * (1 + bonus))) : v
return out
}
function squadOf(w: World, m: MissionState) {
return m.memberIds.map((id) => w.memberById(id)).filter((c) => c.alive)
}
@@ -1,6 +1,7 @@
import type { World } from '../World'
import { Character } from '../../../types/domain'
import { nextRealm, MAJOR_ORDER, realmDeathChance, describeRealm } from '../../../data/realms'
import { techniqueById } from '../../../data/techniques'
export const TRIB_MAJORS: string[] = ['foundation', 'core', 'nascent', 'spirit']
@@ -100,5 +101,6 @@ export function perTribChance(w: World, c: Character): number {
nascent: 0.36,
spirit: 0.26
} as Record<string, number>)[c.realm.major] ?? 0.9
return Math.min(0.92, base + c.mind * 0.01 + c.health / 400 + (c.tribBoost ?? 0))
const tb = techniqueById(c.techniqueId)?.tribBonus ?? 0
return Math.min(0.92, base + c.mind * 0.01 + c.health / 400 + (c.tribBoost ?? 0) + tb)
}
+4 -1
View File
@@ -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 {
+45 -4
View File
@@ -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()) // A4NPC 按 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} 起衅——痛挫其锋,势力大动。`
+14 -1
View File
@@ -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