Final touches before moving to a clean branch

This commit is contained in:
Frutescens 2024-06-17 09:37:24 -07:00
parent 4ca48c6bc6
commit 2d0156c8df
14 changed files with 371 additions and 151 deletions

View File

@ -215,6 +215,9 @@ export class LoadingScene extends SceneBase {
this.loadAtlas("c_rival_m", "character", "rival_m");
this.loadAtlas("c_rival_f", "character", "rival_f");
//Load run-history related images
this.loadImage("hall_of_fame", "ui");
// Load pokemon-related images
this.loadImage("pkmn__back__sub", "pokemon/back", "sub.png");
this.loadImage("pkmn__sub", "pokemon", "sub.png");

View File

@ -0,0 +1,31 @@
import { SimpleTranslationEntries } from "#app/interfaces/locales";
export const runHistory: SimpleTranslationEntries = {
"victory": "Victory!",
"defeatedWild": "Defeated by ",
"defeatedTrainer": "Defeated by ",
"defeatedTrainerDouble": "Defeated by Duo",
"defeatedRival": "Defeated by Rival",
"defeated":"Defeated",
"luck":"Luck",
"score":"Score",
"mode":"Mode",
"challengeRules":"Rule(s)",
"challengeMonoGen1":"Gen I",
"challengeMonoGen2":"Gen II",
"challengeMonoGen3":"Gen III",
"challengeMonoGen4":"Gen IV",
"challengeMonoGen5":"Gen V",
"challengeMonoGen6":"Gen VI",
"challengeMonoGen7":"Gen VII",
"challengeMonoGen8":"Gen VIII",
"challengeMonoGen9":"Gen IX",
"playerItems":"Player Items",
"personalBest":"Personal Best!",
"SPDshortened":"Vel.",
"runInfo":"Run Info",
"money":"Money",
} as const;
//Mode Information found in game-mode.ts
//Wave / Lv found in save-slot-select-ui-handler.ts

View File

@ -1,16 +1,9 @@
import { common } from "./common.js";
import { settings } from "./settings.js";
import { ability } from "./ability";
import { abilityTriggers } from "./ability-trigger";
import { arenaFlyout } from "./arena-flyout";
import { arenaTag } from "./arena-tag";
import { PGFachv, PGMachv } from "./achv";
import { battle } from "./battle";
import { battleInfo } from "./battle-info";
import { battleMessageUiHandler } from "./battle-message-ui-handler";
import { battlerTags } from "./battler-tags";
import { berry } from "./berry";
import { bgmName } from "./bgm-name";
import { biome } from "./biome";
import { challenges } from "./challenges";
import { commandUiHandler } from "./command-ui-handler";
@ -26,50 +19,37 @@ import {
} from "./dialogue";
import { egg } from "./egg";
import { fightUiHandler } from "./fight-ui-handler";
import { filterBar } from "./filter-bar";
import { gameMode } from "./game-mode";
import { gameStatsUiHandler } from "./game-stats-ui-handler";
import { growth } from "./growth";
import { menu } from "./menu";
import { menuUiHandler } from "./menu-ui-handler";
import { modifier } from "./modifier";
import { modifierType } from "./modifier-type";
import { move } from "./move";
import { nature } from "./nature";
import { partyUiHandler } from "./party-ui-handler";
import { pokeball } from "./pokeball";
import { pokemon } from "./pokemon";
import { pokemonForm, battlePokemonForm } from "./pokemon-form";
import { pokemonInfo } from "./pokemon-info";
import { pokemonInfoContainer } from "./pokemon-info-container";
import { pokemonSummary } from "./pokemon-summary";
import { saveSlotSelectUiHandler } from "./save-slot-select-ui-handler";
import { splashMessages } from "./splash-messages";
import { starterSelectUiHandler } from "./starter-select-ui-handler";
import { statusEffect } from "./status-effect";
import { titles, trainerClasses, trainerNames } from "./trainers";
import { tutorial } from "./tutorial";
import { voucher } from "./voucher";
import { terrain, weather } from "./weather";
import { modifierSelectUiHandler } from "./modifier-select-ui-handler";
import { moveTriggers } from "./move-trigger";
import { weather } from "./weather";
import { runHistory } from "./run-history-ui-handler.ts";
export const enConfig = {
ability: ability,
abilityTriggers: abilityTriggers,
arenaFlyout: arenaFlyout,
arenaTag: arenaTag,
battle: battle,
battleInfo: battleInfo,
battleMessageUiHandler: battleMessageUiHandler,
battlePokemonForm: battlePokemonForm,
battlerTags: battlerTags,
berry: berry,
bgmName: bgmName,
biome: biome,
challenges: challenges,
commandUiHandler: commandUiHandler,
common: common,
PGMachv: PGMachv,
PGFachv: PGFachv,
PGMdialogue: PGMdialogue,
@ -82,35 +62,27 @@ export const enConfig = {
PGFdoubleBattleDialogue: PGFdoubleBattleDialogue,
egg: egg,
fightUiHandler: fightUiHandler,
filterBar: filterBar,
gameMode: gameMode,
gameStatsUiHandler: gameStatsUiHandler,
growth: growth,
menu: menu,
menuUiHandler: menuUiHandler,
modifier: modifier,
modifierType: modifierType,
move: move,
nature: nature,
partyUiHandler: partyUiHandler,
pokeball: pokeball,
pokemon: pokemon,
pokemonForm: pokemonForm,
pokemonInfo: pokemonInfo,
pokemonInfoContainer: pokemonInfoContainer,
pokemonSummary: pokemonSummary,
saveSlotSelectUiHandler: saveSlotSelectUiHandler,
settings: settings,
splashMessages: splashMessages,
starterSelectUiHandler: starterSelectUiHandler,
statusEffect: statusEffect,
terrain: terrain,
titles: titles,
trainerClasses: trainerClasses,
trainerNames: trainerNames,
tutorial: tutorial,
voucher: voucher,
weather: weather,
partyUiHandler: partyUiHandler,
modifierSelectUiHandler: modifierSelectUiHandler,
moveTriggers: moveTriggers
runHistory: runHistory,
};

View File

@ -0,0 +1,35 @@
import { SimpleTranslationEntries } from "#app/interfaces/locales";
export const runHistory: SimpleTranslationEntries = {
"victory": "Victory!",
"defeatedWild": "Defeated by ",
"defeatedTrainer": "Defeated by ",
"defeatedTrainerDouble": "Defeated by Duo",
"defeatedRival": "Defeated by Rival",
"defeated":"Defeated",
"luck":"Luck",
"score":"Score",
"mode":"Mode",
"challengeRules":"Rule(s)",
"challengeMonoGen1":"Gen I",
"challengeMonoGen2":"Gen II",
"challengeMonoGen3":"Gen III",
"challengeMonoGen4":"Gen IV",
"challengeMonoGen5":"Gen V",
"challengeMonoGen6":"Gen VI",
"challengeMonoGen7":"Gen VII",
"challengeMonoGen8":"Gen VIII",
"challengeMonoGen9":"Gen IX",
"playerItems":"Player Items",
"personalBest":"Personal Best!",
"SPDshortened":"Vel.",
"runInfo":"Run Info",
"money":"Money",
"runLength":"Run Length",
"viewHeldItems":"Held Items",
"hallofFameText":"Welcome to the Hall of Fame!",
"viewHallOfFame":"View Hall of Fame!"
} as const;
//Mode Information found in game-mode.ts
//Wave / Lv found in save-slot-select-ui-handler.ts

View File

@ -0,0 +1,30 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const runHistory: SimpleTranslationEntries = {
"victory": "Victory!",
"defeatedWild": "Defeated by ",
"defeatedTrainer": "Defeated by ",
"defeatedTrainerDouble": "Defeated by Duo",
"defeatedRival": "Defeated by Rival",
"defeated":"Defeated",
"luck":"Luck",
"score":"Score",
"mode":"Mode",
"challengeRules":"Rule(s)",
"challengeMonoGen1":"Gen I",
"challengeMonoGen2":"Gen II",
"challengeMonoGen3":"Gen III",
"challengeMonoGen4":"Gen IV",
"challengeMonoGen5":"Gen V",
"challengeMonoGen6":"Gen VI",
"challengeMonoGen7":"Gen VII",
"challengeMonoGen8":"Gen VIII",
"challengeMonoGen9":"Gen IX",
"playerItems":"Player Items",
"SPDshortened":"Vel.",
"runInfo":"Run Info",
"money":"Money",
} as const;
//Mode Information found in game-mode.ts
//Wave / Lv found in save-slot-select-ui-handler.ts

View File

@ -0,0 +1,31 @@
import { SimpleTranslationEntries } from "#app/interfaces/locales";
export const runHistory: SimpleTranslationEntries = {
"victory": "Victory!",
"defeatedWild": "Defeated by ",
"defeatedTrainer": "Defeated by ",
"defeatedTrainerDouble": "Defeated by Duo",
"defeatedRival": "Defeated by Rival",
"defeated":"Defeated",
"luck":"Luck",
"score":"Score",
"mode":"Mode",
"challengeRules":"Rule(s)",
"challengeMonoGen1":"Gen I",
"challengeMonoGen2":"Gen II",
"challengeMonoGen3":"Gen III",
"challengeMonoGen4":"Gen IV",
"challengeMonoGen5":"Gen V",
"challengeMonoGen6":"Gen VI",
"challengeMonoGen7":"Gen VII",
"challengeMonoGen8":"Gen VIII",
"challengeMonoGen9":"Gen IX",
"playerItems":"Player Items",
"personalBest":"Personal Best!",
"SPDshortened":"Vel.",
"runInfo":"Run Info",
"money":"Money",
} as const;
//Mode Information found in game-mode.ts
//Wave / Lv found in save-slot-select-ui-handler.ts

View File

@ -0,0 +1,31 @@
import { SimpleTranslationEntries } from "#app/interfaces/locales";
export const runHistory: SimpleTranslationEntries = {
"victory": "Victory!",
"defeatedWild": "Defeated by ",
"defeatedTrainer": "Defeated by ",
"defeatedTrainerDouble": "Defeated by Duo",
"defeatedRival": "Defeated by Rival",
"defeated":"Defeated",
"luck":"Luck",
"score":"Score",
"mode":"Mode",
"challengeRules":"Rule(s)",
"challengeMonoGen1":"Gen I",
"challengeMonoGen2":"Gen II",
"challengeMonoGen3":"Gen III",
"challengeMonoGen4":"Gen IV",
"challengeMonoGen5":"Gen V",
"challengeMonoGen6":"Gen VI",
"challengeMonoGen7":"Gen VII",
"challengeMonoGen8":"Gen VIII",
"challengeMonoGen9":"Gen IX",
"playerItems":"Player Items",
"personalBest":"Personal Best!",
"SPDshortened":"Vel.",
"runInfo":"Run Info",
"money":"Money",
} as const;
//Mode Information found in game-mode.ts
//Wave / Lv found in save-slot-select-ui-handler.ts

View File

@ -0,0 +1,31 @@
import { SimpleTranslationEntries } from "#app/interfaces/locales";
export const runHistory: SimpleTranslationEntries = {
"victory": "Victory!",
"defeatedWild": "Defeated by ",
"defeatedTrainer": "Defeated by ",
"defeatedTrainerDouble": "Defeated by Duo",
"defeatedRival": "Defeated by Rival",
"defeated":"Defeated",
"luck":"Luck",
"score":"Score",
"mode":"Mode",
"challengeRules":"Rule(s)",
"challengeMonoGen1":"Gen I",
"challengeMonoGen2":"Gen II",
"challengeMonoGen3":"Gen III",
"challengeMonoGen4":"Gen IV",
"challengeMonoGen5":"Gen V",
"challengeMonoGen6":"Gen VI",
"challengeMonoGen7":"Gen VII",
"challengeMonoGen8":"Gen VIII",
"challengeMonoGen9":"Gen IX",
"playerItems":"Player Items",
"personalBest":"Personal Best!",
"SPDshortened":"Vel.",
"runInfo":"Run Info",
"money":"Money",
} as const;
//Mode Information found in game-mode.ts
//Wave / Lv found in save-slot-select-ui-handler.ts

View File

@ -0,0 +1,31 @@
import { SimpleTranslationEntries } from "#app/interfaces/locales";
export const runHistory: SimpleTranslationEntries = {
"victory": "Victory!",
"defeatedWild": "Defeated by ",
"defeatedTrainer": "Defeated by ",
"defeatedTrainerDouble": "Defeated by Duo",
"defeatedRival": "Defeated by Rival",
"defeated":"Defeated",
"luck":"Luck",
"score":"Score",
"mode":"Mode",
"challengeRules":"Rule(s)",
"challengeMonoGen1":"Gen I",
"challengeMonoGen2":"Gen II",
"challengeMonoGen3":"Gen III",
"challengeMonoGen4":"Gen IV",
"challengeMonoGen5":"Gen V",
"challengeMonoGen6":"Gen VI",
"challengeMonoGen7":"Gen VII",
"challengeMonoGen8":"Gen VIII",
"challengeMonoGen9":"Gen IX",
"playerItems":"Player Items",
"personalBest":"Personal Best!",
"SPDshortened":"Vel.",
"runInfo":"Run Info",
"money":"Money",
} as const;
//Mode Information found in game-mode.ts
//Wave / Lv found in save-slot-select-ui-handler.ts

View File

@ -0,0 +1,31 @@
import { SimpleTranslationEntries } from "#app/interfaces/locales";
export const runHistory: SimpleTranslationEntries = {
"victory": "Victory!",
"defeatedWild": "Defeated by ",
"defeatedTrainer": "Defeated by ",
"defeatedTrainerDouble": "Defeated by Duo",
"defeatedRival": "Defeated by Rival",
"defeated":"Defeated",
"luck":"Luck",
"score":"Score",
"mode":"Mode",
"challengeRules":"Rule(s)",
"challengeMonoGen1":"Gen I",
"challengeMonoGen2":"Gen II",
"challengeMonoGen3":"Gen III",
"challengeMonoGen4":"Gen IV",
"challengeMonoGen5":"Gen V",
"challengeMonoGen6":"Gen VI",
"challengeMonoGen7":"Gen VII",
"challengeMonoGen8":"Gen VIII",
"challengeMonoGen9":"Gen IX",
"playerItems":"Player Items",
"personalBest":"Personal Best!",
"SPDshortened":"Vel.",
"runInfo":"Run Info",
"money":"Money",
} as const;
//Mode Information found in game-mode.ts
//Wave / Lv found in save-slot-select-ui-handler.ts

View File

@ -0,0 +1,31 @@
import { SimpleTranslationEntries } from "#app/interfaces/locales";
export const runHistory: SimpleTranslationEntries = {
"victory": "Victory!",
"defeatedWild": "Defeated by ",
"defeatedTrainer": "Defeated by ",
"defeatedTrainerDouble": "Defeated by Duo",
"defeatedRival": "Defeated by Rival",
"defeated":"Defeated",
"luck":"Luck",
"score":"Score",
"mode":"Mode",
"challengeRules":"Rule(s)",
"challengeMonoGen1":"Gen I",
"challengeMonoGen2":"Gen II",
"challengeMonoGen3":"Gen III",
"challengeMonoGen4":"Gen IV",
"challengeMonoGen5":"Gen V",
"challengeMonoGen6":"Gen VI",
"challengeMonoGen7":"Gen VII",
"challengeMonoGen8":"Gen VIII",
"challengeMonoGen9":"Gen IX",
"playerItems":"Player Items",
"personalBest":"Personal Best!",
"SPDshortened":"Vel.",
"runInfo":"Run Info",
"money":"Money",
} as const;
//Mode Information found in game-mode.ts
//Wave / Lv found in save-slot-select-ui-handler.ts

View File

@ -944,22 +944,27 @@ export class GameData {
}) as SessionSaveData;
}
async public getRunHistoryData(scene: BattleScene): Promise<Object> {
public async getRunHistoryData(scene: BattleScene): Promise<Object> {
if (!Utils.isLocal) {
const response = await Utils.apiFetch("savedata/runHistory", true);
const data = await response.json();
const cachedResponse = localStorage.getItem(`runHistoryData_${loggedInUser.username}`, true);
if (cachedResponse) {
cachedResponse = JSON.parse(decrypt(cachedResponse, true));
}
const cachedRHData = cachedResponse ?? {};
//check to see whether cachedData or serverData is more up-to-date
if ( Object.keys(cachedRHData).length >= Object.keys(data).length ) {
return cachedRHData;
const data = await Utils.apiFetch("savedata/runHistory", true).json();
//const data = await response.json();
if (localStorage.hasOwnProperty(`runHistoryData_${loggedInUser.username}`)) {
let cachedResponse = localStorage.getItem(`runHistoryData_${loggedInUser.username}`, true);
if (cachedResponse) {
cachedResponse = JSON.parse(decrypt(cachedResponse, true));
}
const cachedRHData = cachedResponse ?? {};
//check to see whether cachedData or serverData is more up-to-date
if ( Object.keys(cachedRHData).length >= Object.keys(data).length ) {
return cachedRHData;
}
} else {
localStorage.setItem(`runHistoryData_${loggedInUser.username}`, JSON.parse(encrypt({}, true)));
return {};
}
return data;
} else {
const cachedResponse = localStorage.getItem(`runHistoryData_${loggedInUser.username}`, true);
let cachedResponse = localStorage.getItem(`runHistoryData_${loggedInUser.username}`, true);
if (cachedResponse) {
cachedResponse = JSON.parse(decrypt(cachedResponse, true));
}
@ -970,7 +975,10 @@ export class GameData {
async saveRunHistory(scene: BattleScene, runEntry : SessionSaveData, victory: boolean): Promise<boolean> {
const runHistoryData = await this.getRunHistoryData(scene);
let runHistoryData = await this.getRunHistoryData(scene);
if (!runHistoryData) {
runHistoryData = {};
}
const timestamps = Object.keys(runHistoryData);
//Arbitrary limit of 25 entries per User --> Can increase or decrease
@ -985,9 +993,9 @@ export class GameData {
localStorage.setItem(`runHistoryData_${loggedInUser.username}`, encrypt(JSON.stringify(runHistoryData), true));
if (!Utils.local) {
if (!Utils.isLocal) {
try {
const response = Utils.apiPost("savedata/runHistory", JSON.stringify(runHistoryData), undefined, true);
Utils.apiPost("savedata/runHistory", JSON.stringify(runHistoryData), undefined, true);
return true;
} catch (err) {
console.log("savedata/runHistory POST failed : ", err);

View File

@ -1,21 +1,17 @@
import BattleScene from "../battle-scene";
import { GameModes } from "../game-mode";
import { SessionSaveData, parseSessionData, getRunHistoryData, RunHistoryData, RunEntries, decrypt } from "../system/game-data";
import { TextStyle, addTextObject } from "./text";
import { Mode } from "./ui";
import { addWindow } from "./ui-theme";
import * as Utils from "../utils";
import { PokemonData } from "../system/pokemon-data";
import { TrainerData } from "../system/trainer-data";
import Pokemon, { EnemyPokemon, PlayerPokemon } from "../field/pokemon";
import { PokemonHeldItemModifier } from "../modifier/modifier";
import PokemonData from "../system/pokemon-data";
import MessageUiHandler from "./message-ui-handler";
import i18next from "i18next";
import {Button} from "../enums/buttons";
import { BattleType } from "../battle";
import { TrainerType } from "../enums/trainer-type";
import { TrainerVariant } from "../field/trainer";
import { getPartyLuckValue, getLuckString, getLuckTextTint } from "../modifier/modifier-type";
import { RunHistoryData } from "../system/game-data";
export const runCount = 25;
@ -27,9 +23,8 @@ export default class RunHistoryUiHandler extends MessageUiHandler {
private runsContainer: Phaser.GameObjects.Container;
private runSelectMessageBox: Phaser.GameObjects.NineSlice;
private runSelectMessageBoxContainer: Phaser.GameObjects.Container;
private runs: runEntry[];
private runs: RunEntry[];
private uiMode: RunHistoryUiMode;
private runSelectCallback: RunSelectCallback;
private scrollCursor: integer = 0;
@ -93,10 +88,11 @@ export default class RunHistoryUiHandler extends MessageUiHandler {
const error = false;
if (button === Button.ACTION || button === Button.CANCEL) {
const originalCallback = this.runSelectCallback;
if (button === Button.ACTION) {
const cursor = this.cursor + this.scrollCursor;
console.log("Action --> page with more detailed run information");
if (this.runs[cursor].hasData) {
this.scene.ui.setOverlayMode(Mode.RUN_INFO, this.runs[cursor].entryData, true);
}
success = true;
return success;
} else {
@ -135,12 +131,13 @@ export default class RunHistoryUiHandler extends MessageUiHandler {
async populateruns(scene: BattleScene) {
const response = await this.scene.gameData.getRunHistoryData(this.scene);
const timestamps = Object.keys(response);
const timestampsNo = timestamps.map(Number);
if (timestamps.length > 1) {
timestamps.sort((a, b) => a - b);
timestampsNo.sort((a, b) => a - b);
}
const entryCount = timestamps.length;
for (let s = 0; s < entryCount; s++) {
const entry = new RunEntry(this.scene, response, timestamps[s], s);
const entry = new RunEntry(this.scene, response, timestampsNo[s].toString(), s);
this.scene.add.existing(entry);
this.runsContainer.add(entry);
this.runs.push(entry);
@ -215,18 +212,21 @@ export default class RunHistoryUiHandler extends MessageUiHandler {
class RunEntry extends Phaser.GameObjects.Container {
public slotId: integer;
public hasData: boolean;
public entryData: RunHistoryData;
private loadingLabel: Phaser.GameObjects.Text;
constructor(scene: BattleScene, runHistory: RunHistoryData, timestamp: string, slotId: integer) {
constructor(scene: BattleScene, runHistory: any, timestamp: string, slotId: integer) {
super(scene, 0, slotId*56);
this.slotId = slotId;
this.hasData = true;
this.entryData = runHistory[timestamp];
this.setup(runHistory[timestamp]);
this.setup(this.entryData);
}
setup(run: RunHistoryData) {
setup(run: any) {
const victory = run.victory;
const data = this.scene.gameData.parseSessionData(JSON.stringify(run.entry));
@ -236,12 +236,12 @@ class RunEntry extends Phaser.GameObjects.Container {
if (victory) {
const gameOutcomeLabel = addTextObject(this.scene, 8, 5, "Victory", TextStyle.WINDOW);
const gameOutcomeLabel = addTextObject(this.scene, 8, 5, `${i18next.t("runHistory:victory")}`, TextStyle.WINDOW);
this.add(gameOutcomeLabel);
} else {
if (data.battleType === BattleType.WILD) {
const enemyContainer = this.scene.add.container(8, 5);
const gameOutcomeLabel = addTextObject(this.scene, 0, 0, "Defeated by ", TextStyle.WINDOW);
const gameOutcomeLabel = addTextObject(this.scene, 0, 0, `${i18next.t("runHistory:defeatedWild")}`, TextStyle.WINDOW);
enemyContainer.add(gameOutcomeLabel);
data.enemyParty.forEach((enemyData, e) => {
//This allows the enemyParty to be shown - doubles or sings -> 58+(e*8)
@ -250,7 +250,7 @@ class RunEntry extends Phaser.GameObjects.Container {
enemyData.boss = false;
const enemy = enemyData.toPokemon(this.scene);
const enemyIcon = this.scene.addPokemonIcon(enemy, 0, 0, 0, 0);
const enemyLevel = addTextObject(this.scene, 32, 20, `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" });
enemyLevel.setShadow(0, 0, null);
enemyLevel.setStroke("#424242", 14);
enemyLevel.setOrigin(1, 0);
@ -262,46 +262,46 @@ class RunEntry extends Phaser.GameObjects.Container {
this.add(enemyContainer);
} else if (data.battleType === BattleType.TRAINER) {
const tObj = data.trainer.toTrainer(this.scene);
const tType = TrainerType[data.trainer.trainerType];
if (data.trainer.trainerType >= 375) {
const gameOutcomeLabel = addTextObject(this.scene, 8, 5, "Defeated by Rival", TextStyle.WINDOW);
const gameOutcomeLabel = addTextObject(this.scene, 8, 5, `${i18next.t("runHistory:defeatedRival")}`, TextStyle.WINDOW);
//otherwise it becomes Rival_5 in Ivy's case
this.add(gameOutcomeLabel);
} else if (data.trainer.variant === TrainerVariant.DOUBLE) {
const gameOutcomeLabel = addTextObject(this.scene, 8, 5, `${i18next.t("runHistory:defeatedTrainer")+tObj.config.nameDouble+" "+tObj.getName(0, false)}`, TextStyle.WINDOW);
this.add(gameOutcomeLabel);
} else {
if (tObj.variant === TrainerVariant.DOUBLE) {
const gameOutcomeLabel = addTextObject(this.scene, 8, 5, "Defeated by Duo", TextStyle.WINDOW);
}
const gameOutcomeLabel = addTextObject(this.scene, 8, 5, `Defeated by ${tObj.getName(0, true)}`, TextStyle.WINDOW);
const gameOutcomeLabel = addTextObject(this.scene, 8, 5, `${i18next.t("runHistory:defeatedTrainer")+tObj.getName(0, true)}`, TextStyle.WINDOW);
this.add(gameOutcomeLabel);
}
}
}
const gameModeLabel = addTextObject(this.scene, 8, 19, "", 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);
break;
case GameModes.DAILY:
gameModeLabel.appendText(`${i18next.t("gameMode:dailyRun")}`, false);
break;
case GameModes.SPLICED_ENDLESS:
gameModeLabel.appendText(`${i18next.t("gameMode:splicedEndless")}`, false);
break;
case GameModes.ENDLESS:
gameModeLabel.appendText(`${i18next.t("gameMode:endless")}`, false);
break;
case GameModes.CLASSIC:
gameModeLabel.appendText(`${i18next.t("gameMode:classic")}`, false);
break;
case GameModes.CHALLENGE:
gameModeLabel.appendText(`${i18next.t("gameMode:challenge")}`, false);
break;
}
const date = new Date(data.timestamp);
gameModeLabel.appendText(" - ", false);
gameModeLabel.appendText(i18next.t("saveSlotSelectUiHandler:wave")+" "+data.waveIndex, false);
this.add(gameModeLabel);
const timestampLabel = addTextObject(this.scene, 8, 33, new Date(data.timestamp).toLocaleString(), TextStyle.WINDOW);
this.add(timestampLabel);
const pokemonIconsContainer = this.scene.add.container(125, 17);
let luckValue = 0;
data.party.forEach((p: PokemonData, i: integer) => {
const iconContainer = this.scene.add.container(26 * i, 0);
@ -309,7 +309,7 @@ class RunEntry extends Phaser.GameObjects.Container {
const pokemon = p.toPokemon(this.scene);
const icon = this.scene.addPokemonIcon(pokemon, 0, 0, 0, 0);
const text = addTextObject(this.scene, 32, 20, `Lv${Utils.formatLargeNumber(pokemon.level, 1000)}`, TextStyle.PARTY, { fontSize: "54px", color: "#f8f8f8" });
const text = addTextObject(this.scene, 32, 20, `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(pokemon.level, 1000)}`, TextStyle.PARTY, { fontSize: "54px", color: "#f8f8f8" });
text.setShadow(0, 0, null);
text.setStroke("#424242", 14);
text.setOrigin(1, 0);
@ -319,52 +319,10 @@ class RunEntry extends Phaser.GameObjects.Container {
pokemonIconsContainer.add(iconContainer);
luckValue += pokemon.getLuck();
pokemon.destroy();
});
this.add(pokemonIconsContainer);
//Display Score - only visible for Daily Mode
//Display Luck - only visible for Endless Modes
switch (data.gameMode) {
case GameModes.DAILY:
const runScore = data.score;
const scoreText = addTextObject(this.scene, 240, 5, `Score: ${data.score}`, TextStyle.WINDOW, {color: "#f89890"});
this.add(scoreText);
break;
case GameModes.ENDLESS:
case GameModes.SPLICED_ENDLESS:
if (luckValue > 14) {
luckValue = 14;
}
const luckTextTint = "#"+(getLuckTextTint(luckValue)).toString(16);
const luckText = addTextObject(this.scene, 240, 5, `Luck: ${getLuckString(luckValue)}`, TextStyle.WINDOW, {color: `${luckTextTint}`});
this.add(luckText);
break;
}
/*
const modifiersModule = import("../modifier/modifier");
const modifierIconsContainer = this.scene.add.container(148, 30);
modifierIconsContainer.setScale(0.5);
let visibleModifierIndex = 0;
for (const m of data.modifiers) {
const modifier = m.toModifier(this.scene, modifiersModule[m.className]);
if (modifier instanceof PokemonHeldItemModifier) {
continue;
}
const icon = modifier.getIcon(this.scene, false);
icon.setPosition(24 * visibleModifierIndex, 0);
modifierIconsContainer.add(icon);
if (++visibleModifierIndex === 12) {
break;
}
}
this.add(modifierIconsContainer);
*/
}
}

View File

@ -44,9 +44,9 @@ import SettingsKeyboardUiHandler from "#app/ui/settings/settings-keyboard-ui-han
import KeyboardBindingUiHandler from "#app/ui/settings/keyboard-binding-ui-handler";
import SettingsDisplayUiHandler from "./settings/settings-display-ui-handler";
import SettingsAudioUiHandler from "./settings/settings-audio-ui-handler";
import RunHistoryUiHandler from "./run-history-ui-handler";
import RunInfoUiHandler from "./run-info-ui-handler";
import { PlayerGender } from "#enums/player-gender";
import BgmBar from "#app/ui/bgm-bar";
import RenameFormUiHandler from "./rename-form-ui-handler";
export enum Mode {
MESSAGE,
@ -74,6 +74,8 @@ export enum Mode {
SETTINGS_KEYBOARD,
KEYBOARD_BINDING,
ACHIEVEMENTS,
RUN_HISTORY,
RUN_INFO,
GAME_STATS,
VOUCHERS,
EGG_LIST,
@ -84,8 +86,7 @@ export enum Mode {
SESSION_RELOAD,
UNAVAILABLE,
OUTDATED,
CHALLENGE_SELECT,
RENAME_POKEMON
CHALLENGE_SELECT
}
const transitionModes = [
@ -117,12 +118,12 @@ const noTransitionModes = [
Mode.GAME_STATS,
Mode.VOUCHERS,
Mode.LOGIN_FORM,
Mode.RUN_HISTORY,
Mode.REGISTRATION_FORM,
Mode.LOADING,
Mode.SESSION_RELOAD,
Mode.UNAVAILABLE,
Mode.OUTDATED,
Mode.RENAME_POKEMON
Mode.OUTDATED
];
export default class UI extends Phaser.GameObjects.Container {
@ -131,7 +132,6 @@ export default class UI extends Phaser.GameObjects.Container {
public handlers: UiHandler[];
private overlay: Phaser.GameObjects.Rectangle;
public achvBar: AchvBar;
public bgmBar: BgmBar;
public savingIcon: SavingIconHandler;
private tooltipContainer: Phaser.GameObjects.Container;
@ -164,7 +164,6 @@ export default class UI extends Phaser.GameObjects.Container {
new OptionSelectUiHandler(scene),
new MenuUiHandler(scene),
new OptionSelectUiHandler(scene, Mode.MENU_OPTION_SELECT),
// settings
new SettingsUiHandler(scene),
new SettingsDisplayUiHandler(scene),
new SettingsAudioUiHandler(scene),
@ -173,6 +172,8 @@ export default class UI extends Phaser.GameObjects.Container {
new SettingsKeyboardUiHandler(scene),
new KeyboardBindingUiHandler(scene),
new AchvsUiHandler(scene),
new RunHistoryUiHandler(scene),
new RunInfoUiHandler(scene),
new GameStatsUiHandler(scene),
new VouchersUiHandler(scene),
new EggListUiHandler(scene),
@ -183,18 +184,16 @@ export default class UI extends Phaser.GameObjects.Container {
new SessionReloadModalUiHandler(scene),
new UnavailableModalUiHandler(scene),
new OutdatedModalUiHandler(scene),
new GameChallengesUiHandler(scene),
new RenameFormUiHandler(scene),
new GameChallengesUiHandler(scene)
];
}
setup(): void {
this.setName(`ui-${Mode[this.mode]}`);
this.setName("container-ui");
for (const handler of this.handlers) {
handler.setup();
}
this.overlay = this.scene.add.rectangle(0, 0, this.scene.game.canvas.width / 6, this.scene.game.canvas.height / 6, 0);
this.overlay.setName("rect-ui-overlay");
this.overlay.setOrigin(0, 0);
(this.scene as BattleScene).uiContainer.add(this.overlay);
this.overlay.setVisible(false);
@ -213,19 +212,15 @@ export default class UI extends Phaser.GameObjects.Container {
private setupTooltip() {
this.tooltipContainer = this.scene.add.container(0, 0);
this.tooltipContainer.setName("tooltip");
this.tooltipContainer.setVisible(false);
this.tooltipBg = addWindow(this.scene as BattleScene, 0, 0, 128, 31);
this.tooltipBg.setName("window-tooltip-bg");
this.tooltipBg.setOrigin(0, 0);
this.tooltipTitle = addTextObject(this.scene, 64, 4, "", TextStyle.TOOLTIP_TITLE);
this.tooltipTitle.setName("text-tooltip-title");
this.tooltipTitle.setOrigin(0.5, 0);
this.tooltipContent = addTextObject(this.scene, 6, 16, "", TextStyle.TOOLTIP_CONTENT);
this.tooltipContent.setName("text-tooltip-content");
this.tooltipContent.setWordWrapWidth(696);
this.tooltipContainer.add(this.tooltipBg);
@ -235,8 +230,8 @@ export default class UI extends Phaser.GameObjects.Container {
(this.scene as BattleScene).uiContainer.add(this.tooltipContainer);
}
getHandler<H extends UiHandler = UiHandler>(): H {
return this.handlers[this.mode] as H;
getHandler(): UiHandler {
return this.handlers[this.mode];
}
getMessageHandler(): BattleMessageUiHandler {
@ -253,6 +248,7 @@ export default class UI extends Phaser.GameObjects.Container {
battleScene?.processInfoButton(pressed);
return true;
}
battleScene?.processInfoButton(false);
return true;
}
@ -459,6 +455,7 @@ export default class UI extends Phaser.GameObjects.Container {
touchControls.dataset.uiMode = Mode[mode];
}
this.getHandler().show(args);
console.log(args);
}
resolve();
};