Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
feat: Experimental save manager
Browse files Browse the repository at this point in the history
The save manager can manually be injected into the game to test saving the modern settings state into the game's save data.
  • Loading branch information
oliversalzburg committed Oct 13, 2022
1 parent 7acb594 commit ddb749e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/userscript/source/UserScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,24 @@ export class UserScript {
return this.engine.stateSerialize();
}

/**
* Experimental save manager for Kitten Game.
* It can be injected manually into the game to cause KS settings to be
* injected into the save blob.
*
* game.managers.push(kittenScientists.saveManager)
*/
get saveManager() {
return this._saveManager;
}

private _saveManager = {
save: (saveData: Record<string, unknown>) => {
cwarn("EXPERIMENTAL: Injecting Kitten Scientists settings into save data...");
saveData.ks = { state: [this.getSettings()] };
},
};

static async waitForGame(timeout = 30000): Promise<GamePage> {
const signals: Array<Promise<unknown>> = [sleep(2000)];

Expand Down

0 comments on commit ddb749e

Please sign in to comment.