mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 16:02:20 +02:00
Allow reload helper to directly access getSessionSaveData()
This commit is contained in:
parent
427de53ae6
commit
b2a934e260
@ -946,7 +946,7 @@ export class GameData {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getSessionSaveData(scene: BattleScene): SessionSaveData {
|
public getSessionSaveData(scene: BattleScene): SessionSaveData {
|
||||||
return {
|
return {
|
||||||
seed: scene.seed,
|
seed: scene.seed,
|
||||||
playTime: scene.sessionPlayTime,
|
playTime: scene.sessionPlayTime,
|
||||||
|
@ -1,10 +1,3 @@
|
|||||||
import { BattleType } from "#app/battle";
|
|
||||||
import PokemonData from "#app/system/pokemon-data";
|
|
||||||
import ArenaData from "#app/system/arena-data";
|
|
||||||
import PersistentModifierData from "#app/system/modifier-data";
|
|
||||||
import ChallengeData from "#app/system/challenge-data";
|
|
||||||
import TrainerData from "#app/system/trainer-data";
|
|
||||||
import { SessionSaveData } from "#app/system/game-data";
|
|
||||||
import { GameManagerHelper } from "./gameManagerHelper";
|
import { GameManagerHelper } from "./gameManagerHelper";
|
||||||
import { TitlePhase } from "#app/phases/title-phase";
|
import { TitlePhase } from "#app/phases/title-phase";
|
||||||
import { Mode } from "#app/ui/ui";
|
import { Mode } from "#app/ui/ui";
|
||||||
@ -17,35 +10,6 @@ import { TurnInitPhase } from "#app/phases/turn-init-phase";
|
|||||||
* Helper to allow reloading sessions in unit tests.
|
* Helper to allow reloading sessions in unit tests.
|
||||||
*/
|
*/
|
||||||
export class ReloadHelper extends GameManagerHelper {
|
export class ReloadHelper extends GameManagerHelper {
|
||||||
/**
|
|
||||||
* Return a save data object to be used for reloading the current session.
|
|
||||||
* @returns A save data object for the current session.
|
|
||||||
*/
|
|
||||||
getSessionSaveData() : SessionSaveData {
|
|
||||||
// Copied from game-data.ts
|
|
||||||
const scene = this.game.scene;
|
|
||||||
const ret = {
|
|
||||||
seed: scene.seed,
|
|
||||||
playTime: scene.sessionPlayTime,
|
|
||||||
gameMode: scene.gameMode.modeId,
|
|
||||||
party: scene.getParty().map(p => new PokemonData(p)),
|
|
||||||
enemyParty: scene.getEnemyParty().map(p => new PokemonData(p)),
|
|
||||||
modifiers: scene.findModifiers(() => true).map(m => new PersistentModifierData(m, true)),
|
|
||||||
enemyModifiers: scene.findModifiers(() => true, false).map(m => new PersistentModifierData(m, false)),
|
|
||||||
arena: new ArenaData(scene.arena),
|
|
||||||
pokeballCounts: scene.pokeballCounts,
|
|
||||||
money: scene.money,
|
|
||||||
score: scene.score,
|
|
||||||
waveIndex: scene.currentBattle.waveIndex,
|
|
||||||
battleType: scene.currentBattle.battleType,
|
|
||||||
trainer: scene.currentBattle.battleType === BattleType.TRAINER ? new TrainerData(scene.currentBattle.trainer) : null,
|
|
||||||
gameVersion: scene.game.config.gameVersion,
|
|
||||||
timestamp: new Date().getTime(),
|
|
||||||
challenges: scene.gameMode.challenges.map(c => new ChallengeData(c))
|
|
||||||
} as SessionSaveData;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simulate reloading the session from the title screen, until reaching the
|
* Simulate reloading the session from the title screen, until reaching the
|
||||||
* beginning of the first turn (equivalent to running `startBattle()`) for
|
* beginning of the first turn (equivalent to running `startBattle()`) for
|
||||||
@ -53,7 +17,7 @@ export class ReloadHelper extends GameManagerHelper {
|
|||||||
*/
|
*/
|
||||||
async reloadSession() : Promise<void> {
|
async reloadSession() : Promise<void> {
|
||||||
const scene = this.game.scene;
|
const scene = this.game.scene;
|
||||||
const sessionData = this.getSessionSaveData();
|
const sessionData = scene.gameData.getSessionSaveData(scene);
|
||||||
const titlePhase = new TitlePhase(scene);
|
const titlePhase = new TitlePhase(scene);
|
||||||
|
|
||||||
scene.clearPhaseQueue();
|
scene.clearPhaseQueue();
|
||||||
|
Loading…
Reference in New Issue
Block a user