mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-08-19 18:43:53 +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' // 分配完成点数,点击开始新人生后
|
||||
| 'TRAJECTORY' // 每一年的人生经历中
|
||||
| 'SUMMARY' // 人生结束,点击人生总结后
|
||||
| 'END' // 游戏完成,点击重开 重开次数在这之后才会+1
|
||||
|
||||
/** 成就 */
|
||||
export type Achievement = {
|
||||
/** 序号 */
|
||||
readonly id: number
|
||||
@@ -12,11 +17,17 @@ export type Achievement = {
|
||||
/** 成就文案 */
|
||||
readonly description: string
|
||||
/** 稀有度 */
|
||||
readonly grade: Grade
|
||||
readonly grade: AchievementGrade
|
||||
/** 触发条件 */
|
||||
readonly condition: string
|
||||
/** 是否隐藏成就 */
|
||||
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 Age = {
|
||||
/** 年龄 */
|
||||
readonly age: number
|
||||
/** 事件列表 */
|
||||
/** 事件池 */
|
||||
readonly event: EventWithWeight[]
|
||||
}
|
||||
// @vt-types-end
|
||||
|
||||
export const transformers = {
|
||||
age: Number,
|
||||
event: (val: any) => {
|
||||
if (val === null || val === undefined)
|
||||
throw new Error(`Invalid event value: ${val}`)
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
export type Property = {
|
||||
/** 人物属性 */
|
||||
export type CharacterProperty = {
|
||||
/** 颜值 */
|
||||
readonly CHR: number
|
||||
/** 智力 */
|
||||
readonly INT: number
|
||||
/** 体质 */
|
||||
readonly STR: number
|
||||
/** 家境 */
|
||||
readonly MNY: number
|
||||
}
|
||||
|
||||
/** 人物 */
|
||||
export type Character = {
|
||||
/** ID */
|
||||
/** 序号 */
|
||||
readonly id: number
|
||||
/** 事件列表 */
|
||||
/** 人名 */
|
||||
readonly name: string
|
||||
readonly property: Property
|
||||
/** 属性 */
|
||||
readonly property: CharacterProperty
|
||||
/** 天赋 */
|
||||
readonly talent: number[]
|
||||
}
|
||||
// @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
|
||||
STR?: number
|
||||
INT?: number
|
||||
CHR?: number
|
||||
SPR?: number
|
||||
LIF?: number
|
||||
/** 事件效果 */
|
||||
export type EventEffect = {
|
||||
/** 颜值变化 */
|
||||
readonly CHR?: number
|
||||
/** 智力变化 */
|
||||
readonly INT?: number
|
||||
/** 体质变化 */
|
||||
readonly STR?: number
|
||||
/** 家境变化 */
|
||||
readonly MNY?: number
|
||||
/** 快乐变化 */
|
||||
readonly SPR?: number
|
||||
/** 寿命变化 */
|
||||
readonly LIF?: number
|
||||
/** 年龄变化 */
|
||||
readonly AGE?: number
|
||||
}
|
||||
|
||||
/** 事件 */
|
||||
export type Event = {
|
||||
/** ID */
|
||||
readonly id: number
|
||||
/** 事件列表 */
|
||||
/** 事件内容 */
|
||||
readonly event: string
|
||||
/** 事件稀有度 */
|
||||
readonly grade: EventGrade
|
||||
/** 追加事件内容 */
|
||||
readonly postEvent?: string
|
||||
readonly grade?: number
|
||||
readonly effect?: Effect
|
||||
readonly branch?: string[]
|
||||
/** 事件效果 */
|
||||
readonly effect?: EventEffect
|
||||
/** 非随机事件 */
|
||||
readonly NoRandom?: boolean
|
||||
/** 有某事件时才能被随机到 */
|
||||
readonly include?: string
|
||||
/** 有某事件时一定随机不到 */
|
||||
readonly exclude?: string
|
||||
/** 分支路线 */
|
||||
readonly branch?: string[]
|
||||
}
|
||||
// @vt-types-end
|
||||
|
||||
export const transformers = {
|
||||
id: Number,
|
||||
// 默认稀有度为0
|
||||
grade: (val: any) => Number(val) || 0,
|
||||
effect: (val: any) => {
|
||||
if (!val) return
|
||||
for (const key in val) {
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
export type Group = 1 | 2
|
||||
/** 特别鸣谢分组 */
|
||||
export type SpecialThanksGroup = 1 | 2
|
||||
|
||||
/** 特别鸣谢 */
|
||||
export type SpecialThanks = {
|
||||
readonly group: Group
|
||||
/** 特别鸣谢分组 */
|
||||
readonly group: SpecialThanksGroup
|
||||
/** 名字 */
|
||||
readonly name: string
|
||||
/** 喊话 */
|
||||
readonly comment?: string
|
||||
/** 颜色 */
|
||||
readonly color?: string
|
||||
}
|
||||
// @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
|
||||
STR?: number
|
||||
INT?: number
|
||||
CHR?: number
|
||||
SPR?: number
|
||||
/** 天赋效果 */
|
||||
export type TalentEffect = {
|
||||
/** 额外家境 */
|
||||
readonly MNY?: 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 = {
|
||||
/** 序号 */
|
||||
readonly id: number
|
||||
/** 天赋名 */
|
||||
readonly name: 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 replacement?: TalentReplacement
|
||||
}
|
||||
// @vt-types-end
|
||||
|
||||
export const transformers = {
|
||||
id: Number,
|
||||
grade: Number,
|
||||
grade: (val: any) => Number(val) || 0,
|
||||
exclude: (val: (string | number)[] | undefined) => val?.map(Number),
|
||||
effect: (val: any) => {
|
||||
if (!val) return
|
||||
@@ -31,4 +66,21 @@ export const transformers = {
|
||||
}
|
||||
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