Add rich presence support

pull/686/merge
William Burleson 2024-05-10 06:42:28 -04:00 committed by Samuel H
parent 5d62d0bb25
commit 7bdb969a73
2 changed files with 18 additions and 1 deletions

View File

@ -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;
}
}

View File

@ -680,6 +680,8 @@ export class EncounterPhase extends BattlePhase {
start() {
super.start();
this.scene.updateGameInfo();
this.scene.initSession();
const loadEnemyAssets = [];