Some more merging + updating
This commit is contained in:
parent
7e3dca57b4
commit
9dda58c66f
|
@ -4,6 +4,7 @@ export const menuUiHandler: SimpleTranslationEntries = {
|
||||||
"GAME_SETTINGS": "Game Settings",
|
"GAME_SETTINGS": "Game Settings",
|
||||||
"ACHIEVEMENTS": "Achievements",
|
"ACHIEVEMENTS": "Achievements",
|
||||||
"STATS": "Stats",
|
"STATS": "Stats",
|
||||||
|
"RUN_HISTORY": "Run History",
|
||||||
"VOUCHERS": "Vouchers",
|
"VOUCHERS": "Vouchers",
|
||||||
"EGG_LIST": "Egg List",
|
"EGG_LIST": "Egg List",
|
||||||
"EGG_GACHA": "Egg Gacha",
|
"EGG_GACHA": "Egg Gacha",
|
||||||
|
|
|
@ -568,10 +568,10 @@ export class GameData {
|
||||||
|
|
||||||
public async getRunHistoryData(scene: BattleScene): Promise<Object> {
|
public async getRunHistoryData(scene: BattleScene): Promise<Object> {
|
||||||
if (!Utils.isLocal) {
|
if (!Utils.isLocal) {
|
||||||
const data = await Utils.apiFetch("savedata/runHistory", true).json();
|
const response = await Utils.apiFetch("savedata/runHistory", true);
|
||||||
//const data = await response.json();
|
const data = await response.json();
|
||||||
if (localStorage.hasOwnProperty(`runHistoryData_${loggedInUser.username}`)) {
|
if (localStorage.hasOwnProperty(`runHistoryData_${loggedInUser.username}`)) {
|
||||||
let cachedResponse = localStorage.getItem(`runHistoryData_${loggedInUser.username}`, true);
|
let cachedResponse = localStorage.getItem(`runHistoryData_${loggedInUser.username}`);
|
||||||
if (cachedResponse) {
|
if (cachedResponse) {
|
||||||
cachedResponse = JSON.parse(decrypt(cachedResponse, true));
|
cachedResponse = JSON.parse(decrypt(cachedResponse, true));
|
||||||
}
|
}
|
||||||
|
@ -580,13 +580,13 @@ export class GameData {
|
||||||
if ( Object.keys(cachedRHData).length >= Object.keys(data).length ) {
|
if ( Object.keys(cachedRHData).length >= Object.keys(data).length ) {
|
||||||
return cachedRHData;
|
return cachedRHData;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
localStorage.setItem(`runHistoryData_${loggedInUser.username}`, JSON.parse(encrypt({}, true)));
|
localStorage.setItem(`runHistoryData_${loggedInUser.username}`, JSON.parse(encrypt("", true)));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else {
|
||||||
let cachedResponse = localStorage.getItem(`runHistoryData_${loggedInUser.username}`, true);
|
let cachedResponse = localStorage.getItem(`runHistoryData_${loggedInUser.username}`);
|
||||||
if (cachedResponse) {
|
if (cachedResponse) {
|
||||||
cachedResponse = JSON.parse(decrypt(cachedResponse, true));
|
cachedResponse = JSON.parse(decrypt(cachedResponse, true));
|
||||||
}
|
}
|
||||||
|
@ -602,10 +602,12 @@ export class GameData {
|
||||||
runHistoryData = {};
|
runHistoryData = {};
|
||||||
}
|
}
|
||||||
const timestamps = Object.keys(runHistoryData);
|
const timestamps = Object.keys(runHistoryData);
|
||||||
|
const timestampsNo = timestamps.map(Number);
|
||||||
|
|
||||||
//Arbitrary limit of 25 entries per User --> Can increase or decrease
|
//Arbitrary limit of 25 entries per User --> Can increase or decrease
|
||||||
if (timestamps.length >= 25) {
|
if (timestamps.length >= 25) {
|
||||||
delete this.scene.gameData.runHistory[Math.min(timestamps)];
|
const oldestTimestamp = Math.min.apply(Math, timestampsNo);
|
||||||
|
delete this.scene.gameData.runHistory[oldestTimestamp.toString()];
|
||||||
}
|
}
|
||||||
|
|
||||||
const timestamp = (runEntry.timestamp).toString();
|
const timestamp = (runEntry.timestamp).toString();
|
||||||
|
|
|
@ -16,6 +16,7 @@ enum MenuOptions {
|
||||||
GAME_SETTINGS,
|
GAME_SETTINGS,
|
||||||
ACHIEVEMENTS,
|
ACHIEVEMENTS,
|
||||||
STATS,
|
STATS,
|
||||||
|
RUN_HISTORY,
|
||||||
VOUCHERS,
|
VOUCHERS,
|
||||||
EGG_LIST,
|
EGG_LIST,
|
||||||
EGG_GACHA,
|
EGG_GACHA,
|
||||||
|
@ -351,6 +352,10 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||||
ui.setOverlayMode(Mode.GAME_STATS);
|
ui.setOverlayMode(Mode.GAME_STATS);
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
|
case MenuOptions.RUN_HISTORY:
|
||||||
|
ui.setOverlayMode(Mode.RUN_HISTORY);
|
||||||
|
success = true;
|
||||||
|
break;
|
||||||
case MenuOptions.VOUCHERS:
|
case MenuOptions.VOUCHERS:
|
||||||
ui.setOverlayMode(Mode.VOUCHERS);
|
ui.setOverlayMode(Mode.VOUCHERS);
|
||||||
success = true;
|
success = true;
|
||||||
|
|
|
@ -248,6 +248,7 @@ class RunEntry extends Phaser.GameObjects.Container {
|
||||||
const enemyIconContainer = this.scene.add.container(65+(e*25),-8);
|
const enemyIconContainer = this.scene.add.container(65+(e*25),-8);
|
||||||
enemyIconContainer.setScale(0.75);
|
enemyIconContainer.setScale(0.75);
|
||||||
enemyData.boss = false;
|
enemyData.boss = false;
|
||||||
|
enemyData["player"] = true;
|
||||||
const enemy = enemyData.toPokemon(this.scene);
|
const enemy = enemyData.toPokemon(this.scene);
|
||||||
const enemyIcon = this.scene.addPokemonIcon(enemy, 0, 0, 0, 0);
|
const enemyIcon = this.scene.addPokemonIcon(enemy, 0, 0, 0, 0);
|
||||||
const enemyLevel = addTextObject(this.scene, 32, 20, `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(enemy.level, 1000)}`, TextStyle.PARTY, { fontSize: "54px", color: "#f8f8f8" });
|
const enemyLevel = addTextObject(this.scene, 32, 20, `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(enemy.level, 1000)}`, TextStyle.PARTY, { fontSize: "54px", color: "#f8f8f8" });
|
||||||
|
|
|
@ -162,6 +162,7 @@ export default class GameInfoUiHandler extends UiHandler {
|
||||||
const enemyData = runData.enemyParty[0];
|
const enemyData = runData.enemyParty[0];
|
||||||
const bossStatus = enemyData.boss;
|
const bossStatus = enemyData.boss;
|
||||||
enemyData.boss = false;
|
enemyData.boss = false;
|
||||||
|
enemyData["player"] = true;
|
||||||
//addPokemonIcon() throws an error if the Pokemon used is a boss
|
//addPokemonIcon() throws an error if the Pokemon used is a boss
|
||||||
const enemy = enemyData.toPokemon(this.scene);
|
const enemy = enemyData.toPokemon(this.scene);
|
||||||
const enemyIcon = this.scene.addPokemonIcon(enemy, 0, 0, 0, 0);
|
const enemyIcon = this.scene.addPokemonIcon(enemy, 0, 0, 0, 0);
|
||||||
|
@ -180,6 +181,7 @@ export default class GameInfoUiHandler extends UiHandler {
|
||||||
const enemyIconContainer = this.scene.add.container(0, 0);
|
const enemyIconContainer = this.scene.add.container(0, 0);
|
||||||
const bossStatus = enemyData.boss;
|
const bossStatus = enemyData.boss;
|
||||||
enemyData.boss = false;
|
enemyData.boss = false;
|
||||||
|
enemyData["player"] = true;
|
||||||
const enemy = enemyData.toPokemon(this.scene);
|
const enemy = enemyData.toPokemon(this.scene);
|
||||||
const enemyIcon = this.scene.addPokemonIcon(enemy, 0, 0, 0, 0);
|
const enemyIcon = this.scene.addPokemonIcon(enemy, 0, 0, 0, 0);
|
||||||
const enemyLevel = addTextObject(this.scene, 36, 26, `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(enemy.level, 1000)}`, bossStatus ? TextStyle.PARTY_RED : TextStyle.PARTY, { fontSize: "44px", color: "#f8f8f8" });
|
const enemyLevel = addTextObject(this.scene, 36, 26, `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(enemy.level, 1000)}`, bossStatus ? TextStyle.PARTY_RED : TextStyle.PARTY, { fontSize: "44px", color: "#f8f8f8" });
|
||||||
|
@ -230,6 +232,7 @@ export default class GameInfoUiHandler extends UiHandler {
|
||||||
enemyIconContainer.setScale(0.6);
|
enemyIconContainer.setScale(0.6);
|
||||||
const isBoss = enemyData.boss;
|
const isBoss = enemyData.boss;
|
||||||
enemyData.boss = false;
|
enemyData.boss = false;
|
||||||
|
enemyData["player"] = true;
|
||||||
const enemy = enemyData.toPokemon(this.scene);
|
const enemy = enemyData.toPokemon(this.scene);
|
||||||
const enemyIcon = this.scene.addPokemonIcon(enemy, 0, 0, 0, 0);
|
const enemyIcon = this.scene.addPokemonIcon(enemy, 0, 0, 0, 0);
|
||||||
const enemySprite1 = enemyIcon.list[0] as Phaser.GameObjects.Sprite;
|
const enemySprite1 = enemyIcon.list[0] as Phaser.GameObjects.Sprite;
|
||||||
|
|
Loading…
Reference in New Issue