mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
wip: migrate backend to new game package
This commit is contained in:
1 parent
1d843f7355
commit
1616f62755
94 files changed
+263
-3055
No files matched your search
@@ -8,7 +8,7 @@ export const questSchema = z.object({
|
||||
title: z.string(),
|
||||
image: z.string(),
|
||||
instruction: z.string(),
|
||||
requirements: requirementsSchema,
|
||||
requirements: requirementsSchema.default([]),
|
||||
stages: z.array(stageSchema),
|
||||
exceptions: z.array(globalExceptionSchema).optional(),
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const responseSchema = z.object({
|
||||
type: z.enum(['narrative', 'dialogue']),
|
||||
type: z.enum(['narrative', 'dialogue']).default('narrative'),
|
||||
content: z.string(),
|
||||
hint: z.string().optional(),
|
||||
})
|
||||
|
||||
@@ -2,11 +2,12 @@ import { z } from 'zod'
|
||||
import { conditionSchema } from './condition.js'
|
||||
import { responseSchema } from './response.js'
|
||||
import { stageExceptionSchema } from './exception.js'
|
||||
import { requirementsSchema } from './requirements.js'
|
||||
|
||||
export const stageSchema = z.object({
|
||||
id: z.string().regex(/^[a-zA-Z0-9_-]+$/),
|
||||
name: z.string().optional(),
|
||||
requirements: z.array(z.string()),
|
||||
requirements: requirementsSchema.default([]),
|
||||
condition: conditionSchema,
|
||||
response: responseSchema,
|
||||
exceptions: stageExceptionSchema.array().optional(),
|
||||
|
||||
@@ -30,7 +30,7 @@ export interface ISession {
|
||||
updatedAt: Date
|
||||
finishedAt?: Date
|
||||
lastActivityAt: Date
|
||||
stages: string[]
|
||||
completedEvents: string[]
|
||||
graph: INode
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ export const Session = model<ISession>(
|
||||
default: Date.now,
|
||||
required: true,
|
||||
},
|
||||
stages: [String],
|
||||
completedEvents: [String],
|
||||
graph: {
|
||||
type: nodeSchema,
|
||||
default: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
interface Node {
|
||||
_id: string
|
||||
id: string
|
||||
requirements: string[]
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export default class DAG {
|
||||
private layers: number[] = []
|
||||
|
||||
constructor(nodes: Node[]) {
|
||||
this.nodes = new Map(nodes.map((node) => [node._id, node]))
|
||||
this.nodes = new Map(nodes.map((node) => [node.id, node]))
|
||||
this.edges = new Set<[string, string]>()
|
||||
this.nodes.forEach((_, id) => {
|
||||
this.setLayer(id)
|
||||
|
||||
Reference in new issue
Block a user