Add Ink session recovery and Coolify Docker support
This commit is contained in:
Vendored
+2
@@ -16,7 +16,9 @@ export declare class InkEngine {
|
||||
newGame(): TurnResult;
|
||||
chooseChoice(choiceIndex: number): TurnResult;
|
||||
saveGame(): string;
|
||||
resumeGame(savedState: string): void;
|
||||
loadGame(savedState: string): TurnResult;
|
||||
private restoreState;
|
||||
private loadStory;
|
||||
private continueStory;
|
||||
private getChoiceTags;
|
||||
|
||||
Vendored
+7
-1
@@ -90,7 +90,14 @@ class InkEngine {
|
||||
nextTurnId: this.nextTurnId,
|
||||
});
|
||||
}
|
||||
resumeGame(savedState) {
|
||||
this.restoreState(savedState);
|
||||
}
|
||||
loadGame(savedState) {
|
||||
this.restoreState(savedState);
|
||||
return this.continueStory();
|
||||
}
|
||||
restoreState(savedState) {
|
||||
this.story = this.loadStory();
|
||||
let inkState = savedState;
|
||||
try {
|
||||
@@ -106,7 +113,6 @@ class InkEngine {
|
||||
// Backward compatibility with raw Ink state JSON.
|
||||
}
|
||||
this.story.state.LoadJson(inkState);
|
||||
return this.continueStory();
|
||||
}
|
||||
loadStory() {
|
||||
const resolvedPath = path_1.default.resolve(this.storyPath);
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+19
@@ -147,6 +147,25 @@ async function handleGameApi(socket, method, args) {
|
||||
socket.emit('gameLoaded', { slot });
|
||||
return { success: true, result: true, running: true, slot };
|
||||
}
|
||||
case 'resumeGame':
|
||||
case 'resumeGame()': {
|
||||
const browserSave = typeof args[0] === 'string' ? args[0] : null;
|
||||
if (!browserSave) {
|
||||
return { success: false, error: 'missing_state', result: false };
|
||||
}
|
||||
const engine = new ink_engine_1.InkEngine(getStoryPath());
|
||||
engine.resumeGame(browserSave);
|
||||
sessions.set(socket.id, engine);
|
||||
return { success: true, result: true, running: engine.isRunning() };
|
||||
}
|
||||
case 'exportGameState':
|
||||
case 'exportGameState()': {
|
||||
const engine = sessions.get(socket.id);
|
||||
if (!engine?.isRunning()) {
|
||||
return { success: false, error: 'game_not_running', result: false };
|
||||
}
|
||||
return { success: true, result: true, savedState: engine.saveGame() };
|
||||
}
|
||||
case 'saveGame':
|
||||
case 'saveGame()': {
|
||||
const engine = sessions.get(socket.id);
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user