refactor: remove unused quest-related schemas and consolidate exports

This commit is contained in:
Justin Lin committed 2025-04-21 21:42:54 +08:00
1 parent d2cdd1304a
commit 1d843f7355
29 files changed
+35 -161

No files matched your search

+1
View File
@@ -14,6 +14,7 @@
},
"dependencies": {
"@linux-odyssey/constants": "*",
"@linux-odyssey/game": "*",
"@linux-odyssey/file-graph": "*",
"@linux-odyssey/models": "*",
"@linux-odyssey/utils": "*",
+5 -5
View File
@@ -3,7 +3,7 @@ import fs from 'fs/promises'
import path from 'path'
import yaml from 'yaml'
import { Quest, questSchema } from '@linux-odyssey/constants'
import { questSchema, globalExceptionSchema, IQuest } from '@linux-odyssey/game'
import logger from '../utils/logger.js'
class QuestValidationError extends Error {
@@ -19,7 +19,7 @@ class QuestValidationError extends Error {
}
class QuestManager {
private quests = new Map<string, Quest>()
private quests = new Map<string, IQuest>()
private questDirectory = path.join(process.cwd(), '..', 'quests')
get(id: string) {
@@ -51,11 +51,11 @@ class QuestManager {
private async loadGlobalExceptions() {
const exceptionsPath = path.join(this.questDirectory, 'exceptions.yml')
const body = await fs.readFile(exceptionsPath, 'utf-8')
return yaml.parse(body)
return globalExceptionSchema.array().parse(yaml.parse(body))
}
async loadAndUpdateQuests() {
const { exceptions } = await this.loadGlobalExceptions()
const exceptions = await this.loadGlobalExceptions()
return this.mapQuests(async (id, questPath) => {
const files = await fs.readdir(questPath)
if (!files.includes('game.yml')) {
@@ -78,7 +78,7 @@ class QuestManager {
image,
...questData,
})
quest.exceptions.push(...exceptions)
quest.exceptions = [...exceptions]
this.quests.set(id, quest)
} catch (error) {
logger.error(`Error parsing quest ${id}`, { error })