mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-08-28 01:06:49 +08:00
update: state, event, condition, data.event.types
This commit is contained in:
@@ -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"
|
||||
},
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user