mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-08-28 09:16:47 +08:00
update: data transformers
This commit is contained in:
@@ -1,9 +1,14 @@
|
|||||||
export type Grade = 0 | 1 | 2 | 3
|
/** 成就稀有度 */
|
||||||
export type Opportunity =
|
export type AchievementGrade = 0 | 1 | 2 | 3
|
||||||
|
|
||||||
|
/** 成就触发时机 */
|
||||||
|
export type AchievementOpportunity =
|
||||||
| 'START' // 分配完成点数,点击开始新人生后
|
| 'START' // 分配完成点数,点击开始新人生后
|
||||||
| 'TRAJECTORY' // 每一年的人生经历中
|
| 'TRAJECTORY' // 每一年的人生经历中
|
||||||
| 'SUMMARY' // 人生结束,点击人生总结后
|
| 'SUMMARY' // 人生结束,点击人生总结后
|
||||||
| 'END' // 游戏完成,点击重开 重开次数在这之后才会+1
|
| 'END' // 游戏完成,点击重开 重开次数在这之后才会+1
|
||||||
|
|
||||||
|
/** 成就 */
|
||||||
export type Achievement = {
|
export type Achievement = {
|
||||||
/** 序号 */
|
/** 序号 */
|
||||||
readonly id: number
|
readonly id: number
|
||||||
@@ -12,11 +17,17 @@ export type Achievement = {
|
|||||||
/** 成就文案 */
|
/** 成就文案 */
|
||||||
readonly description: string
|
readonly description: string
|
||||||
/** 稀有度 */
|
/** 稀有度 */
|
||||||
readonly grade: Grade
|
readonly grade: AchievementGrade
|
||||||
/** 触发条件 */
|
/** 触发条件 */
|
||||||
readonly condition: string
|
readonly condition: string
|
||||||
/** 是否隐藏成就 */
|
/** 是否隐藏成就 */
|
||||||
readonly hide: boolean
|
readonly hide: boolean
|
||||||
/** 触发时机 */
|
/** 触发时机 */
|
||||||
readonly opportunity: Opportunity
|
readonly opportunity: AchievementOpportunity
|
||||||
|
}
|
||||||
|
// @vt-types-end
|
||||||
|
|
||||||
|
export const transformers = {
|
||||||
|
id: Number,
|
||||||
|
grade: (val: any) => Number(val) || 0,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
|
/** 权重事件 */
|
||||||
export type EventWithWeight = [number, number]
|
export type EventWithWeight = [number, number]
|
||||||
|
|
||||||
|
/** 年龄 */
|
||||||
export type Age = {
|
export type Age = {
|
||||||
/** 年龄 */
|
/** 年龄 */
|
||||||
readonly age: number
|
readonly age: number
|
||||||
/** 事件列表 */
|
/** 事件池 */
|
||||||
readonly event: EventWithWeight[]
|
readonly event: EventWithWeight[]
|
||||||
}
|
}
|
||||||
// @vt-types-end
|
// @vt-types-end
|
||||||
|
|
||||||
export const transformers = {
|
export const transformers = {
|
||||||
|
age: Number,
|
||||||
event: (val: any) => {
|
event: (val: any) => {
|
||||||
if (val === null || val === undefined)
|
if (val === null || val === undefined)
|
||||||
throw new Error(`Invalid event value: ${val}`)
|
throw new Error(`Invalid event value: ${val}`)
|
||||||
|
|||||||
@@ -1,15 +1,24 @@
|
|||||||
export type Property = {
|
/** 人物属性 */
|
||||||
|
export type CharacterProperty = {
|
||||||
|
/** 颜值 */
|
||||||
readonly CHR: number
|
readonly CHR: number
|
||||||
|
/** 智力 */
|
||||||
readonly INT: number
|
readonly INT: number
|
||||||
|
/** 体质 */
|
||||||
readonly STR: number
|
readonly STR: number
|
||||||
|
/** 家境 */
|
||||||
readonly MNY: number
|
readonly MNY: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 人物 */
|
||||||
export type Character = {
|
export type Character = {
|
||||||
/** ID */
|
/** 序号 */
|
||||||
readonly id: number
|
readonly id: number
|
||||||
/** 事件列表 */
|
/** 人名 */
|
||||||
readonly name: string
|
readonly name: string
|
||||||
readonly property: Property
|
/** 属性 */
|
||||||
|
readonly property: CharacterProperty
|
||||||
|
/** 天赋 */
|
||||||
readonly talent: number[]
|
readonly talent: number[]
|
||||||
}
|
}
|
||||||
// @vt-types-end
|
// @vt-types-end
|
||||||
|
|||||||
@@ -1,31 +1,51 @@
|
|||||||
export type Grade = 0 | 1 | 2 | 3
|
/** 事件稀有度 */
|
||||||
|
export type EventGrade = 0 | 1 | 2 | 3
|
||||||
|
|
||||||
export type Effect = {
|
/** 事件效果 */
|
||||||
MNY?: number
|
export type EventEffect = {
|
||||||
STR?: number
|
/** 颜值变化 */
|
||||||
INT?: number
|
readonly CHR?: number
|
||||||
CHR?: number
|
/** 智力变化 */
|
||||||
SPR?: number
|
readonly INT?: number
|
||||||
LIF?: number
|
/** 体质变化 */
|
||||||
|
readonly STR?: number
|
||||||
|
/** 家境变化 */
|
||||||
|
readonly MNY?: number
|
||||||
|
/** 快乐变化 */
|
||||||
|
readonly SPR?: number
|
||||||
|
/** 寿命变化 */
|
||||||
|
readonly LIF?: number
|
||||||
|
/** 年龄变化 */
|
||||||
|
readonly AGE?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 事件 */
|
||||||
export type Event = {
|
export type Event = {
|
||||||
/** ID */
|
/** ID */
|
||||||
readonly id: number
|
readonly id: number
|
||||||
/** 事件列表 */
|
/** 事件内容 */
|
||||||
readonly event: string
|
readonly event: string
|
||||||
|
/** 事件稀有度 */
|
||||||
|
readonly grade: EventGrade
|
||||||
|
/** 追加事件内容 */
|
||||||
readonly postEvent?: string
|
readonly postEvent?: string
|
||||||
readonly grade?: number
|
/** 事件效果 */
|
||||||
readonly effect?: Effect
|
readonly effect?: EventEffect
|
||||||
readonly branch?: string[]
|
/** 非随机事件 */
|
||||||
readonly NoRandom?: boolean
|
readonly NoRandom?: boolean
|
||||||
|
/** 有某事件时才能被随机到 */
|
||||||
readonly include?: string
|
readonly include?: string
|
||||||
|
/** 有某事件时一定随机不到 */
|
||||||
readonly exclude?: string
|
readonly exclude?: string
|
||||||
|
/** 分支路线 */
|
||||||
|
readonly branch?: string[]
|
||||||
}
|
}
|
||||||
// @vt-types-end
|
// @vt-types-end
|
||||||
|
|
||||||
export const transformers = {
|
export const transformers = {
|
||||||
id: Number,
|
id: Number,
|
||||||
|
// 默认稀有度为0
|
||||||
|
grade: (val: any) => Number(val) || 0,
|
||||||
effect: (val: any) => {
|
effect: (val: any) => {
|
||||||
if (!val) return
|
if (!val) return
|
||||||
for (const key in val) {
|
for (const key in val) {
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
export type Group = 1 | 2
|
/** 特别鸣谢分组 */
|
||||||
|
export type SpecialThanksGroup = 1 | 2
|
||||||
|
|
||||||
|
/** 特别鸣谢 */
|
||||||
export type SpecialThanks = {
|
export type SpecialThanks = {
|
||||||
readonly group: Group
|
/** 特别鸣谢分组 */
|
||||||
|
readonly group: SpecialThanksGroup
|
||||||
|
/** 名字 */
|
||||||
readonly name: string
|
readonly name: string
|
||||||
|
/** 喊话 */
|
||||||
readonly comment?: string
|
readonly comment?: string
|
||||||
|
/** 颜色 */
|
||||||
readonly color?: string
|
readonly color?: string
|
||||||
}
|
}
|
||||||
// @vt-types-end
|
// @vt-types-end
|
||||||
|
|||||||
@@ -1,26 +1,61 @@
|
|||||||
export type Grade = 0 | 1 | 2 | 3
|
/** 天赋稀有度 */
|
||||||
|
export type TalentGrade = 0 | 1 | 2 | 3
|
||||||
|
|
||||||
export type Effect = {
|
/** 天赋效果 */
|
||||||
MNY?: number
|
export type TalentEffect = {
|
||||||
STR?: number
|
/** 额外家境 */
|
||||||
INT?: number
|
readonly MNY?: number
|
||||||
CHR?: number
|
/** 额外体质 */
|
||||||
SPR?: number
|
readonly STR?: number
|
||||||
|
/** 额外智力 */
|
||||||
|
readonly INT?: number
|
||||||
|
/** 额外颜值 */
|
||||||
|
readonly CHR?: number
|
||||||
|
/** 额外快乐 */
|
||||||
|
readonly SPR?: number
|
||||||
|
/** 额外随机属性 */
|
||||||
|
readonly RND?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 权重天赋 */
|
||||||
|
export type TalentWithWeight = [number, number]
|
||||||
|
|
||||||
|
/** 天赋盲盒 */
|
||||||
|
export type TalentReplacement = {
|
||||||
|
/** 指定列表盲盒 */
|
||||||
|
talent?: TalentWithWeight[]
|
||||||
|
/** 指定稀有度盲盒 */
|
||||||
|
grade?: TalentGrade[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 天赋 */
|
||||||
export type Talent = {
|
export type Talent = {
|
||||||
|
/** 序号 */
|
||||||
readonly id: number
|
readonly id: number
|
||||||
|
/** 天赋名 */
|
||||||
readonly name: string
|
readonly name: string
|
||||||
|
/** 天赋描述 */
|
||||||
readonly description: string
|
readonly description: string
|
||||||
readonly grade: number
|
/** 天赋触发条件 */
|
||||||
readonly effect?: Effect
|
readonly condition?: string
|
||||||
|
/** 天赋稀有度 */
|
||||||
|
readonly grade: TalentGrade
|
||||||
|
/** 天赋效果 */
|
||||||
|
readonly effect?: TalentEffect
|
||||||
|
/** 专属天赋 */
|
||||||
|
readonly exclusive?: boolean
|
||||||
|
/** 初始可用属性点调整 */
|
||||||
|
readonly status?: number
|
||||||
|
/** 互斥天赋 */
|
||||||
readonly exclude?: number[]
|
readonly exclude?: number[]
|
||||||
|
/** 天赋盲盒 */
|
||||||
|
readonly replacement?: TalentReplacement
|
||||||
}
|
}
|
||||||
// @vt-types-end
|
// @vt-types-end
|
||||||
|
|
||||||
export const transformers = {
|
export const transformers = {
|
||||||
id: Number,
|
id: Number,
|
||||||
grade: Number,
|
grade: (val: any) => Number(val) || 0,
|
||||||
exclude: (val: (string | number)[] | undefined) => val?.map(Number),
|
exclude: (val: (string | number)[] | undefined) => val?.map(Number),
|
||||||
effect: (val: any) => {
|
effect: (val: any) => {
|
||||||
if (!val) return
|
if (!val) return
|
||||||
@@ -31,4 +66,21 @@ export const transformers = {
|
|||||||
}
|
}
|
||||||
return val
|
return val
|
||||||
},
|
},
|
||||||
|
replacement: (val: any) => {
|
||||||
|
if (!val) return
|
||||||
|
if (val.talent)
|
||||||
|
val.talent = val.talent.map((v: string | number) => {
|
||||||
|
if (typeof v === 'number') return [v, 1]
|
||||||
|
const [talent, weight] = v.split('*').map(Number)
|
||||||
|
if (talent == null || isNaN(talent))
|
||||||
|
throw new Error(`Invalid talent value: ${v}`)
|
||||||
|
if (weight != null && isNaN(weight))
|
||||||
|
throw new Error(
|
||||||
|
`Invalid weight value: ${v} ${JSON.stringify({ talent, weight })}`,
|
||||||
|
)
|
||||||
|
return [talent, weight ?? 1]
|
||||||
|
})
|
||||||
|
if (val.grade) val.grade = val.grade.map(Number)
|
||||||
|
return val
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user