mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
feat: add isFinished method to GameSession and update commandController to handle session completion
This commit is contained in:
1 parent
cfbc386c16
commit
52e9a13645
2 files changed
+7
-2
No files matched your search
@@ -44,6 +44,10 @@ export class GameSession {
|
|||||||
return stageId
|
return stageId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isFinished() {
|
||||||
|
return this.getActiveStages().length === 0
|
||||||
|
}
|
||||||
|
|
||||||
getResponses(): IResponse[] {
|
getResponses(): IResponse[] {
|
||||||
return this.quest.getResponses(this.completed)
|
return this.quest.getResponses(this.completed)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,10 +60,11 @@ export const newCommand = asyncHandler(async (req: Request, res: Response) => {
|
|||||||
await c.save()
|
await c.save()
|
||||||
|
|
||||||
session.completedEvents = gameSession.completedEvents
|
session.completedEvents = gameSession.completedEvents
|
||||||
await session.save()
|
|
||||||
|
|
||||||
if ((session.status as string) === 'finished') {
|
if (gameSession.isFinished()) {
|
||||||
await finishSession(session)
|
await finishSession(session)
|
||||||
|
} else {
|
||||||
|
await session.save()
|
||||||
}
|
}
|
||||||
pushToSession(session.id, 'update', {
|
pushToSession(session.id, 'update', {
|
||||||
responses: gameSession.getResponses(),
|
responses: gameSession.getResponses(),
|
||||||
|
|||||||
Reference in new issue
Block a user