mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-01 05:52:17 +02:00
Updated code with the current repo + mode localization
This commit is contained in:
parent
c53818205a
commit
4ca48c6bc6
@ -945,14 +945,10 @@ export class GameData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async public getRunHistoryData(scene: BattleScene): Promise<Object> {
|
async public getRunHistoryData(scene: BattleScene): Promise<Object> {
|
||||||
try {
|
if (!Utils.isLocal) {
|
||||||
const response = await Utils.apiFetch("savedata/runHistory", true);
|
const response = await Utils.apiFetch("savedata/runHistory", true);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log(data);
|
const cachedResponse = localStorage.getItem(`runHistoryData_${loggedInUser.username}`, true);
|
||||||
if (!data) {
|
|
||||||
throw new Error("No data");
|
|
||||||
} else {
|
|
||||||
var cachedResponse = localStorage.getItem(`runHistoryData_${loggedInUser.username}`, true);
|
|
||||||
if (cachedResponse) {
|
if (cachedResponse) {
|
||||||
cachedResponse = JSON.parse(decrypt(cachedResponse, true));
|
cachedResponse = JSON.parse(decrypt(cachedResponse, true));
|
||||||
}
|
}
|
||||||
@ -962,14 +958,13 @@ export class GameData {
|
|||||||
return cachedRHData;
|
return cachedRHData;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
} else {
|
||||||
} catch (err) {
|
const cachedResponse = localStorage.getItem(`runHistoryData_${loggedInUser.username}`, true);
|
||||||
console.log("Something went wrong: ", err);
|
|
||||||
var cachedResponse = localStorage.getItem(`runHistoryData_${loggedInUser.username}`, true);
|
|
||||||
if (cachedResponse) {
|
if (cachedResponse) {
|
||||||
cachedResponse = JSON.parse(decrypt(cachedResponse, true));
|
cachedResponse = JSON.parse(decrypt(cachedResponse, true));
|
||||||
}
|
}
|
||||||
return cachedResponse ?? {};
|
const cachedRHData = cachedResponse ?? {};
|
||||||
|
return cachedRHData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -990,6 +985,7 @@ export class GameData {
|
|||||||
|
|
||||||
localStorage.setItem(`runHistoryData_${loggedInUser.username}`, encrypt(JSON.stringify(runHistoryData), true));
|
localStorage.setItem(`runHistoryData_${loggedInUser.username}`, encrypt(JSON.stringify(runHistoryData), true));
|
||||||
|
|
||||||
|
if (!Utils.local) {
|
||||||
try {
|
try {
|
||||||
const response = Utils.apiPost("savedata/runHistory", JSON.stringify(runHistoryData), undefined, true);
|
const response = Utils.apiPost("savedata/runHistory", JSON.stringify(runHistoryData), undefined, true);
|
||||||
return true;
|
return true;
|
||||||
@ -998,6 +994,7 @@ export class GameData {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
saveAll(scene: BattleScene, skipVerification: boolean = false, sync: boolean = false, useCachedSession: boolean = false, useCachedSystem: boolean = false): Promise<boolean> {
|
saveAll(scene: BattleScene, skipVerification: boolean = false, sync: boolean = false, useCachedSession: boolean = false, useCachedSystem: boolean = false): Promise<boolean> {
|
||||||
return new Promise<boolean>(resolve => {
|
return new Promise<boolean>(resolve => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import BattleScene from "../battle-scene";
|
import BattleScene from "../battle-scene";
|
||||||
import { gameModes, GameModes } from "../game-mode";
|
import { GameModes } from "../game-mode";
|
||||||
import { SessionSaveData, parseSessionData, getRunHistoryData, RunHistoryData, RunEntries, decrypt } from "../system/game-data";
|
import { SessionSaveData, parseSessionData, getRunHistoryData, RunHistoryData, RunEntries, decrypt } from "../system/game-data";
|
||||||
import { TextStyle, addTextObject } from "./text";
|
import { TextStyle, addTextObject } from "./text";
|
||||||
import { Mode } from "./ui";
|
import { Mode } from "./ui";
|
||||||
@ -13,7 +13,7 @@ import MessageUiHandler from "./message-ui-handler";
|
|||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import {Button} from "../enums/buttons";
|
import {Button} from "../enums/buttons";
|
||||||
import { BattleType } from "../battle";
|
import { BattleType } from "../battle";
|
||||||
import {TrainerType} from "../data/enums/trainer-type";
|
import { TrainerType } from "../enums/trainer-type";
|
||||||
import { TrainerVariant } from "../field/trainer";
|
import { TrainerVariant } from "../field/trainer";
|
||||||
import { getPartyLuckValue, getLuckString, getLuckTextTint } from "../modifier/modifier-type";
|
import { getPartyLuckValue, getLuckString, getLuckTextTint } from "../modifier/modifier-type";
|
||||||
|
|
||||||
@ -134,7 +134,6 @@ export default class RunHistoryUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
async populateruns(scene: BattleScene) {
|
async populateruns(scene: BattleScene) {
|
||||||
const response = await this.scene.gameData.getRunHistoryData(this.scene);
|
const response = await this.scene.gameData.getRunHistoryData(this.scene);
|
||||||
console.log(response);
|
|
||||||
const timestamps = Object.keys(response);
|
const timestamps = Object.keys(response);
|
||||||
if (timestamps.length > 1) {
|
if (timestamps.length > 1) {
|
||||||
timestamps.sort((a, b) => a - b);
|
timestamps.sort((a, b) => a - b);
|
||||||
@ -278,8 +277,23 @@ class RunEntry extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const gameModeLabel = addTextObject(this.scene, 8, 19, `${gameModes[data.gameMode]?.getName() || "Unknown"} - Wave ${data.waveIndex}`, TextStyle.WINDOW);
|
|
||||||
|
switch (data.gameMode) {
|
||||||
|
case GameModes.DAILY:
|
||||||
|
const dailyModeLabel = addTextObject(this.scene, 8, 19, `${i18next.t('gameMode:dailyRun') || "Unknown"} - Wave ${data.waveIndex}`, TextStyle.WINDOW);
|
||||||
|
this.add(dailyModeLabel);
|
||||||
|
break;
|
||||||
|
case GameModes.SPLICED_ENDLESS:
|
||||||
|
const endlessSplicedLabel = addTextObject(this.scene, 8, 19, `${i18next.t('gameMode:endlessSpliced') || "Unknown"} - Wave ${data.waveIndex}`, TextStyle.WINDOW);
|
||||||
|
this.add(endlessSplicedLabel);
|
||||||
|
break;
|
||||||
|
case GameModes.ENDLESS:
|
||||||
|
case GameModes.CLASSIC:
|
||||||
|
case GameModes.CHALLENGE:
|
||||||
|
const gameModeLabel = addTextObject(this.scene, 8, 19, `${i18next.t('gameMode:'+GameModes[data.gameMode].toLowerCase()) || "Unknown"} - Wave ${data.waveIndex}`, TextStyle.WINDOW);
|
||||||
this.add(gameModeLabel);
|
this.add(gameModeLabel);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
const date = new Date(data.timestamp);
|
const date = new Date(data.timestamp);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user