mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-25 00:39:27 +02:00
potential fix for failed save with rental pokemon
This commit is contained in:
parent
077fe56cca
commit
8818c91f84
@ -1188,16 +1188,23 @@ export class GameData {
|
|||||||
|
|
||||||
tryClearSession(scene: BattleScene, slotId: integer): Promise<[success: boolean, newClear: boolean]> {
|
tryClearSession(scene: BattleScene, slotId: integer): Promise<[success: boolean, newClear: boolean]> {
|
||||||
return new Promise<[boolean, boolean]>(resolve => {
|
return new Promise<[boolean, boolean]>(resolve => {
|
||||||
// if (bypassLogin) {
|
if (bypassLogin) {
|
||||||
// localStorage.removeItem(`sessionData${slotId ? slotId : ""}_${loggedInUser?.username}`);
|
localStorage.removeItem(`sessionData${slotId ? slotId : ""}_${loggedInUser?.username}`);
|
||||||
// return resolve([true, true]);
|
return resolve([true, true]);
|
||||||
// }
|
}
|
||||||
|
|
||||||
updateUserInfo().then(success => {
|
updateUserInfo().then(success => {
|
||||||
if (success !== null && !success) {
|
if (success !== null && !success) {
|
||||||
return resolve([false, false]);
|
return resolve([false, false]);
|
||||||
}
|
}
|
||||||
const sessionData = this.getSessionSaveData(scene);
|
const sessionData = this.getSessionSaveData(scene);
|
||||||
|
|
||||||
|
// Filter out any "rental" Pokemon from the player's team that were used for the run
|
||||||
|
sessionData.party = sessionData.party.filter(p => {
|
||||||
|
const speciesRootForm = getPokemonSpecies(p.species).getRootSpeciesId();
|
||||||
|
return !!this.scene.gameData.dexData[speciesRootForm].caughtAttr;
|
||||||
|
});
|
||||||
|
|
||||||
Utils.apiPost(`savedata/session/clear?slot=${slotId}&trainerId=${this.trainerId}&secretId=${this.secretId}&clientSessionId=${clientSessionId}`, JSON.stringify(sessionData), undefined, true).then(response => {
|
Utils.apiPost(`savedata/session/clear?slot=${slotId}&trainerId=${this.trainerId}&secretId=${this.secretId}&clientSessionId=${clientSessionId}`, JSON.stringify(sessionData), undefined, true).then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
loggedInUser!.lastSessionSlot = -1; // TODO: is the bang correct?
|
loggedInUser!.lastSessionSlot = -1; // TODO: is the bang correct?
|
||||||
@ -1718,7 +1725,7 @@ export class GameData {
|
|||||||
* @param count
|
* @param count
|
||||||
*/
|
*/
|
||||||
addStarterCandy(species: PokemonSpecies, count: integer): void {
|
addStarterCandy(species: PokemonSpecies, count: integer): void {
|
||||||
// Only gain candies if the Pokemon has already been marked as caught in dex (ignore "rental" pokemon
|
// Only gain candies if the Pokemon has already been marked as caught in dex (ignore "rental" pokemon)
|
||||||
const speciesRootForm = species.getRootSpeciesId();
|
const speciesRootForm = species.getRootSpeciesId();
|
||||||
if (!!this.scene.gameData.dexData[speciesRootForm].caughtAttr) {
|
if (!!this.scene.gameData.dexData[speciesRootForm].caughtAttr) {
|
||||||
this.scene.candyBar.showStarterSpeciesCandy(species.speciesId, count);
|
this.scene.candyBar.showStarterSpeciesCandy(species.speciesId, count);
|
||||||
|
Loading…
Reference in New Issue
Block a user