|
|
|
import { BaseSavegameInterface } from "./savegame_interface";
|
|
|
|
import { SavegameInterface_V1000 } from "./schemas/1000";
|
|
|
|
import { createLogger } from "../core/logging";
|
|
|
|
import { SavegameInterface_V1001 } from "./schemas/1001";
|
|
|
|
import { SavegameInterface_V1002 } from "./schemas/1002";
|
|
|
|
import { SavegameInterface_V1003 } from "./schemas/1003";
|
|
|
|
import { SavegameInterface_V1004 } from "./schemas/1004";
|
|
|
|
import { SavegameInterface_V1005 } from "./schemas/1005";
|
|
|
|
import { SavegameInterface_V1006 } from "./schemas/1006";
|
|
|
|
import { SavegameInterface_V1007 } from "./schemas/1007";
|
Achievements (#1087)
* [WIP] Add boilerplate for achievement implementation
* Add config.local.template.js and rm cached copy of config.local.js
* [WIP] Implement painting, cutting, rotating achievements (to log only)
* [WIP] Refactor achievements, jsdoc fixes, add npm script
- Refactor achievements to make use of Signals
- Move implemented achievement interfaces to appropriate
platform folders (SteamAchievements in currently in use
in browser wrapper for testing)
- Fix invalid jsdocs
- Add dev-standalone script to package.json scripts
* Add steam/greenworks IPC calls and optional private-artifact dependency
* Include private artifacts in standalone builds
* Uncomment appid include
* [WIP] Add steam overlay fix, add hash to artifact dependency
* Update electron, greenworks. Add task to add local config if not present
* Add more achievements, refactor achievement code
* Add receiver flexibility and more achievements
- Add check to see if necessary to create achievement and add receiver
- Add remove receiver functionality when achievement is unlocked
* Add achievements and accommodations for switching states
- Fix startup code to avoid clobbering achievements on state switch
- Add a few more achievements
* Add achievements, ids. Update names, keys for consistency
* Add play time achievements
* [WIP] Add more achievements
* Add more achievements. Add bulk achievement check signal
* [WIP] Add achievements. Start savefile migration
* Add achievements. Add savefile migration
* Remove superfluous achievement stat
* Update lock files, fix merge conflict
3 years ago
|
|
|
import { SavegameInterface_V1008 } from "./schemas/1008";
|
|
|
|
|
|
|
|
/** @type {Object.<number, typeof BaseSavegameInterface>} */
|
|
|
|
export const savegameInterfaces = {
|
|
|
|
1000: SavegameInterface_V1000,
|
|
|
|
1001: SavegameInterface_V1001,
|
|
|
|
1002: SavegameInterface_V1002,
|
|
|
|
1003: SavegameInterface_V1003,
|
|
|
|
1004: SavegameInterface_V1004,
|
|
|
|
1005: SavegameInterface_V1005,
|
|
|
|
1006: SavegameInterface_V1006,
|
|
|
|
1007: SavegameInterface_V1007,
|
Achievements (#1087)
* [WIP] Add boilerplate for achievement implementation
* Add config.local.template.js and rm cached copy of config.local.js
* [WIP] Implement painting, cutting, rotating achievements (to log only)
* [WIP] Refactor achievements, jsdoc fixes, add npm script
- Refactor achievements to make use of Signals
- Move implemented achievement interfaces to appropriate
platform folders (SteamAchievements in currently in use
in browser wrapper for testing)
- Fix invalid jsdocs
- Add dev-standalone script to package.json scripts
* Add steam/greenworks IPC calls and optional private-artifact dependency
* Include private artifacts in standalone builds
* Uncomment appid include
* [WIP] Add steam overlay fix, add hash to artifact dependency
* Update electron, greenworks. Add task to add local config if not present
* Add more achievements, refactor achievement code
* Add receiver flexibility and more achievements
- Add check to see if necessary to create achievement and add receiver
- Add remove receiver functionality when achievement is unlocked
* Add achievements and accommodations for switching states
- Fix startup code to avoid clobbering achievements on state switch
- Add a few more achievements
* Add achievements, ids. Update names, keys for consistency
* Add play time achievements
* [WIP] Add more achievements
* Add more achievements. Add bulk achievement check signal
* [WIP] Add achievements. Start savefile migration
* Add achievements. Add savefile migration
* Remove superfluous achievement stat
* Update lock files, fix merge conflict
3 years ago
|
|
|
1008: SavegameInterface_V1008,
|
|
|
|
};
|
|
|
|
|
|
|
|
const logger = createLogger("savegame_interface_registry");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if the given savegame has any supported interface
|
|
|
|
* @param {any} savegame
|
|
|
|
* @returns {BaseSavegameInterface|null}
|
|
|
|
*/
|
|
|
|
export function getSavegameInterface(savegame) {
|
|
|
|
if (!savegame || !savegame.version) {
|
|
|
|
logger.warn("Savegame does not contain a valid version (undefined)");
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
const version = savegame.version;
|
|
|
|
if (!Number.isInteger(version)) {
|
|
|
|
logger.warn("Savegame does not contain a valid version (non-integer):", version);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const interfaceClass = savegameInterfaces[version];
|
|
|
|
if (!interfaceClass) {
|
|
|
|
logger.warn("Version", version, "has no implemented interface!");
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new interfaceClass(savegame);
|
|
|
|
}
|