From 7bdb969a731f59708e1f9c8dd476b62777da174f Mon Sep 17 00:00:00 2001 From: William Burleson <72857839+Admiral-Billy@users.noreply.github.com> Date: Fri, 10 May 2024 06:42:28 -0400 Subject: [PATCH] Add rich presence support --- src/battle-scene.ts | 17 ++++++++++++++++- src/phases.ts | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 9a51950a5..0171fb96c 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -53,7 +53,7 @@ import PokemonSpriteSparkleHandler from './field/pokemon-sprite-sparkle-handler' import CharSprite from './ui/char-sprite'; import DamageNumberHandler from './field/damage-number-handler'; import PokemonInfoContainer from './ui/pokemon-info-container'; -import { biomeDepths } from './data/biomes'; +import { biomeDepths, getBiomeName } from './data/biomes'; import { UiTheme } from './enums/ui-theme'; import { SceneBase } from './scene-base'; import CandyBar from './ui/candy-bar'; @@ -200,6 +200,7 @@ export default class BattleScene extends SceneBase { this.phaseQueuePrepend = []; this.phaseQueuePrependSpliceIndex = -1; this.nextCommandPhaseQueue = []; + this.updateGameInfo(); } loadPokemonAtlas(key: string, atlasPath: string, experimental?: boolean) { @@ -769,6 +770,8 @@ export default class BattleScene extends SceneBase { this.trainer.setTexture(`trainer_${this.gameData.gender === PlayerGender.FEMALE ? 'f' : 'm'}_back`); this.trainer.setPosition(406, 186); this.trainer.setVisible(true); + + this.updateGameInfo(); if (reloadI18n) { const localizable: Localizable[] = [ @@ -1963,4 +1966,16 @@ export default class BattleScene extends SceneBase { return false; } + + updateGameInfo(): void { + const gameInfo = { + gameMode: this.currentBattle ? this.gameMode.getName() : 'Title', + biome: this.currentBattle ? getBiomeName(this.arena.biomeType) : '', + wave: this.currentBattle?.waveIndex || 0, + party: this.party ? this.party.map(p => { + return { name: p.name, level: p.level }; + }) : [] + }; + (window as any).gameInfo = gameInfo; + } } \ No newline at end of file diff --git a/src/phases.ts b/src/phases.ts index 71de11579..6144fe47a 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -680,6 +680,8 @@ export class EncounterPhase extends BattlePhase { start() { super.start(); + this.scene.updateGameInfo(); + this.scene.initSession(); const loadEnemyAssets = [];