0.1.37 天人感应·因果织锦:功德系统+飞升试炼+世界奇观+MOD扩展口
This commit is contained in:
@@ -64,6 +64,8 @@ export interface WorldSimState {
|
||||
worldAnnals?: { year: number; text: string }[]
|
||||
/** 世鉴(50/100 年宏观:开局 vs 现在/era 路径/最强家更替——独立数组零漂) */
|
||||
sagaAnnals?: { year: number; kind: 'quinquagenary' | 'centennial'; text: string }[]
|
||||
/** 0.1.37 世界奇观(当前活跃奇观;年首种子派生判定——零 rng 消耗) */
|
||||
wonder?: WorldWonder
|
||||
}
|
||||
|
||||
export function makeWorldSimState(): WorldSimState {
|
||||
@@ -225,11 +227,57 @@ export const WORLDSIM = {
|
||||
shortageLine: 0.7, // 断供警戒线:池/基准 < 此值起计连续月
|
||||
shortageMonths: 3,
|
||||
shortagePrice: 1.5, // 断供价乘
|
||||
newSecretChance: 0.04 // 年首新秘境现身概率(乱世 ×2)
|
||||
newSecretChance: 0.04, // 年首新秘境现身概率(乱世 ×2)
|
||||
// —— 0.1.37 因果/奇观 ——
|
||||
wonderChance: 0.08, // 世界奇观年首现身概率(种子派生——零 rng 消耗)
|
||||
karmaDecayRate: 0.1, // 功德年首衰减率(向中性靠拢——善行需持续)
|
||||
karmaHighThreshold: 30, // 功德深厚阈值(触发灾年 -15%/渡劫 +5%)
|
||||
karmaLowThreshold: -20 // 功德亏缺阈值(触发灾年 +15%/渡劫 -5%)
|
||||
}
|
||||
|
||||
export type CalamityName = string
|
||||
|
||||
// ==================== 0.1.37 世界奇观 ====================
|
||||
|
||||
/** 世界奇观类型(年首种子派生判定——零 rng 消耗) */
|
||||
export type WorldWonderKind = 'tide_surge' | 'ancient_ruin' | 'heaven_bless' | 'qi_wane' | string
|
||||
|
||||
export interface WorldWonder {
|
||||
kind: WorldWonderKind
|
||||
year: number
|
||||
/** 持续月数(灵气涌潮/灵脉枯竭有持续效果;古遗迹/天降祥瑞一次性) */
|
||||
duration?: number
|
||||
/** 已过月数 */
|
||||
elapsed?: number
|
||||
}
|
||||
|
||||
/** 世界奇观年首现身概率(聚合读口——MOD 可经 worldNum('wonderChance') 覆写) */
|
||||
export const WONDER_CHANCE = 0.08
|
||||
|
||||
/** 奇观名称映射 */
|
||||
export const WONDER_NAMES: Record<WorldWonderKind, string> = {
|
||||
tide_surge: '灵气涌潮',
|
||||
ancient_ruin: '古遗迹现身',
|
||||
heaven_bless: '天降祥瑞',
|
||||
qi_wane: '灵脉枯竭'
|
||||
}
|
||||
|
||||
/** 奇观描述 */
|
||||
export const WONDER_DESCS: Record<WorldWonderKind, string> = {
|
||||
tide_surge: '天地灵气如潮涌至,万灵共鸣——修炼事半功倍。',
|
||||
ancient_ruin: '远古修士洞府现世——其中或藏功法丹材之珍。',
|
||||
heaven_bless: '祥瑞降世——风调雨顺,灾厄消弭。',
|
||||
qi_wane: '灵脉逆行——天地灵气骤衰,修行维艰。'
|
||||
}
|
||||
|
||||
/** 奇观持续月数(灵气涌潮/灵脉枯竭持续 12 月;古遗迹/天降祥瑞一次性) */
|
||||
export const WONDER_DURATION: Record<WorldWonderKind, number> = {
|
||||
tide_surge: 12,
|
||||
ancient_ruin: 0,
|
||||
heaven_bless: 0,
|
||||
qi_wane: 12
|
||||
}
|
||||
|
||||
/** 默认灾因集(聚合读口:默认+MOD/插件扩展——默认表和不变 → 基准世界指纹不漂) */
|
||||
export const DEFAULT_CALAMITIES = ['旱灾', '涝灾', '蝗灾', '疫病', '兽潮', '寒潮'] as const
|
||||
|
||||
@@ -292,3 +340,61 @@ export function calamityEffectOf(name: string): Partial<Record<string, number>>
|
||||
export function calamityDescOf(name: string): string {
|
||||
return EXTENDED_BRIEF[name] ?? `${name}——灵植减产,市价将行。`
|
||||
}
|
||||
|
||||
// ==================== 0.1.37 奇观类型扩展注册表(MOD 口) ====================
|
||||
|
||||
/** 扩展奇观类型定义(MOD 可注入自定义奇观——零 rng 消耗,种子派生选取) */
|
||||
export interface ExtendedWonderDef {
|
||||
/** 奇观类型 id(唯一——与内置不冲突) */
|
||||
kind: string
|
||||
/** 中文名称 */
|
||||
name: string
|
||||
/** 描述文本 */
|
||||
desc: string
|
||||
/** 持续月数(0 = 一次性) */
|
||||
duration: number
|
||||
/** 持续效果类型:tide_up = 灵气增益 / tide_down = 灵气衰减 / none = 无持续效果 */
|
||||
effect: 'tide_up' | 'tide_down' | 'none'
|
||||
/** 一次性效果:bless = 灾年消弭+声望 / loot = 资源获取 / none = 无 */
|
||||
oneshot: 'bless' | 'loot' | 'none'
|
||||
}
|
||||
|
||||
const EXTENDED_WONDERS: ExtendedWonderDef[] = []
|
||||
|
||||
/** 内置奇观定义(供聚合读口统一访问) */
|
||||
const BUILTIN_WONDERS: ExtendedWonderDef[] = [
|
||||
{ kind: 'tide_surge', name: '灵气涌潮', desc: '天地灵气如潮涌至,万灵共鸣——修炼事半功倍。', duration: 12, effect: 'tide_up', oneshot: 'none' },
|
||||
{ kind: 'ancient_ruin', name: '古遗迹现身', desc: '远古修士洞府现世——其中或藏功法丹材之珍。', duration: 0, effect: 'none', oneshot: 'loot' },
|
||||
{ kind: 'heaven_bless', name: '天降祥瑞', desc: '祥瑞降世——风调雨顺,灾厄消弭。', duration: 0, effect: 'none', oneshot: 'bless' },
|
||||
{ kind: 'qi_wane', name: '灵脉枯竭', desc: '灵脉逆行——天地灵气骤衰,修行维艰。', duration: 12, effect: 'tide_down', oneshot: 'none' }
|
||||
]
|
||||
|
||||
/** MOD/插件注册奇观类型(kind 唯一——与内置+已注册不冲突) */
|
||||
export function addWonderType(def: Omit<ExtendedWonderDef, 'name' | 'desc' | 'duration' | 'effect' | 'oneshot'> & Partial<Omit<ExtendedWonderDef, 'kind'>>): boolean {
|
||||
if (!def.kind || BUILTIN_WONDERS.some((w) => w.kind === def.kind) || EXTENDED_WONDERS.some((w) => w.kind === def.kind)) return false
|
||||
EXTENDED_WONDERS.push({
|
||||
kind: def.kind,
|
||||
name: def.name ?? '异变',
|
||||
desc: def.desc ?? '天地异变,灵机暗涌。',
|
||||
duration: def.duration ?? 0,
|
||||
effect: def.effect ?? 'none',
|
||||
oneshot: def.oneshot ?? 'none'
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
/** 卸载时按 kind 摘除扩展奇观 */
|
||||
export function removeWonderType(kind: string): void {
|
||||
const idx = EXTENDED_WONDERS.findIndex((w) => w.kind === kind)
|
||||
if (idx >= 0) EXTENDED_WONDERS.splice(idx, 1)
|
||||
}
|
||||
|
||||
/** 聚合读口:全部奇观类型(内置 + 扩展) */
|
||||
export function allWonderKinds(): ExtendedWonderDef[] {
|
||||
return [...BUILTIN_WONDERS, ...EXTENDED_WONDERS]
|
||||
}
|
||||
|
||||
/** 聚合读口:按 kind 查奇观定义 */
|
||||
export function wonderDefOf(kind: string): ExtendedWonderDef | undefined {
|
||||
return BUILTIN_WONDERS.find((w) => w.kind === kind) ?? EXTENDED_WONDERS.find((w) => w.kind === kind)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user