mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
refactor: update file-graph package structure and integrate with game session management
This commit is contained in:
1 parent
92173bb7e9
commit
cfbc386c16
9 files changed
+44
-10
No files matched your search
@@ -1,5 +1,4 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { Session } from '../types'
|
|
||||||
|
|
||||||
const api = axios.create({
|
const api = axios.create({
|
||||||
baseURL: '/api/v1',
|
baseURL: '/api/v1',
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "@linux-odyssey/file-graph",
|
"name": "@linux-odyssey/file-graph",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"type": "module",
|
"main": "./dist/cjs/index.js",
|
||||||
"main": "dist/index.js",
|
"types": "./dist/types/index.d.ts",
|
||||||
"types": "dist/index.d.ts",
|
"exports": {
|
||||||
"exports": "./dist/index.js",
|
".": {
|
||||||
|
"require": "./dist/cjs/index.js",
|
||||||
|
"types": "./dist/types/index.d.ts"
|
||||||
|
}
|
||||||
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc -p tsconfig.cjs.json",
|
||||||
"dev": "tsc -w",
|
"dev": "tsc -w",
|
||||||
"test": "yarn build && jest"
|
"test": "yarn build && jest"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
export { default as File, FileObject } from './file.js'
|
export { default as File, FileObject } from './file.js'
|
||||||
export { default as FileNode } from './fileNode.js'
|
export { default as FileNode } from './fileNode.js'
|
||||||
export { default as FileGraph, Event } from './fileGraph.js'
|
export { default as FileGraph, Event } from './fileGraph.js'
|
||||||
|
|
||||||
|
export interface INode {
|
||||||
|
path: string
|
||||||
|
type: string
|
||||||
|
discovered: boolean
|
||||||
|
children?: INode[]
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "CommonJS",
|
||||||
|
"moduleResolution": "Node",
|
||||||
|
"outDir": "./dist/cjs",
|
||||||
|
"declarationDir": "./dist/types"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,9 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"composite": true,
|
"composite": true,
|
||||||
"outDir": "./dist"
|
"module": "NodeNext",
|
||||||
|
"outDir": "./dist/esm",
|
||||||
|
"declarationDir": "./dist/types"
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": ["src"],
|
||||||
"exclude": ["node_modules", "dist"]
|
"exclude": ["node_modules", "dist"]
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"build": "tsc -b"
|
"build": "tsc -b"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@linux-odyssey/file-graph": "*",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { FileGraph, INode } from '@linux-odyssey/file-graph'
|
||||||
import { Quest } from './Quest'
|
import { Quest } from './Quest'
|
||||||
import {
|
import {
|
||||||
IQuest,
|
IQuest,
|
||||||
@@ -8,17 +9,19 @@ import {
|
|||||||
ITask,
|
ITask,
|
||||||
} from './schema'
|
} from './schema'
|
||||||
|
|
||||||
export class GameSession implements ISession {
|
export class GameSession {
|
||||||
private completed: string[] = []
|
private completed: string[] = []
|
||||||
private quest: Quest
|
private quest: Quest
|
||||||
|
private graph: FileGraph
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{ completedEvents }: ISession,
|
{ completedEvents, graph }: ISession,
|
||||||
quest: IQuest,
|
quest: IQuest,
|
||||||
checker: IFileExistenceChecker
|
checker: IFileExistenceChecker
|
||||||
) {
|
) {
|
||||||
this.completed = completedEvents
|
this.completed = completedEvents
|
||||||
this.quest = new Quest(quest, checker)
|
this.quest = new Quest(quest, checker)
|
||||||
|
this.graph = new FileGraph(graph)
|
||||||
}
|
}
|
||||||
|
|
||||||
get completedEvents() {
|
get completedEvents() {
|
||||||
@@ -48,4 +51,8 @@ export class GameSession implements ISession {
|
|||||||
getTasks(): ITask[] {
|
getTasks(): ITask[] {
|
||||||
return this.quest.getTasks(this.completed)
|
return this.quest.getTasks(this.completed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getGraph(): INode {
|
||||||
|
return this.graph
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { INode } from '@linux-odyssey/file-graph'
|
||||||
|
|
||||||
export * from './condition.js'
|
export * from './condition.js'
|
||||||
export * from './stage.js'
|
export * from './stage.js'
|
||||||
export * from './requirements.js'
|
export * from './requirements.js'
|
||||||
@@ -14,6 +16,7 @@ export interface ICommand {
|
|||||||
|
|
||||||
export interface ISession {
|
export interface ISession {
|
||||||
completedEvents: string[]
|
completedEvents: string[]
|
||||||
|
graph: INode
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITask {
|
export interface ITask {
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"composite": true
|
"composite": true,
|
||||||
|
"module": "CommonJS",
|
||||||
|
"moduleResolution": "Node"
|
||||||
},
|
},
|
||||||
"include": ["src"]
|
"include": ["src"]
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user