feat: load responses and tasks from existing session

This commit is contained in:
Justin Lin committed 2025-04-23 16:17:10 +08:00
1 parent 2fcca0c4b9
commit b4b8f8baee
9 files changed
+52 -28

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@ import {
ITask,
} from './schema'
export class Session implements ISession {
export class GameSession implements ISession {
private completed: string[] = []
private quest: Quest
+7
View File
@@ -35,3 +35,10 @@ export const conditionSchema: z.ZodType<ICondition> =
export interface IFileExistenceChecker {
exists(file: IFileInput): Promise<boolean>
}
export class VoidFileExistenceChecker implements IFileExistenceChecker {
// eslint-disable-next-line class-methods-use-this
async exists(_file: IFileInput): Promise<boolean> {
return false
}
}
+4 -4
View File
@@ -1,6 +1,6 @@
import { expect, it, describe } from '@jest/globals'
import { IQuest } from '../src/schema'
import { Session } from '../src/Session'
import { GameSession } from '../src/Session'
import { MockFileChecker } from './asyncCondition.test'
const quest: IQuest = {
@@ -65,7 +65,7 @@ const quest: IQuest = {
describe('exceptions', () => {
it('should return the stage exception', async () => {
const session = new Session(
const session = new GameSession(
{ completedEvents: [] },
quest,
new MockFileChecker()
@@ -76,7 +76,7 @@ describe('exceptions', () => {
})
it('should return the catch all exception', async () => {
const session = new Session(
const session = new GameSession(
{ completedEvents: [] },
quest,
new MockFileChecker()
@@ -87,7 +87,7 @@ describe('exceptions', () => {
})
it('should return the global exception', async () => {
const session = new Session(
const session = new GameSession(
{ completedEvents: [] },
quest,
new MockFileChecker()
+5 -5
View File
@@ -1,6 +1,6 @@
import { expect, describe, it } from '@jest/globals'
import { IQuest } from '../src/schema'
import { Session } from '../src/Session'
import { GameSession } from '../src/Session'
import { MockFileChecker } from './asyncCondition.test'
const quest: IQuest = {
@@ -64,7 +64,7 @@ const quest: IQuest = {
describe('Session', () => {
it('should return active stages', () => {
const session = new Session(
const session = new GameSession(
{
completedEvents: [],
},
@@ -84,7 +84,7 @@ describe('Session', () => {
})
it('should run command', async () => {
const session = new Session(
const session = new GameSession(
{
completedEvents: [],
},
@@ -111,7 +111,7 @@ describe('Session', () => {
})
it('should return all responses', () => {
const session = new Session(
const session = new GameSession(
{
completedEvents: ['stage1'],
},
@@ -135,7 +135,7 @@ describe('Session', () => {
})
it('should return tasks', () => {
const session = new Session(
const session = new GameSession(
{
completedEvents: [],
},