mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-08-28 09:16:47 +08:00
update: state, event, condition, data.event.types
This commit is contained in:
@@ -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