update: state, event, condition, data.event.types

This commit is contained in:
Vick Scarlet
2026-07-30 19:56:12 +08:00
parent 97988a95ba
commit 329a4e3a81
18 changed files with 1216 additions and 793 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
"main": "src/index.ts",
"author": "Vick Scarlet <vick@syaro.io>",
"scripts": {
"build": "bunx --bun v-transform@3.0.0 transform -t ts -w src -d dist \"**/[!~$]*.xlsx\" ",
"build": "bunx --bun v-transform@3.0.1 transform -t ts -w src -d dist \"**/[!~$]*.xlsx\" ",
"lint": "eslint .",
"test": "bun test"
},
+20 -1
View File
@@ -19,6 +19,14 @@ export type EventEffect = {
readonly AGE?: number
}
/** 分支路线 */
export type EventBranch = {
/** 分支条件 */
condition: string
/** 分支事件ID */
event: number
}
/** 事件 */
export type Event = {
/** ID */
@@ -38,7 +46,7 @@ export type Event = {
/** 有某事件时一定随机不到 */
readonly exclude?: string
/** 分支路线 */
readonly branch?: string[]
readonly branch?: EventBranch[]
}
// @vt-types-end
@@ -55,4 +63,15 @@ export const transformers = {
}
return val
},
branch: (val?: any[]) => {
if (!val) return
for (const key in val) {
const [condition, eventId] = val[key]!.split(':')
const event = Number(eventId)
if (isNaN(event))
throw new Error(`Invalid event ID in branch: ${eventId}`)
val[key] = { condition, event }
}
return val
},
}