mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-08-28 09:16:47 +08:00
update: ts
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
dist
|
||||
node_modules
|
||||
~$*.xlsx
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "@remake/data",
|
||||
"type": "module",
|
||||
"version": "3.0.0",
|
||||
"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\" ",
|
||||
"lint": "eslint .",
|
||||
"test": "bun test"
|
||||
},
|
||||
"exports": {
|
||||
"./*": {
|
||||
"types": "./dist/*.ts",
|
||||
"import": "./dist/*.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
export type Grade = 0 | 1 | 2 | 3
|
||||
export type Opportunity =
|
||||
| 'START' // 分配完成点数,点击开始新人生后
|
||||
| 'TRAJECTORY' // 每一年的人生经历中
|
||||
| 'SUMMARY' // 人生结束,点击人生总结后
|
||||
| 'END' // 游戏完成,点击重开 重开次数在这之后才会+1
|
||||
export type Achievement = {
|
||||
/** 序号 */
|
||||
readonly id: number
|
||||
/** 成就名 */
|
||||
readonly name: string
|
||||
/** 成就文案 */
|
||||
readonly description: string
|
||||
/** 稀有度 */
|
||||
readonly grade: Grade
|
||||
/** 触发条件 */
|
||||
readonly condition: string
|
||||
/** 是否隐藏成就 */
|
||||
readonly hide: boolean
|
||||
/** 触发时机 */
|
||||
readonly opportunity: Opportunity
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
export type EventWithWeight = [number, number]
|
||||
export type Age = {
|
||||
/** 年龄 */
|
||||
readonly age: number
|
||||
/** 事件列表 */
|
||||
readonly event: EventWithWeight[]
|
||||
}
|
||||
// @vt-types-end
|
||||
|
||||
export const transformers = {
|
||||
event: (val: any) => {
|
||||
if (val === null || val === undefined)
|
||||
throw new Error(`Invalid event value: ${val}`)
|
||||
if (Array.isArray(val))
|
||||
return val.map(v => {
|
||||
switch (typeof v) {
|
||||
case 'number':
|
||||
return [v, 1]
|
||||
case 'string':
|
||||
const [event, weight] = v.split('*').map(Number)
|
||||
if (event == null || isNaN(event))
|
||||
throw new Error(`Invalid event value: ${v}`)
|
||||
if (weight != null && isNaN(weight))
|
||||
throw new Error(
|
||||
`Invalid weight value: ${v} ${JSON.stringify({ event, weight })}`,
|
||||
)
|
||||
return [event, weight ?? 1]
|
||||
default:
|
||||
throw new Error(`Invalid event value: ${v}`)
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,30 @@
|
||||
export type Property = {
|
||||
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 talent: number[]
|
||||
}
|
||||
// @vt-types-end
|
||||
|
||||
export const transformers = {
|
||||
id: Number,
|
||||
talent: (val: (string | number)[]) => val.map(Number),
|
||||
property: (val: any) => {
|
||||
if (val === null || val === undefined)
|
||||
throw new Error(`Invalid property value: ${JSON.stringify(val)}`)
|
||||
for (const key of ['CHR', 'INT', 'STR', 'MNY']) {
|
||||
val[key] = Number(val[key])
|
||||
if (isNaN(val[key]))
|
||||
throw new Error(`Invalid property value: ${key}=${val[key]}`)
|
||||
}
|
||||
return val
|
||||
},
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,38 @@
|
||||
export type Grade = 0 | 1 | 2 | 3
|
||||
|
||||
export type Effect = {
|
||||
MNY?: number
|
||||
STR?: number
|
||||
INT?: number
|
||||
CHR?: number
|
||||
SPR?: number
|
||||
LIF?: number
|
||||
}
|
||||
|
||||
export type Event = {
|
||||
/** ID */
|
||||
readonly id: number
|
||||
/** 事件列表 */
|
||||
readonly event: string
|
||||
readonly postEvent?: string
|
||||
readonly grade?: number
|
||||
readonly effect?: Effect
|
||||
readonly branch?: string[]
|
||||
readonly NoRandom?: boolean
|
||||
readonly include?: string
|
||||
readonly exclude?: string
|
||||
}
|
||||
// @vt-types-end
|
||||
|
||||
export const transformers = {
|
||||
id: Number,
|
||||
effect: (val: any) => {
|
||||
if (!val) return
|
||||
for (const key in val) {
|
||||
val[key] = Number(val[key])
|
||||
if (isNaN(val[key]))
|
||||
throw new Error(`Invalid property value: ${key}=${val[key]}`)
|
||||
}
|
||||
return val
|
||||
},
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
export type Group = 1 | 2
|
||||
export type SpecialThanks = {
|
||||
readonly group: Group
|
||||
readonly name: string
|
||||
readonly comment?: string
|
||||
readonly color?: string
|
||||
}
|
||||
// @vt-types-end
|
||||
|
||||
export const transformers = {
|
||||
group: Number,
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
export type Grade = 0 | 1 | 2 | 3
|
||||
|
||||
export type Effect = {
|
||||
MNY?: number
|
||||
STR?: number
|
||||
INT?: number
|
||||
CHR?: number
|
||||
SPR?: number
|
||||
}
|
||||
|
||||
export type Talent = {
|
||||
readonly id: number
|
||||
readonly name: string
|
||||
readonly description: string
|
||||
readonly grade: number
|
||||
readonly effect?: Effect
|
||||
readonly exclude?: number[]
|
||||
}
|
||||
// @vt-types-end
|
||||
|
||||
export const transformers = {
|
||||
id: Number,
|
||||
grade: Number,
|
||||
exclude: (val: (string | number)[] | undefined) => val?.map(Number),
|
||||
effect: (val: any) => {
|
||||
if (!val) return
|
||||
for (const key in val) {
|
||||
val[key] = Number(val[key])
|
||||
if (isNaN(val[key]))
|
||||
throw new Error(`Invalid property value: ${key}=${val[key]}`)
|
||||
}
|
||||
return val
|
||||
},
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
// Environment setup & latest features
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
"module": "Preserve",
|
||||
"moduleDetection": "force",
|
||||
"types": ["bun"],
|
||||
|
||||
// Bundler mode
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true,
|
||||
|
||||
// Best practices
|
||||
"strict": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
"noImplicitAny": true
|
||||
},
|
||||
"include": ["**/*"]
|
||||
}
|
||||
Reference in New Issue
Block a user