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() {
|
getDefaultData() {
|
||||||
return {
|
return {
|
||||||
version: this.getCurrentVersion(),
|
version: this.getCurrentVersion(),
|
||||||
savegameV1119Imported: false,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,32 +46,20 @@ export class RestrictionManager extends ReadWriteProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
return this.readAsync().then(() => {
|
return this.readAsync();
|
||||||
if (this.currentData.savegameV1119Imported) {
|
|
||||||
console.warn("Levelunlock is granted to current user due to past savegame");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- End RW Proxy Impl
|
// -- 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 if the app is currently running as the limited version
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isLimitedVersion() {
|
isLimitedVersion() {
|
||||||
|
if (G_IS_STEAM_DEMO) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (G_IS_STANDALONE) {
|
if (G_IS_STANDALONE) {
|
||||||
// Standalone is never limited
|
// Standalone is never limited
|
||||||
return false;
|
return false;
|
||||||
@ -135,7 +122,7 @@ export class RestrictionManager extends ReadWriteProxy {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
getHasExtendedUpgrades() {
|
getHasExtendedUpgrades() {
|
||||||
return !this.isLimitedVersion() || this.currentData.savegameV1119Imported;
|
return !this.isLimitedVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,6 +130,6 @@ export class RestrictionManager extends ReadWriteProxy {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
getHasExtendedLevelsAndFreeplay() {
|
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 });
|
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
|
* Deletes a savegame
|
||||||
* @param {SavegameMetadata} game
|
* @param {SavegameMetadata} game
|
||||||
@ -167,9 +159,6 @@ export class SavegameManager extends ReadWriteProxy {
|
|||||||
importSavegame(data) {
|
importSavegame(data) {
|
||||||
const savegame = this.createNewSavegame();
|
const savegame = this.createNewSavegame();
|
||||||
|
|
||||||
// Track legacy savegames
|
|
||||||
const isOldSavegame = data.version < 1006;
|
|
||||||
|
|
||||||
const migrationResult = savegame.migrate(data);
|
const migrationResult = savegame.migrate(data);
|
||||||
if (migrationResult.isBad()) {
|
if (migrationResult.isBad()) {
|
||||||
return Promise.reject("Failed to migrate: " + migrationResult.reason);
|
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 Promise.reject("Verification failed: " + verification.result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return savegame
|
return savegame.writeSavegameAndMetadata().then(() => this.updateAfterSavegamesChanged());
|
||||||
.writeSavegameAndMetadata()
|
|
||||||
.then(() => this.updateAfterSavegamesChanged())
|
|
||||||
.then(() => this.app.restrictionMgr.onHasLegacySavegamesChanged(isOldSavegame));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook after the savegames got changed
|
* Hook after the savegames got changed
|
||||||
*/
|
*/
|
||||||
updateAfterSavegamesChanged() {
|
updateAfterSavegamesChanged() {
|
||||||
return this.sortSavegames()
|
return this.sortSavegames().then(() => this.writeAsync());
|
||||||
.then(() => this.writeAsync())
|
|
||||||
.then(() => this.app.restrictionMgr.onHasLegacySavegamesChanged(this.getHasAnyLegacySavegames()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user