mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-30 02:36:11 +00:00
Don't update user info on save for optimization
This commit is contained in:
parent
4fcea107ab
commit
72b4552b01
@ -250,58 +250,52 @@ export class GameData {
|
|||||||
public saveSystem(): Promise<boolean> {
|
public saveSystem(): Promise<boolean> {
|
||||||
return new Promise<boolean>(resolve => {
|
return new Promise<boolean>(resolve => {
|
||||||
this.scene.ui.savingIcon.show();
|
this.scene.ui.savingIcon.show();
|
||||||
updateUserInfo().then(response => {
|
const data: SystemSaveData = {
|
||||||
if (!response[0]) {
|
trainerId: this.trainerId,
|
||||||
this.scene.ui.savingIcon.hide();
|
secretId: this.secretId,
|
||||||
return resolve(false);
|
gender: this.gender,
|
||||||
}
|
dexData: this.dexData,
|
||||||
const data: SystemSaveData = {
|
starterData: this.starterData,
|
||||||
trainerId: this.trainerId,
|
gameStats: this.gameStats,
|
||||||
secretId: this.secretId,
|
unlocks: this.unlocks,
|
||||||
gender: this.gender,
|
achvUnlocks: this.achvUnlocks,
|
||||||
dexData: this.dexData,
|
voucherUnlocks: this.voucherUnlocks,
|
||||||
starterData: this.starterData,
|
voucherCounts: this.voucherCounts,
|
||||||
gameStats: this.gameStats,
|
eggs: this.eggs.map(e => new EggData(e)),
|
||||||
unlocks: this.unlocks,
|
gameVersion: this.scene.game.config.gameVersion,
|
||||||
achvUnlocks: this.achvUnlocks,
|
timestamp: new Date().getTime()
|
||||||
voucherUnlocks: this.voucherUnlocks,
|
};
|
||||||
voucherCounts: this.voucherCounts,
|
|
||||||
eggs: this.eggs.map(e => new EggData(e)),
|
|
||||||
gameVersion: this.scene.game.config.gameVersion,
|
|
||||||
timestamp: new Date().getTime()
|
|
||||||
};
|
|
||||||
|
|
||||||
const maxIntAttrValue = Math.pow(2, 31);
|
const maxIntAttrValue = Math.pow(2, 31);
|
||||||
const systemData = JSON.stringify(data, (k: any, v: any) => typeof v === 'bigint' ? v <= maxIntAttrValue ? Number(v) : v.toString() : v);
|
const systemData = JSON.stringify(data, (k: any, v: any) => typeof v === 'bigint' ? v <= maxIntAttrValue ? Number(v) : v.toString() : v);
|
||||||
|
|
||||||
if (!bypassLogin) {
|
if (!bypassLogin) {
|
||||||
Utils.apiPost(`savedata/update?datatype=${GameDataType.SYSTEM}`, systemData, undefined, true)
|
Utils.apiPost(`savedata/update?datatype=${GameDataType.SYSTEM}`, systemData, undefined, true)
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(error => {
|
.then(error => {
|
||||||
this.scene.ui.savingIcon.hide();
|
this.scene.ui.savingIcon.hide();
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error.startsWith('client version out of date')) {
|
if (error.startsWith('client version out of date')) {
|
||||||
this.scene.clearPhaseQueue();
|
this.scene.clearPhaseQueue();
|
||||||
this.scene.unshiftPhase(new OutdatedPhase(this.scene));
|
this.scene.unshiftPhase(new OutdatedPhase(this.scene));
|
||||||
} else if (error.startsWith('session out of date')) {
|
} else if (error.startsWith('session out of date')) {
|
||||||
this.scene.clearPhaseQueue();
|
this.scene.clearPhaseQueue();
|
||||||
this.scene.unshiftPhase(new ReloadSessionPhase(this.scene));
|
this.scene.unshiftPhase(new ReloadSessionPhase(this.scene));
|
||||||
}
|
|
||||||
console.error(error);
|
|
||||||
return resolve(false);
|
|
||||||
}
|
}
|
||||||
resolve(true);
|
console.error(error);
|
||||||
});
|
return resolve(false);
|
||||||
} else {
|
}
|
||||||
localStorage.setItem('data_bak', localStorage.getItem('data'));
|
resolve(true);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
localStorage.setItem('data_bak', localStorage.getItem('data'));
|
||||||
|
|
||||||
localStorage.setItem('data', btoa(systemData));
|
localStorage.setItem('data', btoa(systemData));
|
||||||
|
|
||||||
this.scene.ui.savingIcon.hide();
|
this.scene.ui.savingIcon.hide();
|
||||||
|
|
||||||
resolve(true);
|
resolve(true);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user