Cleanup game-stats-ui-handler (from PR #1095) (#1106)

* Update i18n.ts

* Update config.ts

* Update game-stats-ui-handler.ts

* Add files via upload

* Cleanup code

  + Modification of the interface to manage labels dynamically (without this, the language change was not reflected until the page was completely refreshed)

* Apply ESLint after rebase on upstream/main

* Remove useless initStatsKeys

* Adds german localization

  + Changes font size in german only (because otherwise it overflows :D)

* Adds an additional method of formatting large numbers to make it a little more pleasant to read

  + The other was a little too barbaric in what it truncated, but is still useful in certain cases
  + Use abbreviations from 10^0 to 10^33

* Use of the new 'formatFancyLargeNumber' method to display money owned in combat and the highest sum of money obtained in statistics

---------

Co-authored-by: Lugiad <adrien.grivel@hotmail.fr>
Co-authored-by: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com>
This commit is contained in:
Dakurei 2024-05-27 13:58:20 +02:00 committed by GitHub
parent da5370cbd5
commit 6d2b8ef2d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 547 additions and 75 deletions

View File

@ -1264,7 +1264,7 @@ export default class BattleScene extends SceneBase {
}
updateMoneyText(): void {
this.moneyText.setText(`${Utils.formatLargeNumber(this.money, 1000)}`);
this.moneyText.setText(`${Utils.formatFancyLargeNumber(this.money, 3)}`);
this.moneyText.setVisible(true);
}

View File

@ -9,7 +9,6 @@ import { WindowVariant, getWindowVariantSuffix } from "./ui/ui-theme";
import { isMobile } from "./touch-controls";
import * as Utils from "./utils";
import { initI18n } from "./plugins/i18n";
import {initStatsKeys} from "#app/ui/game-stats-ui-handler";
import {initPokemonPrevolutions} from "#app/data/pokemon-evolutions";
import {initBiomes} from "#app/data/biomes";
import {initEggMoves} from "#app/data/egg-moves";
@ -310,7 +309,6 @@ export class LoadingScene extends SceneBase {
this.loadLoadingScreen();
initStatsKeys();
initPokemonPrevolutions();
initBiomes();
initEggMoves();

View File

@ -20,6 +20,7 @@ import { tutorial } from "./tutorial";
import { weather } from "./weather";
import { battleMessageUiHandler } from "./battle-message-ui-handler";
import { berry } from "./berry";
import { gameStatsUiHandler } from "./game-stats-ui-handler";
import { voucher } from "./voucher";
import {
PGMdialogue,
@ -56,6 +57,7 @@ export const deConfig = {
weather: weather,
battleMessageUiHandler: battleMessageUiHandler,
berry: berry,
gameStatsUiHandler: gameStatsUiHandler,
voucher: voucher,
biome: biome,
PGMdialogue: PGMdialogue,

View File

@ -0,0 +1,44 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const gameStatsUiHandler: SimpleTranslationEntries = {
"stats": "Statistiken",
"playTime": "Spielzeit",
"totalBattles": "Kämpfe insgesamt",
"starters": "Starter",
"shinyStarters": "Schillernde Starter",
"speciesSeen": "Gesehene Arten",
"speciesCaught": "Gefangene Arten",
"ribbonsOwned": "Bänder im Besitz",
"classicRuns": "Klassik-Modus Versuche",
"classicWins": "Klassik-Modus Siege",
"dailyRunAttempts": "Täglicher-Modus Versuche",
"dailyRunWins": "Täglicher-Modus Siege",
"endlessRuns": "Endlos-Modus Versuche",
"highestWaveEndless": "Höchste Welle (Endlos)",
"highestMoney": "Max. Geld im Besitz",
"highestDamage": "Höchster Schaden",
"highestHPHealed": "Höchste Heilung",
"pokemonEncountered": "Getroffene Pokémon",
"pokemonDefeated": "Besiegte Pokémon",
"pokemonCaught": "Gefangene Pokémon",
"eggsHatched": "Ausgebrütete Eier",
"subLegendsSeen": "Getroffene Sub-Legenden",
"subLegendsCaught": "Gefangene Sub-Legenden",
"subLegendsHatched": "Ausgebrütete Sub-Legenden",
"legendsSeen": "Getroffene Legenden",
"legendsCaught": "Gefangene Legenden",
"legendsHatched": "Ausgebrütete Legenden",
"mythicalsSeen": "Getroffene Mythische",
"mythicalsCaught": "Gefangene Mythische",
"mythicalsHatched": "Ausgebrütete Mythische",
"shiniesSeen": "Getroffene Schillernde",
"shiniesCaught": "Gefangene Schillernde",
"shiniesHatched": "Ausgebrütete Schillernde",
"pokemonFused": "Pokémon fusioniert",
"trainersDefeated": "Besiegte Trainer",
"eggsPulled": "Gezogene Eier",
"rareEggsPulled": "Seltene Eier Gezogen",
"epicEggsPulled": "Epische Eier Gezogen",
"legendaryEggsPulled": "Legendäre Eier Gezogen",
"manaphyEggsPulled": "Manaphy Eier Gezogen",
} as const;

View File

@ -20,6 +20,7 @@ import { tutorial } from "./tutorial";
import { weather } from "./weather";
import { battleMessageUiHandler } from "./battle-message-ui-handler";
import { berry } from "./berry";
import { gameStatsUiHandler } from "./game-stats-ui-handler";
import { voucher } from "./voucher";
import {
PGMdialogue,
@ -56,6 +57,7 @@ export const enConfig = {
weather: weather,
battleMessageUiHandler: battleMessageUiHandler,
berry: berry,
gameStatsUiHandler: gameStatsUiHandler,
voucher: voucher,
biome: biome,
PGMdialogue: PGMdialogue,

View File

@ -0,0 +1,44 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const gameStatsUiHandler: SimpleTranslationEntries = {
"stats": "Stats",
"playTime": "Play Time",
"totalBattles": "Total Battles",
"starters": "Starters",
"shinyStarters": "Shiny Starters",
"speciesSeen": "Species Seen",
"speciesCaught": "Species Caught",
"ribbonsOwned": "Ribbons Owned",
"classicRuns": "Classic Runs",
"classicWins": "Classic Wins",
"dailyRunAttempts": "Daily Run Attempts",
"dailyRunWins": "Daily Run Wins",
"endlessRuns": "Endless Runs",
"highestWaveEndless": "Highest Wave (Endless)",
"highestMoney": "Highest Money",
"highestDamage": "Highest Damage",
"highestHPHealed": "Highest HP Healed",
"pokemonEncountered": "Pokémon Encountered",
"pokemonDefeated": "Pokémon Defeated",
"pokemonCaught": "Pokémon Caught",
"eggsHatched": "Eggs Hatched",
"subLegendsSeen": "Sub-Legends Seen",
"subLegendsCaught": "Sub-Legends Caught",
"subLegendsHatched": "Sub-Legends Hatched",
"legendsSeen": "Legends Seen",
"legendsCaught": "Legends Caught",
"legendsHatched": "Legends Hatched",
"mythicalsSeen": "Mythicals Seen",
"mythicalsCaught": "Mythicals Caught",
"mythicalsHatched": "Mythicals Hatched",
"shiniesSeen": "Shinies Seen",
"shiniesCaught": "Shinies Caught",
"shiniesHatched": "Shinies Hatched",
"pokemonFused": "Pokémon Fused",
"trainersDefeated": "Trainers Defeated",
"eggsPulled": "Eggs Pulled",
"rareEggsPulled": "Rare Eggs Pulled",
"epicEggsPulled": "Epic Eggs Pulled",
"legendaryEggsPulled": "Legendary Eggs Pulled",
"manaphyEggsPulled": "Manaphy Eggs Pulled",
} as const;

View File

@ -20,6 +20,7 @@ import { tutorial } from "./tutorial";
import { weather } from "./weather";
import { battleMessageUiHandler } from "./battle-message-ui-handler";
import { berry } from "./berry";
import { gameStatsUiHandler } from "./game-stats-ui-handler";
import { voucher } from "./voucher";
import {
PGMdialogue,
@ -56,6 +57,7 @@ export const esConfig = {
weather: weather,
battleMessageUiHandler: battleMessageUiHandler,
berry: berry,
gameStatsUiHandler: gameStatsUiHandler,
voucher: voucher,
biome: biome,
PGMdialogue: PGMdialogue,

View File

@ -0,0 +1,44 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const gameStatsUiHandler: SimpleTranslationEntries = {
"stats": "Stats",
"playTime": "Play Time",
"totalBattles": "Total Battles",
"starters": "Starters",
"shinyStarters": "Shiny Starters",
"speciesSeen": "Species Seen",
"speciesCaught": "Species Caught",
"ribbonsOwned": "Ribbons Owned",
"classicRuns": "Classic Runs",
"classicWins": "Classic Wins",
"dailyRunAttempts": "Daily Run Attempts",
"dailyRunWins": "Daily Run Wins",
"endlessRuns": "Endless Runs",
"highestWaveEndless": "Highest Wave (Endless)",
"highestMoney": "Highest Money",
"highestDamage": "Highest Damage",
"highestHPHealed": "Highest HP Healed",
"pokemonEncountered": "Pokémon Encountered",
"pokemonDefeated": "Pokémon Defeated",
"pokemonCaught": "Pokémon Caught",
"eggsHatched": "Eggs Hatched",
"subLegendsSeen": "Sub-Legends Seen",
"subLegendsCaught": "Sub-Legends Caught",
"subLegendsHatched": "Sub-Legends Hatched",
"legendsSeen": "Legends Seen",
"legendsCaught": "Legends Caught",
"legendsHatched": "Legends Hatched",
"mythicalsSeen": "Mythicals Seen",
"mythicalsCaught": "Mythicals Caught",
"mythicalsHatched": "Mythicals Hatched",
"shiniesSeen": "Shinies Seen",
"shiniesCaught": "Shinies Caught",
"shiniesHatched": "Shinies Hatched",
"pokemonFused": "Pokémon Fused",
"trainersDefeated": "Trainers Defeated",
"eggsPulled": "Eggs Pulled",
"rareEggsPulled": "Rare Eggs Pulled",
"epicEggsPulled": "Epic Eggs Pulled",
"legendaryEggsPulled": "Legendary Eggs Pulled",
"manaphyEggsPulled": "Manaphy Eggs Pulled",
} as const;

View File

@ -20,6 +20,7 @@ import { tutorial } from "./tutorial";
import { weather } from "./weather";
import { battleMessageUiHandler } from "./battle-message-ui-handler";
import { berry } from "./berry";
import { gameStatsUiHandler } from "./game-stats-ui-handler";
import { voucher } from "./voucher";
import {
PGMdialogue,
@ -56,6 +57,7 @@ export const frConfig = {
weather: weather,
battleMessageUiHandler: battleMessageUiHandler,
berry: berry,
gameStatsUiHandler: gameStatsUiHandler,
voucher: voucher,
biome: biome,
PGMdialogue: PGMdialogue,

View File

@ -0,0 +1,44 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const gameStatsUiHandler: SimpleTranslationEntries = {
"stats": "Statistiques",
"playTime": "Temps de jeu",
"totalBattles": "Total combats",
"shinyStarters": "Starters chroma",
"starters": "Starters",
"speciesSeen": "Espèces vues",
"speciesCaught": "Espèces capt.",
"ribbonsOwned": "Rubans possédés",
"classicRuns": "Parties en Classique",
"classicWins": "Victoires en Classique",
"dailyRunAttempts": "Essais Défi du jour",
"dailyRunWins": "Victoires Défi du jour",
"endlessRuns": "Parties en Infini",
"highestWaveEndless": "Record vagues (Infini)",
"highestMoney": "Record dargent",
"highestDamage": "Record de dégâts",
"highestHPHealed": "Record PV soignés",
"pokemonEncountered": "Pokémon rencontrés",
"pokemonDefeated": "Pokémon battus",
"pokemonCaught": "Pokémon capturés",
"eggsHatched": "Œufs éclos",
"subLegendsSeen": "Semi-légendaires vus",
"subLegendsCaught": "Semi-légendaires capt.",
"subLegendsHatched": "Semi-légendaires éclos",
"legendsSeen": "Legendaires vus",
"legendsCaught": "Légendaires capt.",
"legendsHatched": "Légendaires éclos",
"mythicalsSeen": "Fabuleux vus",
"mythicalsCaught": "Fabuleux capt.",
"mythicalsHatched": "Fabuleux éclos",
"shiniesSeen": "Chromatiques vus",
"shiniesCaught": "Chromatiques capt.",
"shiniesHatched": "Chromatiques éclos",
"pokemonFused": "Pokémon fusionnés",
"trainersDefeated": "Dresseurs battus",
"eggsPulled": "Œufs obtenus",
"rareEggsPulled": "Œufs Rares",
"epicEggsPulled": "Œufs Épiques",
"legendaryEggsPulled": "Œufs Légendaires",
"manaphyEggsPulled": "Œufs de Manaphy",
} as const;

View File

@ -20,6 +20,7 @@ import { tutorial } from "./tutorial";
import { weather } from "./weather";
import { battleMessageUiHandler } from "./battle-message-ui-handler";
import { berry } from "./berry";
import { gameStatsUiHandler } from "./game-stats-ui-handler";
import { voucher } from "./voucher";
import {
PGMdialogue,
@ -56,6 +57,7 @@ export const itConfig = {
weather: weather,
battleMessageUiHandler: battleMessageUiHandler,
berry: berry,
gameStatsUiHandler: gameStatsUiHandler,
voucher: voucher,
biome: biome,
PGMdialogue: PGMdialogue,

View File

@ -0,0 +1,44 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const gameStatsUiHandler: SimpleTranslationEntries = {
"stats": "Stats",
"playTime": "Play Time",
"totalBattles": "Total Battles",
"starters": "Starters",
"shinyStarters": "Shiny Starters",
"speciesSeen": "Species Seen",
"speciesCaught": "Species Caught",
"ribbonsOwned": "Ribbons Owned",
"classicRuns": "Classic Runs",
"classicWins": "Classic Wins",
"dailyRunAttempts": "Daily Run Attempts",
"dailyRunWins": "Daily Run Wins",
"endlessRuns": "Endless Runs",
"highestWaveEndless": "Highest Wave (Endless)",
"highestMoney": "Highest Money",
"highestDamage": "Highest Damage",
"highestHPHealed": "Highest HP Healed",
"pokemonEncountered": "Pokémon Encountered",
"pokemonDefeated": "Pokémon Defeated",
"pokemonCaught": "Pokémon Caught",
"eggsHatched": "Eggs Hatched",
"subLegendsSeen": "Sub-Legends Seen",
"subLegendsCaught": "Sub-Legends Caught",
"subLegendsHatched": "Sub-Legends Hatched",
"legendsSeen": "Legends Seen",
"legendsCaught": "Legends Caught",
"legendsHatched": "Legends Hatched",
"mythicalsSeen": "Mythicals Seen",
"mythicalsCaught": "Mythicals Caught",
"mythicalsHatched": "Mythicals Hatched",
"shiniesSeen": "Shinies Seen",
"shiniesCaught": "Shinies Caught",
"shiniesHatched": "Shinies Hatched",
"pokemonFused": "Pokémon Fused",
"trainersDefeated": "Trainers Defeated",
"eggsPulled": "Eggs Pulled",
"rareEggsPulled": "Rare Eggs Pulled",
"epicEggsPulled": "Epic Eggs Pulled",
"legendaryEggsPulled": "Legendary Eggs Pulled",
"manaphyEggsPulled": "Manaphy Eggs Pulled",
} as const;

View File

@ -20,6 +20,7 @@ import { tutorial } from "./tutorial";
import { weather } from "./weather";
import { battleMessageUiHandler } from "./battle-message-ui-handler";
import { berry } from "./berry";
import { gameStatsUiHandler } from "./game-stats-ui-handler";
import { voucher } from "./voucher";
import {
PGMdialogue,
@ -56,6 +57,7 @@ export const ptBrConfig = {
weather: weather,
battleMessageUiHandler: battleMessageUiHandler,
berry: berry,
gameStatsUiHandler: gameStatsUiHandler,
voucher: voucher,
biome: biome,
PGMdialogue: PGMdialogue,

View File

@ -0,0 +1,44 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const gameStatsUiHandler: SimpleTranslationEntries = {
"stats": "Stats",
"playTime": "Play Time",
"totalBattles": "Total Battles",
"starters": "Starters",
"shinyStarters": "Shiny Starters",
"speciesSeen": "Species Seen",
"speciesCaught": "Species Caught",
"ribbonsOwned": "Ribbons Owned",
"classicRuns": "Classic Runs",
"classicWins": "Classic Wins",
"dailyRunAttempts": "Daily Run Attempts",
"dailyRunWins": "Daily Run Wins",
"endlessRuns": "Endless Runs",
"highestWaveEndless": "Highest Wave (Endless)",
"highestMoney": "Highest Money",
"highestDamage": "Highest Damage",
"highestHPHealed": "Highest HP Healed",
"pokemonEncountered": "Pokémon Encountered",
"pokemonDefeated": "Pokémon Defeated",
"pokemonCaught": "Pokémon Caught",
"eggsHatched": "Eggs Hatched",
"subLegendsSeen": "Sub-Legends Seen",
"subLegendsCaught": "Sub-Legends Caught",
"subLegendsHatched": "Sub-Legends Hatched",
"legendsSeen": "Legends Seen",
"legendsCaught": "Legends Caught",
"legendsHatched": "Legends Hatched",
"mythicalsSeen": "Mythicals Seen",
"mythicalsCaught": "Mythicals Caught",
"mythicalsHatched": "Mythicals Hatched",
"shiniesSeen": "Shinies Seen",
"shiniesCaught": "Shinies Caught",
"shiniesHatched": "Shinies Hatched",
"pokemonFused": "Pokémon Fused",
"trainersDefeated": "Trainers Defeated",
"eggsPulled": "Eggs Pulled",
"rareEggsPulled": "Rare Eggs Pulled",
"epicEggsPulled": "Epic Eggs Pulled",
"legendaryEggsPulled": "Legendary Eggs Pulled",
"manaphyEggsPulled": "Manaphy Eggs Pulled",
} as const;

View File

@ -20,6 +20,7 @@ import { tutorial } from "./tutorial";
import { weather } from "./weather";
import { battleMessageUiHandler } from "./battle-message-ui-handler";
import { berry } from "./berry";
import { gameStatsUiHandler } from "./game-stats-ui-handler";
import { voucher } from "./voucher";
import {
PGMdialogue,
@ -56,6 +57,7 @@ export const zhCnConfig = {
weather: weather,
battleMessageUiHandler: battleMessageUiHandler,
berry: berry,
gameStatsUiHandler: gameStatsUiHandler,
voucher: voucher,
biome: biome,
PGMdialogue: PGMdialogue,

View File

@ -0,0 +1,44 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const gameStatsUiHandler: SimpleTranslationEntries = {
"stats": "Stats",
"playTime": "Play Time",
"totalBattles": "Total Battles",
"starters": "Starters",
"shinyStarters": "Shiny Starters",
"speciesSeen": "Species Seen",
"speciesCaught": "Species Caught",
"ribbonsOwned": "Ribbons Owned",
"classicRuns": "Classic Runs",
"classicWins": "Classic Wins",
"dailyRunAttempts": "Daily Run Attempts",
"dailyRunWins": "Daily Run Wins",
"endlessRuns": "Endless Runs",
"highestWaveEndless": "Highest Wave (Endless)",
"highestMoney": "Highest Money",
"highestDamage": "Highest Damage",
"highestHPHealed": "Highest HP Healed",
"pokemonEncountered": "Pokémon Encountered",
"pokemonDefeated": "Pokémon Defeated",
"pokemonCaught": "Pokémon Caught",
"eggsHatched": "Eggs Hatched",
"subLegendsSeen": "Sub-Legends Seen",
"subLegendsCaught": "Sub-Legends Caught",
"subLegendsHatched": "Sub-Legends Hatched",
"legendsSeen": "Legends Seen",
"legendsCaught": "Legends Caught",
"legendsHatched": "Legends Hatched",
"mythicalsSeen": "Mythicals Seen",
"mythicalsCaught": "Mythicals Caught",
"mythicalsHatched": "Mythicals Hatched",
"shiniesSeen": "Shinies Seen",
"shiniesCaught": "Shinies Caught",
"shiniesHatched": "Shinies Hatched",
"pokemonFused": "Pokémon Fused",
"trainersDefeated": "Trainers Defeated",
"eggsPulled": "Eggs Pulled",
"rareEggsPulled": "Rare Eggs Pulled",
"epicEggsPulled": "Epic Eggs Pulled",
"legendaryEggsPulled": "Legendary Eggs Pulled",
"manaphyEggsPulled": "Manaphy Eggs Pulled",
} as const;

View File

@ -178,6 +178,7 @@ declare module "i18next" {
modifierType: ModifierTypeTranslationEntries;
battleMessageUiHandler: SimpleTranslationEntries;
berry: BerryTranslationEntries;
gameStatsUiHandler: SimpleTranslationEntries;
voucher: SimpleTranslationEntries;
biome: SimpleTranslationEntries;
PGMdialogue: DialogueTranslationEntries;

View File

@ -7,9 +7,10 @@ import * as Utils from "../utils";
import { DexAttr, GameData } from "../system/game-data";
import { speciesStarters } from "../data/pokemon-species";
import {Button} from "../enums/buttons";
import i18next from "../plugins/i18n";
interface DisplayStat {
label?: string;
label_key?: string;
sourceFunc?: (gameData: GameData) => string;
hidden?: boolean;
}
@ -20,70 +21,193 @@ interface DisplayStats {
const displayStats: DisplayStats = {
playTime: {
label_key: "playTime",
sourceFunc: gameData => Utils.getPlayTimeString(gameData.gameStats.playTime)
},
battles: "Total Battles",
battles: {
label_key: "totalBattles",
sourceFunc: gameData => gameData.gameStats.battles.toString(),
},
startersUnlocked: {
label: "Starters",
label_key: "starters",
sourceFunc: gameData => {
const starterCount = gameData.getStarterCount(d => !!d.caughtAttr);
return `${starterCount} (${Math.floor((starterCount / Object.keys(speciesStarters).length) * 1000) / 10}%)`;
}
},
shinyStartersUnlocked: {
label: "Shiny Starters",
label_key: "shinyStarters",
sourceFunc: gameData => {
const starterCount = gameData.getStarterCount(d => !!(d.caughtAttr & DexAttr.SHINY));
return `${starterCount} (${Math.floor((starterCount / Object.keys(speciesStarters).length) * 1000) / 10}%)`;
}
},
dexSeen: {
label: "Species Seen",
label_key: "speciesSeen",
sourceFunc: gameData => {
const seenCount = gameData.getSpeciesCount(d => !!d.seenAttr);
return `${seenCount} (${Math.floor((seenCount / Object.keys(gameData.dexData).length) * 1000) / 10}%)`;
}
},
dexCaught: {
label: "Species Caught",
label_key: "speciesCaught",
sourceFunc: gameData => {
const caughtCount = gameData.getSpeciesCount(d => !!d.caughtAttr);
return `${caughtCount} (${Math.floor((caughtCount / Object.keys(gameData.dexData).length) * 1000) / 10}%)`;
}
},
ribbonsOwned: "Ribbons Owned",
classicSessionsPlayed: "Classic Runs",
sessionsWon: "Classic Wins",
dailyRunSessionsPlayed: "Daily Run Attempts",
dailyRunSessionsWon: "Daily Run Wins",
endlessSessionsPlayed: "Endless Runs?",
highestEndlessWave: "Highest Wave (Endless)?",
highestMoney: "Highest Money",
highestDamage: "Highest Damage",
highestHeal: "Highest HP Healed",
pokemonSeen: "Pokémon Encountered",
pokemonDefeated: "Pokémon Defeated",
pokemonCaught: "Pokémon Caught",
pokemonHatched: "Eggs Hatched",
subLegendaryPokemonSeen: "Sub-Legends Seen?",
subLegendaryPokemonCaught: "Sub-Legends Caught?",
subLegendaryPokemonHatched: "Sub-Legends Hatched?",
legendaryPokemonSeen: "Legends Seen?",
legendaryPokemonCaught: "Legends Caught?",
legendaryPokemonHatched: "Legends Hatched?",
mythicalPokemonSeen: "Mythicals Seen?",
mythicalPokemonCaught: "Mythicals Caught?",
mythicalPokemonHatched: "Mythicals Hatched?",
shinyPokemonSeen: "Shinies Seen?",
shinyPokemonCaught: "Shinies Caught?",
shinyPokemonHatched: "Shinies Hatched?",
pokemonFused: "Pokémon Fused?",
trainersDefeated: "Trainers Defeated",
eggsPulled: "Eggs Pulled",
rareEggsPulled: "Rare Eggs Pulled?",
epicEggsPulled: "Epic Eggs Pulled?",
legendaryEggsPulled: "Legendary Eggs Pulled?",
manaphyEggsPulled: "Manaphy Eggs Pulled?"
ribbonsOwned: {
label_key: "ribbonsOwned",
sourceFunc: gameData => gameData.gameStats.ribbonsOwned.toString(),
},
classicSessionsPlayed:{
label_key: "classicRuns",
sourceFunc: gameData => gameData.gameStats.classicSessionsPlayed.toString(),
},
sessionsWon: {
label_key: "classicWins",
sourceFunc: gameData => gameData.gameStats.sessionsWon.toString(),
},
dailyRunSessionsPlayed: {
label_key: "dailyRunAttempts",
sourceFunc: gameData => gameData.gameStats.dailyRunSessionsPlayed.toString(),
},
dailyRunSessionsWon: {
label_key: "dailyRunWins",
sourceFunc: gameData => gameData.gameStats.dailyRunSessionsWon.toString(),
},
endlessSessionsPlayed: {
label_key: "endlessRuns",
sourceFunc: gameData => gameData.gameStats.endlessSessionsPlayed.toString(),
hidden: true
},
highestEndlessWave: {
label_key: "highestWaveEndless",
sourceFunc: gameData => gameData.gameStats.highestEndlessWave.toString(),
hidden: true
},
highestMoney: {
label_key: "highestMoney",
sourceFunc: gameData => Utils.formatFancyLargeNumber(gameData.gameStats.highestMoney, 3),
},
highestDamage: {
label_key: "highestDamage",
sourceFunc: gameData => gameData.gameStats.highestDamage.toString(),
},
highestHeal: {
label_key: "highestHPHealed",
sourceFunc: gameData => gameData.gameStats.highestHeal.toString(),
},
pokemonSeen: {
label_key: "pokemonEncountered",
sourceFunc: gameData => gameData.gameStats.pokemonSeen.toString(),
},
pokemonDefeated: {
label_key: "pokemonDefeated",
sourceFunc: gameData => gameData.gameStats.pokemonDefeated.toString(),
},
pokemonCaught: {
label_key: "pokemonCaught",
sourceFunc: gameData => gameData.gameStats.pokemonCaught.toString(),
},
pokemonHatched: {
label_key: "eggsHatched",
sourceFunc: gameData => gameData.gameStats.pokemonHatched.toString(),
},
subLegendaryPokemonSeen: {
label_key: "subLegendsSeen",
sourceFunc: gameData => gameData.gameStats.subLegendaryPokemonSeen.toString(),
hidden: true
},
subLegendaryPokemonCaught: {
label_key: "subLegendsCaught",
sourceFunc: gameData => gameData.gameStats.subLegendaryPokemonCaught.toString(),
hidden: true
},
subLegendaryPokemonHatched: {
label_key: "subLegendsHatched",
sourceFunc: gameData => gameData.gameStats.subLegendaryPokemonHatched.toString(),
hidden: true
},
legendaryPokemonSeen: {
label_key: "legendsSeen",
sourceFunc: gameData => gameData.gameStats.legendaryPokemonSeen.toString(),
hidden: true
},
legendaryPokemonCaught: {
label_key: "legendsCaught",
sourceFunc: gameData => gameData.gameStats.legendaryPokemonCaught.toString(),
hidden: true
},
legendaryPokemonHatched: {
label_key: "legendsHatched",
sourceFunc: gameData => gameData.gameStats.legendaryPokemonHatched.toString(),
hidden: true
},
mythicalPokemonSeen: {
label_key: "mythicalsSeen",
sourceFunc: gameData => gameData.gameStats.mythicalPokemonSeen.toString(),
hidden: true
},
mythicalPokemonCaught: {
label_key: "mythicalsCaught",
sourceFunc: gameData => gameData.gameStats.mythicalPokemonCaught.toString(),
hidden: true
},
mythicalPokemonHatched: {
label_key: "mythicalsHatched",
sourceFunc: gameData => gameData.gameStats.legendaryPokemonHatched.toString(),
hidden: true
},
shinyPokemonSeen: {
label_key: "shiniesSeen",
sourceFunc: gameData => gameData.gameStats.shinyPokemonSeen.toString(),
hidden: true
},
shinyPokemonCaught: {
label_key: "shiniesCaught",
sourceFunc: gameData => gameData.gameStats.shinyPokemonCaught.toString(),
hidden: true
},
shinyPokemonHatched: {
label_key: "shiniesHatched",
sourceFunc: gameData => gameData.gameStats.shinyPokemonHatched.toString(),
hidden: true
},
pokemonFused: {
label_key: "pokemonFused",
sourceFunc: gameData => gameData.gameStats.pokemonFused.toString(),
hidden: true
},
trainersDefeated: {
label_key: "trainersDefeated",
sourceFunc: gameData => gameData.gameStats.trainersDefeated.toString(),
},
eggsPulled: {
label_key: "eggsPulled",
sourceFunc: gameData => gameData.gameStats.eggsPulled.toString(),
hidden: true
},
rareEggsPulled: {
label_key: "rareEggsPulled",
sourceFunc: gameData => gameData.gameStats.rareEggsPulled.toString(),
hidden: true
},
epicEggsPulled: {
label_key: "epicEggsPulled",
sourceFunc: gameData => gameData.gameStats.epicEggsPulled.toString(),
hidden: true
},
legendaryEggsPulled: {
label_key: "legendaryEggsPulled",
sourceFunc: gameData => gameData.gameStats.legendaryEggsPulled.toString(),
hidden: true
},
manaphyEggsPulled: {
label_key: "manaphyEggsPulled",
sourceFunc: gameData => gameData.gameStats.manaphyEggsPulled.toString(),
hidden: true
},
};
export default class GameStatsUiHandler extends UiHandler {
@ -110,7 +234,7 @@ export default class GameStatsUiHandler extends UiHandler {
const headerBg = addWindow(this.scene, 0, 0, (this.scene.game.canvas.width / 6) - 2, 24);
headerBg.setOrigin(0, 0);
const headerText = addTextObject(this.scene, 0, 0, "Stats", TextStyle.SETTINGS_LABEL);
const headerText = addTextObject(this.scene, 0, 0, i18next.t("gameStatsUiHandler:stats"), TextStyle.SETTINGS_LABEL);
headerText.setOrigin(0, 0);
headerText.setPositionRelative(headerBg, 8, 4);
@ -127,13 +251,15 @@ export default class GameStatsUiHandler extends UiHandler {
this.statsContainer = this.scene.add.container(0, 0);
new Array(18).fill(null).map((_, s) => {
const statLabel = addTextObject(this.scene, 8 + (s % 2 === 1 ? statsBgWidth : 0), 28 + Math.floor(s / 2) * 16, "", TextStyle.SETTINGS_LABEL);
const statLabel = addTextObject(this.scene, 8 + (s % 2 === 1 ? statsBgWidth : 0), 28 + Math.floor(s / 2) * 16, "", TextStyle.STATS_LABEL);
statLabel.setOrigin(0, 0);
this.statsContainer.add(statLabel);
this.statLabels.push(statLabel);
const statValue = addTextObject(this.scene, (statsBgWidth * ((s % 2) + 1)) - 8, statLabel.y, "", TextStyle.WINDOW);
const statValue = addTextObject(this.scene, (statsBgWidth * ((s % 2) + 1)) - 8, statLabel.y, "", TextStyle.STATS_VALUE);
statValue.setOrigin(1, 0);
this.statsContainer.add(statValue);
this.statValues.push(statValue);
@ -173,7 +299,7 @@ export default class GameStatsUiHandler extends UiHandler {
statKeys.forEach((key, s) => {
const stat = displayStats[key] as DisplayStat;
const value = stat.sourceFunc(this.scene.gameData);
this.statLabels[s].setText(!stat.hidden || isNaN(parseInt(value)) || parseInt(value) ? stat.label : "???");
this.statLabels[s].setText(!stat.hidden || isNaN(parseInt(value)) || parseInt(value) ? i18next.t(`gameStatsUiHandler:${stat.label_key}`) : "???");
this.statValues[s].setText(value);
});
if (statKeys.length < 18) {
@ -229,31 +355,3 @@ export default class GameStatsUiHandler extends UiHandler {
this.gameStatsContainer.setVisible(false);
}
}
export function initStatsKeys() {
const statKeys = Object.keys(displayStats);
for (const key of statKeys) {
if (typeof displayStats[key] === "string") {
let label = displayStats[key] as string;
let hidden = false;
if (label.endsWith("?")) {
label = label.slice(0, -1);
hidden = true;
}
displayStats[key] = {
label: label,
sourceFunc: gameData => gameData.gameStats[key].toString(),
hidden: hidden
};
} else if (displayStats[key] === null) {
displayStats[key] = {
sourceFunc: gameData => gameData.gameStats[key].toString()
};
}
if (!(displayStats[key] as DisplayStat).label) {
const splittableKey = key.replace(/([a-z]{2,})([A-Z]{1}(?:[^A-Z]|$))/g, "$1_$2");
(displayStats[key] as DisplayStat).label = Utils.toReadableString(`${splittableKey[0].toUpperCase()}${splittableKey.slice(1)}`);
}
}
}

View File

@ -22,6 +22,8 @@ export enum TextStyle {
SUMMARY_GRAY,
SUMMARY_GREEN,
MONEY,
STATS_LABEL,
STATS_VALUE,
SETTINGS_LABEL,
SETTINGS_SELECTED,
TOOLTIP_TITLE,
@ -112,6 +114,33 @@ function getTextStyleOptions(style: TextStyle, uiTheme: UiTheme, extraStyleOptio
case TextStyle.WINDOW_ALT:
shadowXpos = 3;
shadowYpos = 3;
break;
case TextStyle.STATS_LABEL:
let fontSizeLabel = "96px";
switch (lang) {
case "de":
fontSizeLabel = "80px";
break;
default:
fontSizeLabel = "96px";
break;
}
styleOptions.fontSize = fontSizeLabel;
break;
case TextStyle.STATS_VALUE:
shadowXpos = 3;
shadowYpos = 3;
let fontSizeValue = "96px";
switch (lang) {
case "de":
fontSizeValue = "80px";
break;
default:
fontSizeValue = "96px";
break;
}
styleOptions.fontSize = fontSizeValue;
break;
case TextStyle.MESSAGE:
case TextStyle.SETTINGS_LABEL:
case TextStyle.SETTINGS_SELECTED:
@ -199,6 +228,10 @@ export function getTextColor(textStyle: TextStyle, shadow?: boolean, uiTheme: Ui
return !shadow ? "#e8e8a8" : "#a0a060";
case TextStyle.SUMMARY_GRAY:
return !shadow ? "#a0a0a0" : "#636363";
case TextStyle.STATS_LABEL:
return !shadow ? "#f8b050" : "#c07800";
case TextStyle.STATS_VALUE:
return !shadow ? "#f8f8f8" : "#6b5a73";
case TextStyle.SUMMARY_GREEN:
return !shadow ? "#78c850" : "#306850";
case TextStyle.SETTINGS_LABEL:

View File

@ -217,6 +217,26 @@ export function formatLargeNumber(count: integer, threshold: integer): string {
return `${ret.slice(0, digits)}${decimalNumber ? `.${decimalNumber}` : ""}${suffix}`;
}
// Abbreviations from 10^0 to 10^33
const AbbreviationsLargeNumber: string[] = ["", "K", "M", "B", "t", "q", "Q", "s", "S", "o", "n", "d"];
export function formatFancyLargeNumber(number: number, rounded: number = 2): string {
let exponent: number;
if (number < 1000) {
exponent = 0;
} else {
const maxExp = AbbreviationsLargeNumber.length - 1;
exponent = Math.floor(Math.log(number) / Math.log(1000));
exponent = Math.min(exponent, maxExp);
number /= Math.pow(1000, exponent);
}
return `${(exponent === 0) ? number : number.toFixed(rounded)}${AbbreviationsLargeNumber[exponent]}`;
}
export function formatStat(stat: integer, forHp: boolean = false): string {
return formatLargeNumber(stat, forHp ? 100000 : 1000000);
}