mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-04-24 18:44:42 +01:00
[P3 Bug] Run History function saves the most-recent session data possible (#3838)
Co-authored-by: frutescens <info@laptop>
This commit is contained in:
parent
447d47ef47
commit
e0bcb2ef27
@ -1,19 +1,19 @@
|
|||||||
import { clientSessionId } from "#app/account.js";
|
import { clientSessionId } from "#app/account";
|
||||||
import BattleScene from "#app/battle-scene.js";
|
import BattleScene from "#app/battle-scene";
|
||||||
import { BattleType } from "#app/battle.js";
|
import { BattleType } from "#app/battle";
|
||||||
import { miscDialogue, getCharVariantFromDialogue } from "#app/data/dialogue.js";
|
import { miscDialogue, getCharVariantFromDialogue } from "#app/data/dialogue";
|
||||||
import { pokemonEvolutions } from "#app/data/pokemon-evolutions.js";
|
import { pokemonEvolutions } from "#app/data/pokemon-evolutions";
|
||||||
import PokemonSpecies, { getPokemonSpecies } from "#app/data/pokemon-species.js";
|
import PokemonSpecies, { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||||
import { trainerConfigs } from "#app/data/trainer-config.js";
|
import { trainerConfigs } from "#app/data/trainer-config";
|
||||||
import { PlayerGender } from "#app/enums/player-gender.js";
|
import { PlayerGender } from "#app/enums/player-gender";
|
||||||
import { TrainerType } from "#app/enums/trainer-type.js";
|
import { TrainerType } from "#app/enums/trainer-type";
|
||||||
import Pokemon from "#app/field/pokemon.js";
|
import Pokemon from "#app/field/pokemon";
|
||||||
import { modifierTypes } from "#app/modifier/modifier-type.js";
|
import { modifierTypes } from "#app/modifier/modifier-type";
|
||||||
import { achvs, ChallengeAchv } from "#app/system/achv.js";
|
import { achvs, ChallengeAchv } from "#app/system/achv";
|
||||||
import { Unlockables } from "#app/system/unlockables.js";
|
import { Unlockables } from "#app/system/unlockables";
|
||||||
import { Mode } from "#app/ui/ui.js";
|
import { Mode } from "#app/ui/ui";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import * as Utils from "#app/utils.js";
|
import * as Utils from "#app/utils";
|
||||||
import { BattlePhase } from "./battle-phase";
|
import { BattlePhase } from "./battle-phase";
|
||||||
import { CheckSwitchPhase } from "./check-switch-phase";
|
import { CheckSwitchPhase } from "./check-switch-phase";
|
||||||
import { EncounterPhase } from "./encounter-phase";
|
import { EncounterPhase } from "./encounter-phase";
|
||||||
@ -23,6 +23,12 @@ import { SummonPhase } from "./summon-phase";
|
|||||||
import { EndCardPhase } from "./end-card-phase";
|
import { EndCardPhase } from "./end-card-phase";
|
||||||
import { PostGameOverPhase } from "./post-game-over-phase";
|
import { PostGameOverPhase } from "./post-game-over-phase";
|
||||||
import { UnlockPhase } from "./unlock-phase";
|
import { UnlockPhase } from "./unlock-phase";
|
||||||
|
import { SessionSaveData } from "../system/game-data";
|
||||||
|
import TrainerData from "../system/trainer-data";
|
||||||
|
import PokemonData from "../system/pokemon-data";
|
||||||
|
import PersistentModifierData from "../system/modifier-data";
|
||||||
|
import ChallengeData from "../system/challenge-data";
|
||||||
|
import ArenaData from "../system/arena-data";
|
||||||
|
|
||||||
export class GameOverPhase extends BattlePhase {
|
export class GameOverPhase extends BattlePhase {
|
||||||
private victory: boolean;
|
private victory: boolean;
|
||||||
@ -98,13 +104,7 @@ export class GameOverPhase extends BattlePhase {
|
|||||||
this.scene.gameData.gameStats.dailyRunSessionsWon++;
|
this.scene.gameData.gameStats.dailyRunSessionsWon++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.scene.gameData.getSession(this.scene.sessionSlotId).then(sessionData => {
|
this.scene.gameData.saveRunHistory(this.scene, this.getFinalSessionData(), this.victory);
|
||||||
if (sessionData) {
|
|
||||||
this.scene.gameData.saveRunHistory(this.scene, sessionData, this.victory);
|
|
||||||
}
|
|
||||||
}).catch(err => {
|
|
||||||
console.error("Failed to save run to history.", err);
|
|
||||||
});
|
|
||||||
const fadeDuration = this.victory ? 10000 : 5000;
|
const fadeDuration = this.victory ? 10000 : 5000;
|
||||||
this.scene.fadeOutBgm(fadeDuration, true);
|
this.scene.fadeOutBgm(fadeDuration, true);
|
||||||
const activeBattlers = this.scene.getField().filter(p => p?.isActive(true));
|
const activeBattlers = this.scene.getField().filter(p => p?.isActive(true));
|
||||||
@ -207,4 +207,32 @@ export class GameOverPhase extends BattlePhase {
|
|||||||
this.firstRibbons.push(getPokemonSpecies(pokemon.species.getRootSpeciesId(forStarter)));
|
this.firstRibbons.push(getPokemonSpecies(pokemon.species.getRootSpeciesId(forStarter)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function mirrors game-data.ts' getSessionSaveData() to update the session data to reflect any changes that occurred within the last wave
|
||||||
|
* This means that level ups, item usage, evolutions, etc. will all be accurately reflected.
|
||||||
|
* @returns {@linkCode SessionSaveData} an updated version of the wave's SessionSaveData that accurately reflects the events of the wave
|
||||||
|
*/
|
||||||
|
private getFinalSessionData(): SessionSaveData {
|
||||||
|
return {
|
||||||
|
seed: this.scene.seed,
|
||||||
|
playTime: this.scene.sessionPlayTime,
|
||||||
|
gameMode: this.scene.gameMode.modeId,
|
||||||
|
party: this.scene.getParty().map(p => new PokemonData(p)),
|
||||||
|
enemyParty: this.scene.getEnemyParty().map(p => new PokemonData(p)),
|
||||||
|
modifiers: this.scene.findModifiers(() => true).map(m => new PersistentModifierData(m, true)),
|
||||||
|
enemyModifiers: this.scene.findModifiers(() => true, false).map(m => new PersistentModifierData(m, false)),
|
||||||
|
arena: new ArenaData(this.scene.arena),
|
||||||
|
pokeballCounts: this.scene.pokeballCounts,
|
||||||
|
money: this.scene.money,
|
||||||
|
score: this.scene.score,
|
||||||
|
waveIndex: this.scene.currentBattle.waveIndex,
|
||||||
|
battleType: this.scene.currentBattle.battleType,
|
||||||
|
trainer: this.scene.currentBattle.battleType === BattleType.TRAINER ? new TrainerData(this.scene.currentBattle.trainer) : null,
|
||||||
|
gameVersion: this.scene.game.config.gameVersion,
|
||||||
|
timestamp: new Date().getTime(),
|
||||||
|
challenges: this.scene.gameMode.challenges.map(c => new ChallengeData(c))
|
||||||
|
} as SessionSaveData;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user