mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Get rid of legacy 1.19 savegame logic
This commit is contained in:
parent
9e0193399f
commit
0974dee6d4
@ -29,7 +29,6 @@ export class RestrictionManager extends ReadWriteProxy {
|
||||
getDefaultData() {
|
||||
return {
|
||||
version: this.getCurrentVersion(),
|
||||
savegameV1119Imported: false,
|
||||
};
|
||||
}
|
||||
|
||||
@ -47,32 +46,20 @@ export class RestrictionManager extends ReadWriteProxy {
|
||||
}
|
||||
|
||||
initialize() {
|
||||
return this.readAsync().then(() => {
|
||||
if (this.currentData.savegameV1119Imported) {
|
||||
console.warn("Levelunlock is granted to current user due to past savegame");
|
||||
}
|
||||
});
|
||||
return this.readAsync();
|
||||
}
|
||||
|
||||
// -- End RW Proxy Impl
|
||||
|
||||
/**
|
||||
* Checks if there are any savegames from the 1.1.19 version
|
||||
*/
|
||||
onHasLegacySavegamesChanged(has119Savegames = false) {
|
||||
if (has119Savegames && !this.currentData.savegameV1119Imported) {
|
||||
this.currentData.savegameV1119Imported = true;
|
||||
console.warn("Current user now has access to all levels due to 1119 savegame");
|
||||
return this.writeAsync();
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the app is currently running as the limited version
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isLimitedVersion() {
|
||||
if (G_IS_STEAM_DEMO) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (G_IS_STANDALONE) {
|
||||
// Standalone is never limited
|
||||
return false;
|
||||
@ -135,7 +122,7 @@ export class RestrictionManager extends ReadWriteProxy {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
getHasExtendedUpgrades() {
|
||||
return !this.isLimitedVersion() || this.currentData.savegameV1119Imported;
|
||||
return !this.isLimitedVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,6 +130,6 @@ export class RestrictionManager extends ReadWriteProxy {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
getHasExtendedLevelsAndFreeplay() {
|
||||
return !this.isLimitedVersion() || this.currentData.savegameV1119Imported;
|
||||
return !this.isLimitedVersion();
|
||||
}
|
||||
}
|
||||
|
@ -89,14 +89,6 @@ export class SavegameManager extends ReadWriteProxy {
|
||||
return new Savegame(this.app, { internalId, metaDataRef: metadata });
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if this manager has any savegame of a 1.1.19 version, which
|
||||
* enables all levels
|
||||
*/
|
||||
getHasAnyLegacySavegames() {
|
||||
return this.currentData.savegames.some(savegame => savegame.version === 1005 || savegame.level > 14);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a savegame
|
||||
* @param {SavegameMetadata} game
|
||||
@ -167,9 +159,6 @@ export class SavegameManager extends ReadWriteProxy {
|
||||
importSavegame(data) {
|
||||
const savegame = this.createNewSavegame();
|
||||
|
||||
// Track legacy savegames
|
||||
const isOldSavegame = data.version < 1006;
|
||||
|
||||
const migrationResult = savegame.migrate(data);
|
||||
if (migrationResult.isBad()) {
|
||||
return Promise.reject("Failed to migrate: " + migrationResult.reason);
|
||||
@ -181,19 +170,14 @@ export class SavegameManager extends ReadWriteProxy {
|
||||
return Promise.reject("Verification failed: " + verification.result);
|
||||
}
|
||||
|
||||
return savegame
|
||||
.writeSavegameAndMetadata()
|
||||
.then(() => this.updateAfterSavegamesChanged())
|
||||
.then(() => this.app.restrictionMgr.onHasLegacySavegamesChanged(isOldSavegame));
|
||||
return savegame.writeSavegameAndMetadata().then(() => this.updateAfterSavegamesChanged());
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook after the savegames got changed
|
||||
*/
|
||||
updateAfterSavegamesChanged() {
|
||||
return this.sortSavegames()
|
||||
.then(() => this.writeAsync())
|
||||
.then(() => this.app.restrictionMgr.onHasLegacySavegamesChanged(this.getHasAnyLegacySavegames()));
|
||||
return this.sortSavegames().then(() => this.writeAsync());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user